Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 1 | /* MGW (Media Gateway) test suite in TTCN-3 |
| 2 | * (C) 2017-2018 Harald Welte <laforge@gnumonks.org> |
| 3 | * (C) 2018-2019 sysmocom - s.f.m.c. GmbH |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Released under the terms of GNU General Public License, Version 2 or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | */ |
| 11 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 12 | module MGCP_Test { |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 13 | import from Osmocom_Types all; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 14 | import from MGCP_Types all; |
Harald Welte | 4029e8c | 2017-11-23 22:00:42 +0100 | [diff] [blame] | 15 | import from MGCP_Templates all; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 16 | import from SDP_Types all; |
| 17 | import from MGCP_CodecPort all; |
| 18 | import from MGCP_CodecPort_CtrlFunct all; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 19 | import from RTP_CodecPort all; |
| 20 | import from RTP_CodecPort_CtrlFunct all; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 21 | import from RTP_Emulation all; |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 22 | import from IuUP_Emulation all; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 23 | import from OSMUX_Types all; |
| 24 | import from OSMUX_CodecPort all; |
| 25 | import from OSMUX_CodecPort_CtrlFunct all; |
| 26 | import from OSMUX_Emulation all; |
Pau Espin Pedrol | 71ed463 | 2022-09-02 18:51:19 +0200 | [diff] [blame] | 27 | import from AMR_Types all; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 28 | import from IPL4asp_Types all; |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 29 | import from General_Types all; |
| 30 | import from Native_Functions all; |
| 31 | import from IPCP_Types all; |
| 32 | import from IP_Types all; |
| 33 | import from Osmocom_VTY_Functions all; |
| 34 | import from TELNETasp_PortType all; |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 35 | import from StatsD_Types all; |
| 36 | import from StatsD_CodecPort all; |
| 37 | import from StatsD_CodecPort_CtrlFunct all; |
| 38 | import from StatsD_Checker all; |
Philipp Maier | 3560bd6 | 2021-08-19 11:52:23 +0200 | [diff] [blame] | 39 | import from Osmocom_CTRL_Functions all; |
| 40 | import from Osmocom_CTRL_Types all; |
| 41 | import from Osmocom_CTRL_Adapter all; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 42 | |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 43 | const charstring c_mgw_domain := "mgw"; |
| 44 | const charstring c_mgw_ep_rtpbridge := "rtpbridge/"; |
| 45 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 46 | /* any variables declared in the component will be available to |
| 47 | * all functions that 'run on' the named component, similar to |
| 48 | * class members in C++ */ |
Philipp Maier | 3560bd6 | 2021-08-19 11:52:23 +0200 | [diff] [blame] | 49 | type component dummy_CT extends StatsD_ConnHdlr, CTRL_Adapter_CT { |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 50 | port MGCP_CODEC_PT MGCP; |
| 51 | var boolean initialized := false; |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 52 | var ConnectionId g_mgcp_conn_id := -1; |
Harald Welte | e1e18c5 | 2017-09-17 16:23:07 +0800 | [diff] [blame] | 53 | var integer g_trans_id; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 54 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 55 | var RTP_Emulation_CT vc_RTPEM[3]; |
| 56 | port RTPEM_CTRL_PT RTPEM[3]; |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 57 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 58 | var OSMUX_Emulation_CT vc_OsmuxEM; |
| 59 | port OsmuxEM_CTRL_PT OsmuxEM; |
| 60 | |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 61 | port TELNETasp_PT MGWVTY; |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 62 | |
| 63 | var StatsD_Checker_CT vc_STATSD; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 64 | }; |
| 65 | |
Harald Welte | e1e18c5 | 2017-09-17 16:23:07 +0800 | [diff] [blame] | 66 | function get_next_trans_id() runs on dummy_CT return MgcpTransId { |
| 67 | var MgcpTransId tid := int2str(g_trans_id); |
| 68 | g_trans_id := g_trans_id + 1; |
| 69 | return tid; |
| 70 | } |
| 71 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 72 | /* all parameters declared here can be modified / overridden by |
| 73 | * the config file in the [MODULE_PARAMETERS] section. If no |
| 74 | * config file is used or the file doesn't specify them, the |
| 75 | * default values assigned below are used */ |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 76 | modulepar { |
| 77 | PortNumber mp_local_udp_port := 2727; |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 78 | charstring mp_local_ipv4 := "127.0.0.1"; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 79 | charstring mp_local_ipv6 := "::1"; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 80 | PortNumber mp_remote_udp_port := 2427; |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 81 | charstring mp_remote_ipv4 := "127.0.0.1"; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 82 | charstring mp_remote_ipv6 := "::1"; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 83 | PortNumber mp_local_rtp_port_base := 10000; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 84 | PortNumber mp_local_osmux_port := 1985; |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 85 | PortNumber mp_mgw_statsd_port := 8125; |
Philipp Maier | 3560bd6 | 2021-08-19 11:52:23 +0200 | [diff] [blame] | 86 | PortNumber mp_mgw_ctrl_port := 4267; |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 87 | /* Maximum number of available endpoints in osmo-mgw.cfg ("number endpoints"): */ |
Pau Espin Pedrol | 787e2e4 | 2022-10-07 10:58:35 +0200 | [diff] [blame] | 88 | integer mp_num_endpoints := 300; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 89 | } |
| 90 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 91 | private function f_vty_enable_osmux(boolean osmux_on) runs on dummy_CT { |
| 92 | /* Turn on conversion mode */ |
| 93 | f_vty_enter_config(MGWVTY); |
| 94 | f_vty_transceive(MGWVTY, "mgcp"); |
| 95 | if (osmux_on) { |
| 96 | f_vty_transceive(MGWVTY, "osmux on"); |
| 97 | } else { |
| 98 | f_vty_transceive(MGWVTY, "osmux off"); |
| 99 | } |
| 100 | f_vty_transceive(MGWVTY, "exit"); |
| 101 | f_vty_transceive(MGWVTY, "exit"); |
| 102 | |
| 103 | } |
| 104 | |
| 105 | private function f_init_vty(boolean osmux_on) runs on dummy_CT { |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 106 | map(self:MGWVTY, system:MGWVTY); |
| 107 | f_vty_set_prompts(MGWVTY); |
| 108 | f_vty_transceive(MGWVTY, "enable"); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 109 | |
| 110 | f_vty_enable_osmux(osmux_on); |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 113 | private function f_rtpem_init(inout RTP_Emulation_CT comp_ref, integer i) |
| 114 | runs on dummy_CT { |
| 115 | comp_ref := RTP_Emulation_CT.create("RTPEM" & int2str(i)); |
| 116 | map(comp_ref:RTP, system:RTP); |
| 117 | map(comp_ref:RTCP, system:RTCP); |
| 118 | comp_ref.start(RTP_Emulation.f_main()); |
| 119 | } |
| 120 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 121 | private function f_osmuxem_init(inout OSMUX_Emulation_CT comp_ref) |
| 122 | runs on dummy_CT { |
| 123 | comp_ref := OSMUX_Emulation_CT.create("OsmuxEM"); |
| 124 | map(comp_ref:OSMUX, system:OSMUX); |
| 125 | comp_ref.start(OSMUX_Emulation.f_main()); |
| 126 | } |
| 127 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 128 | /* initialization function, called by each test case at the |
| 129 | * beginning, but 'initialized' variable ensures its body is |
| 130 | * only executed once */ |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 131 | private function f_init(template MgcpEndpoint ep := omit, boolean osmux_on := false) runs on dummy_CT { |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 132 | var Result res; |
Harald Welte | f07c286 | 2017-11-18 17:16:24 +0100 | [diff] [blame] | 133 | var uint32_t ssrc; |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 134 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 135 | if (initialized == false) { |
| 136 | initialized := true; |
| 137 | |
| 138 | /* some random number for the initial transaction id */ |
| 139 | g_trans_id := float2int(rnd()*65535.0); |
| 140 | map(self:MGCP, system:MGCP_CODEC_PT); |
| 141 | /* connect the MGCP test port using the given |
| 142 | * source/destionation ip/port and store the connection id in g_mgcp_conn_id |
| 143 | * */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 144 | res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP, mp_remote_ipv4, mp_remote_udp_port, mp_local_ipv4, mp_local_udp_port, 0, { udp := {} }); |
Harald Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 145 | if (not ispresent(res.connId)) { |
| 146 | setverdict(fail, "Could not connect MGCP, check your configuration"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 147 | mtc.stop; |
Harald Welte | 9220f63 | 2018-05-23 20:27:02 +0200 | [diff] [blame] | 148 | } |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 149 | g_mgcp_conn_id := res.connId; |
| 150 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 151 | for (var integer i := 0; i < sizeof(vc_RTPEM); i := i+1) { |
| 152 | f_rtpem_init(vc_RTPEM[i], i); |
| 153 | connect(vc_RTPEM[i]:CTRL, self:RTPEM[i]); |
| 154 | } |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 155 | if (osmux_on) { |
| 156 | f_osmuxem_init(vc_OsmuxEM); |
| 157 | connect(vc_OsmuxEM:CTRL, self:OsmuxEM); |
| 158 | } |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 159 | |
Philipp Maier | 2ff3e66 | 2021-08-19 10:52:33 +0200 | [diff] [blame] | 160 | f_init_statsd("VirtCallAgent", vc_STATSD, mp_local_ipv4, mp_mgw_statsd_port); |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 161 | connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC); |
| 162 | |
| 163 | f_statsd_reset(); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 164 | } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 165 | |
Philipp Maier | 3560bd6 | 2021-08-19 11:52:23 +0200 | [diff] [blame] | 166 | f_ipa_ctrl_start_client(mp_remote_ipv4, mp_mgw_ctrl_port); |
| 167 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 168 | if (isvalue(ep)) { |
| 169 | /* do a DLCX on all connections of the EP */ |
| 170 | f_dlcx_ignore(valueof(ep)); |
| 171 | } |
Philipp Maier | 6137c32 | 2019-02-20 16:13:41 +0100 | [diff] [blame] | 172 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 173 | f_init_vty(osmux_on); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 174 | } |
| 175 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 176 | testcase TC_selftest() runs on dummy_CT { |
| 177 | const charstring c_auep := "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n"; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 178 | const charstring c_mdcx3 := "MDCX 18983215 " & c_mgw_ep_rtpbridge & "1@" & c_mgw_domain & " MGCP 1.0\r\n"; |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 179 | const charstring c_mdcx3_ret := "200 18983215 OK\r\n" & |
| 180 | "I: 1\n" & |
| 181 | "\n" & |
| 182 | "v=0\r\n" & |
| 183 | "o=- 1 23 IN IP4 0.0.0.0\r\n" & |
| 184 | "s=-\r\n" & |
| 185 | "c=IN IP4 0.0.0.0\r\n" & |
| 186 | "t=0 0\r\n" & |
| 187 | "m=audio 0 RTP/AVP 126\r\n" & |
| 188 | "a=rtpmap:126 AMR/8000\r\n" & |
| 189 | "a=ptime:20\r\n"; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 190 | const charstring c_mdcx4 := "MDCX 18983216 " & c_mgw_ep_rtpbridge & "1@" & c_mgw_domain & " MGCP 1.0\r\n" & |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 191 | "M: sendrecv\r" & |
| 192 | "C: 2\r\n" & |
| 193 | "I: 1\r\n" & |
| 194 | "L: p:20, a:AMR, nt:IN\r\n" & |
| 195 | "\n" & |
| 196 | "v=0\r\n" & |
| 197 | "o=- 1 23 IN IP4 0.0.0.0\r\n" & |
Harald Welte | 2871d0b | 2017-09-14 22:42:12 +0800 | [diff] [blame] | 198 | "s=-\r\n" & |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 199 | "c=IN IP4 0.0.0.0\r\n" & |
| 200 | "t=0 0\r\n" & |
| 201 | "m=audio 4441 RTP/AVP 99\r\n" & |
| 202 | "a=rtpmap:99 AMR/8000\r\n" & |
| 203 | "a=ptime:40\r\n"; |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 204 | const charstring c_crcx510_ret := "510 23 FAIL\r\n" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 205 | |
| 206 | log(c_auep); |
| 207 | log(dec_MgcpCommand(c_auep)); |
| 208 | |
| 209 | log(c_mdcx3); |
| 210 | log(dec_MgcpCommand(c_mdcx3)); |
| 211 | |
| 212 | log(c_mdcx3_ret); |
| 213 | log(dec_MgcpResponse(c_mdcx3_ret)); |
| 214 | |
| 215 | log(c_mdcx4); |
| 216 | log(dec_MgcpCommand(c_mdcx4)); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 217 | |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 218 | log(ts_CRCX("23", c_mgw_ep_rtpbridge & "42@" & c_mgw_domain, "sendrecv", '1234'H)); |
| 219 | log(enc_MgcpCommand(valueof(ts_CRCX("23", c_mgw_ep_rtpbridge & "42@" & c_mgw_domain, "sendrecv", '1234'H)))); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 220 | |
| 221 | log(c_crcx510_ret); |
| 222 | log(dec_MgcpResponse(c_crcx510_ret)); |
| 223 | log(dec_MgcpMessage(c_crcx510_ret)); |
Daniel Willmann | 94e4e80 | 2018-12-13 16:56:26 +0100 | [diff] [blame] | 224 | |
| 225 | /* We didn't encounter any DTE, so pass the test */ |
| 226 | setverdict(pass); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 227 | } |
| 228 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 229 | /* CRCX test ideas: |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 230 | * x without mandatory CallId |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 231 | * - with forbidden parameters (e.g. Capabilities, PackageList, ... |
| 232 | * - CRCX with remote session description and without |
| 233 | * |
| 234 | * general ideas: |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 235 | * x packetization != 20ms |
| 236 | * x invalid mode |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 237 | * x unsupported mode (517) |
| 238 | * x bidirectional mode before RemoteConnDesc: 527 |
| 239 | * - invalid codec |
Harald Welte | e0b331f | 2017-11-18 20:34:33 +0100 | [diff] [blame] | 240 | * x retransmission of same transaction |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 241 | * - unsupported LocalConnectionOptions ("b", "a", "e", "gc", "s", "r", "k", ..) |
| 242 | */ |
| 243 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 244 | /* build a receive template for receiving a MGCP message. You |
| 245 | * pass the MGCP response template in, and it will generate an |
| 246 | * MGCP_RecvFrom template that can match the primitives arriving on the |
| 247 | * MGCP_CodecPort */ |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 248 | function tr_MGCP_RecvFrom_R(template MgcpResponse resp) runs on dummy_CT return template MGCP_RecvFrom { |
| 249 | var template MGCP_RecvFrom mrf := { |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 250 | connId := g_mgcp_conn_id, |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 251 | remName := mp_remote_ipv4, |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 252 | remPort := mp_remote_udp_port, |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 253 | locName := mp_local_ipv4, |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 254 | locPort := mp_local_udp_port, |
| 255 | msg := { response := resp } |
| 256 | } |
| 257 | return mrf; |
| 258 | } |
| 259 | |
| 260 | /* Send a MGCP request + receive a (matching!) response */ |
| 261 | function mgcp_transceive_mgw(template MgcpCommand cmd, template MgcpResponse resp := ?) runs on dummy_CT return MgcpResponse { |
| 262 | var MgcpMessage msg := { command := valueof(cmd) }; |
| 263 | resp.line.trans_id := cmd.line.trans_id; |
| 264 | var template MGCP_RecvFrom mrt := tr_MGCP_RecvFrom_R(resp); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 265 | var MGCP_RecvFrom mrf; |
| 266 | timer T := 5.0; |
| 267 | |
Harald Welte | 5501536 | 2017-11-18 16:02:42 +0100 | [diff] [blame] | 268 | MGCP.send(t_MGCP_Send(g_mgcp_conn_id, msg)); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 269 | T.start; |
| 270 | alt { |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 271 | [] MGCP.receive(mrt) -> value mrf { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 272 | [] MGCP.receive(tr_MGCP_RecvFrom_R(?)) { |
| 273 | setverdict(fail, "Response didn't match template"); |
| 274 | mtc.stop; |
| 275 | } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 276 | [] MGCP.receive { repeat; } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 277 | [] T.timeout { |
| 278 | setverdict(fail, "Timeout waiting for response to ", cmd); |
| 279 | mtc.stop; |
| 280 | } |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 281 | } |
| 282 | T.stop; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 283 | |
| 284 | if (isbound(mrf) and isbound(mrf.msg) and ischosen(mrf.msg.response)) { |
| 285 | return mrf.msg.response; |
| 286 | } else { |
| 287 | var MgcpResponse r := { line := { code := "999", trans_id := valueof(cmd.line.trans_id) } }; |
| 288 | return r; |
| 289 | } |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 292 | function extract_conn_id(MgcpResponse resp) return MgcpConnectionId { |
| 293 | var integer i; |
| 294 | for (i := 0; i < lengthof(resp.params); i := i + 1) { |
| 295 | var MgcpParameter par := resp.params[i]; |
| 296 | if (par.code == "I") { |
| 297 | return str2hex(par.val); |
| 298 | } |
| 299 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 300 | setverdict(fail, "Could not find conn id for MgcpReponse"); |
| 301 | mtc.stop; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 302 | return '00000000'H; |
| 303 | } |
| 304 | |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 305 | function f_dlcx(MgcpEndpoint ep, template MgcpResponseCode ret_code, template charstring ret_val, |
| 306 | template MgcpCallId call_id := omit, |
| 307 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 308 | var template MgcpCommand cmd; |
| 309 | var MgcpResponse resp; |
| 310 | var template MgcpResponse rtmpl := { |
| 311 | line := { |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 312 | code := ret_code, |
| 313 | string := ret_val |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 314 | }, |
| 315 | params := *, |
| 316 | sdp := * |
| 317 | }; |
Harald Welte | c40e0c3 | 2017-11-18 19:08:22 +0100 | [diff] [blame] | 318 | cmd := ts_DLCX(get_next_trans_id(), ep, call_id, conn_id); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 319 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 320 | } |
| 321 | |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 322 | /* Send DLCX and expect OK response */ |
| 323 | function f_dlcx_ok(MgcpEndpoint ep, template MgcpCallId call_id := omit, |
| 324 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
Harald Welte | f91edf3 | 2017-12-28 14:16:21 +0100 | [diff] [blame] | 325 | f_dlcx(ep, ("200","250"), "OK", call_id, conn_id); |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 328 | /* Send DLCX and accept any response */ |
Harald Welte | c40e0c3 | 2017-11-18 19:08:22 +0100 | [diff] [blame] | 329 | function f_dlcx_ignore(MgcpEndpoint ep, template MgcpCallId call_id := omit, |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 330 | template MgcpConnectionId conn_id := omit) runs on dummy_CT { |
Harald Welte | 10889c1 | 2017-11-18 19:40:31 +0100 | [diff] [blame] | 331 | f_dlcx(ep, ?, *, call_id, conn_id); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 332 | } |
| 333 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 334 | type record HostPort { |
| 335 | charstring hostname, |
| 336 | integer portnr optional |
| 337 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 338 | type record RtpOsmuxFlowData { |
| 339 | boolean local_cid_sent, /* whther non wildcarded CID was already sent to MGW */ |
| 340 | MgcpOsmuxCID local_cid optional, |
| 341 | MgcpOsmuxCID remote_cid optional, |
| 342 | OsmuxemConfig cfg optional |
| 343 | } |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 344 | type record RtpCodecDescr { |
| 345 | uint7_t pt, |
| 346 | charstring codec, |
| 347 | charstring fmtp optional |
| 348 | } |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 349 | type record RtpFlowData { |
| 350 | HostPort em, /* emulation side */ |
| 351 | HostPort mgw, /* mgw side */ |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 352 | MgcpConnectionId mgcp_conn_id optional, |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 353 | record of RtpCodecDescr codec_descr, |
Philipp Maier | c8c0b40 | 2019-03-07 10:48:45 +0100 | [diff] [blame] | 354 | RtpemConfig rtp_cfg optional, |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 355 | RtpOsmuxFlowData osmux |
| 356 | } |
| 357 | |
Philipp Maier | d6c4559 | 2023-03-31 16:41:51 +0200 | [diff] [blame] | 358 | template RtpFlowData t_RtpFlow(charstring host_a, charstring host_b, uint7_t pt, |
| 359 | charstring codec, template charstring fmtp := omit) := { |
| 360 | em := { |
| 361 | hostname := host_a, |
| 362 | portnr := omit |
| 363 | }, |
| 364 | mgw := { |
| 365 | hostname := host_b, |
| 366 | portnr := omit |
| 367 | }, |
| 368 | codec_descr := {{ |
| 369 | pt := pt, |
| 370 | codec := codec, |
| 371 | fmtp := fmtp |
| 372 | }}, |
| 373 | osmux:= { |
| 374 | local_cid_sent := false, |
| 375 | local_cid := omit, |
| 376 | remote_cid := omit, |
| 377 | cfg := omit |
| 378 | } |
| 379 | } |
| 380 | |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 381 | /* To be used with f_flow_create/modify... functions */ |
| 382 | function f_gen_sdp(RtpFlowData flow) runs on dummy_CT return SDP_Message { |
| 383 | var template SDP_Message sdp; |
| 384 | var SDP_fmt_list fmt_list := {}; |
| 385 | var SDP_attribute_list attributes := {}; |
| 386 | |
| 387 | /* Add SDP RTMAP attributes (codec type, referenced by PT) */ |
| 388 | for (var integer i := 0; i < lengthof(flow.codec_descr); i := i + 1) { |
| 389 | attributes := attributes & { valueof(ts_SDP_rtpmap(flow.codec_descr[i].pt, |
| 390 | flow.codec_descr[i].codec)) }; |
| 391 | } |
| 392 | |
| 393 | /* Add SDP PTIME attribute, regardless of which codec, the packet intervall remains the same */ |
| 394 | attributes := attributes & { valueof(ts_SDP_ptime(20)) }; |
| 395 | |
| 396 | /* Add SDP FMTP attributes (codec parameters for each codec, referenced by PT) */ |
| 397 | for (var integer i := 0; i < lengthof(flow.codec_descr); i := i + 1) { |
| 398 | if (isvalue(flow.codec_descr[i].fmtp) and flow.codec_descr[i].fmtp != "") { |
| 399 | attributes := attributes & { valueof(ts_SDP_fmtp(flow.codec_descr[i].pt, |
| 400 | flow.codec_descr[i].fmtp)) }; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /* Final step: Generate SDP */ |
| 405 | for (var integer i := 0; i < lengthof(flow.codec_descr); i := i + 1) { |
| 406 | fmt_list := fmt_list & {int2str(flow.codec_descr[i].pt)}; |
| 407 | } |
| 408 | sdp := ts_SDP(flow.em.hostname, flow.em.hostname, "23", "42", flow.em.portnr, fmt_list, attributes); |
| 409 | |
| 410 | return valueof(sdp); |
| 411 | } |
| 412 | |
| 413 | /* Generate a valid RTP emulation config from the payload type numbers configured in the flow description and |
| 414 | * the the default configuration of the RTP emulation module. */ |
| 415 | function f_gen_rtpem_config_from_flow(RtpFlowData flow) return RtpemConfig { |
| 416 | var RtpemConfig rtp_cfg := c_RtpemDefaultCfg; |
| 417 | |
| 418 | for (var integer i := 0; i < lengthof(flow.codec_descr); i := i + 1) { |
| 419 | var RtpemConfigPayload tx_cfg_payload; |
| 420 | var RtpemConfigPayload rx_cfg_payload; |
| 421 | |
| 422 | tx_cfg_payload.payload_type := flow.codec_descr[i].pt; |
| 423 | tx_cfg_payload.fixed_payload := c_RtpemDefaultCfg.tx_payloads[0].fixed_payload; |
| 424 | rx_cfg_payload.payload_type := flow.codec_descr[i].pt; |
| 425 | rx_cfg_payload.fixed_payload := c_RtpemDefaultCfg.rx_payloads[0].fixed_payload; |
| 426 | |
| 427 | rtp_cfg.tx_payloads := rtp_cfg.tx_payloads & {tx_cfg_payload}; |
| 428 | rtp_cfg.rx_payloads := rtp_cfg.rx_payloads & {rx_cfg_payload}; |
| 429 | } |
| 430 | |
| 431 | return rtp_cfg; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 432 | } |
| 433 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 434 | /* Create an RTP flow (bidirectional, or receive-only) */ |
| 435 | function f_flow_create(RTPEM_CTRL_PT pt, MgcpEndpoint ep, MgcpCallId call_id, charstring mode, inout RtpFlowData flow, |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 436 | boolean one_phase := true) |
| 437 | runs on dummy_CT { |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 438 | var template MgcpCommand cmd; |
| 439 | var MgcpResponse resp; |
| 440 | |
| 441 | /* bind local RTP emulation socket */ |
| 442 | f_rtpem_bind(pt, flow.em.hostname, flow.em.portnr); |
| 443 | |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 444 | /* configure rtp-emulation */ |
| 445 | if (ispresent(flow.rtp_cfg)) { |
| 446 | f_rtpem_configure(pt, flow.rtp_cfg); |
| 447 | } else { |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 448 | f_rtpem_configure(pt, f_gen_rtpem_config_from_flow(flow)); |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 449 | } |
| 450 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 451 | if (one_phase) { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 452 | /* Connect flow to MGW using a CRCX that also contains an SDP |
| 453 | * part that tells the MGW where we are listening for RTP streams |
| 454 | * that come from the MGW. We get a fully working connection in |
| 455 | * one go. */ |
| 456 | |
| 457 | cmd := ts_CRCX(get_next_trans_id(), ep, mode, call_id); |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 458 | cmd.sdp := f_gen_sdp(flow); |
Philipp Maier | c8c0b40 | 2019-03-07 10:48:45 +0100 | [diff] [blame] | 459 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 460 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 461 | flow.mgcp_conn_id := extract_conn_id(resp); |
| 462 | /* extract port number from response */ |
| 463 | flow.mgw.portnr := |
| 464 | resp.sdp.media_list[0].media_field.ports.port_number; |
| 465 | } else { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 466 | /* Create a half-open connection only. We do not tell the MGW |
| 467 | * where it can send RTP streams to us. This means this |
| 468 | * connection will only be able to receive but can not send |
| 469 | * data back to us. In order to turn the connection in a fully |
| 470 | * bi-directional one, a separate MDCX is needed. */ |
| 471 | |
| 472 | cmd := ts_CRCX(get_next_trans_id(), ep, mode, call_id); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 473 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 474 | flow.mgcp_conn_id := extract_conn_id(resp); |
| 475 | /* extract MGW-side port number from response */ |
| 476 | flow.mgw.portnr := |
| 477 | resp.sdp.media_list[0].media_field.ports.port_number; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 478 | } |
| 479 | /* finally, connect the emulation-side RTP socket to the MGW */ |
| 480 | f_rtpem_connect(pt, flow.mgw.hostname, flow.mgw.portnr); |
| 481 | } |
| 482 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 483 | /* Create an Osmux flow (bidirectional, or receive-only) */ |
| 484 | function f_flow_create_osmux(OsmuxEM_CTRL_PT pt, MgcpEndpoint ep, MgcpCallId call_id, charstring mode, inout RtpFlowData flow, |
| 485 | boolean one_phase := true) |
| 486 | runs on dummy_CT { |
| 487 | var template MgcpCommand cmd; |
| 488 | var MgcpResponse resp; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 489 | var OsmuxTxHandle tx_hdl; |
| 490 | var OsmuxRxHandle rx_hdl; |
| 491 | var charstring cid_response; |
| 492 | var OsmuxCID cid_resp_parsed |
| 493 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 494 | /* bind local Osmux emulation socket */ |
| 495 | f_osmuxem_bind(pt, flow.em.hostname, flow.em.portnr); |
| 496 | |
| 497 | /* configure osmux-emulation */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 498 | if (ispresent(flow.osmux.cfg)) { |
| 499 | f_osmuxem_configure(pt, flow.osmux.cfg); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 500 | } else { |
| 501 | var OsmuxemConfig osmux_cfg := c_OsmuxemDefaultCfg; |
| 502 | f_osmuxem_configure(pt, osmux_cfg); |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 503 | flow.osmux.cfg := osmux_cfg |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | if (one_phase) { |
| 507 | /* Connect flow to MGW using a CRCX that also contains an SDP |
| 508 | * part that tells the MGW where we are listening for Osmux streams |
| 509 | * that come from the MGW. We get a fully working connection in |
| 510 | * one go. */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 511 | if (flow.osmux.local_cid != -1) { |
Pau Espin Pedrol | 71387aa | 2020-09-08 14:27:43 +0200 | [diff] [blame] | 512 | /* We may still want to negotiate osmux CID later at MDCX */ |
| 513 | rx_hdl := c_OsmuxemDefaultRxHandle; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 514 | rx_hdl.cid := flow.osmux.local_cid; |
Pau Espin Pedrol | 71387aa | 2020-09-08 14:27:43 +0200 | [diff] [blame] | 515 | f_osmuxem_register_rxhandle(pt, rx_hdl); |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 516 | flow.osmux.local_cid_sent := true; |
Pau Espin Pedrol | 71387aa | 2020-09-08 14:27:43 +0200 | [diff] [blame] | 517 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 518 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, mode, call_id, flow.osmux.local_cid); |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 519 | cmd.sdp := f_gen_sdp(flow); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 520 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK_osmux); |
| 521 | flow.mgcp_conn_id := extract_conn_id(resp); |
| 522 | /* extract port number from response */ |
| 523 | flow.mgw.portnr := |
| 524 | resp.sdp.media_list[0].media_field.ports.port_number; |
| 525 | } else { |
| 526 | /* Create a half-open connection only. We do not tell the MGW |
| 527 | * where it can send Osmux streams to us. This means this |
| 528 | * connection will only be able to receive but can not send |
| 529 | * data back to us. In order to turn the connection in a fully |
| 530 | * bi-directional one, a separate MDCX is needed. */ |
| 531 | |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 532 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, mode, call_id, flow.osmux.local_cid); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 533 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK_osmux); |
| 534 | |
| 535 | flow.mgcp_conn_id := extract_conn_id(resp); |
| 536 | /* extract MGW-side port number from response */ |
| 537 | flow.mgw.portnr := |
| 538 | resp.sdp.media_list[0].media_field.ports.port_number; |
| 539 | } |
| 540 | |
| 541 | /* extract Osmux CID we got assigned by the MGW */ |
| 542 | var MgcpMessage resp_msg := { |
| 543 | response := resp |
| 544 | } |
| 545 | |
| 546 | if (f_mgcp_find_param(resp_msg, "X-OSMUX", cid_response) == false) { |
| 547 | setverdict(fail, "No Osmux CID in MGCP response", resp); |
| 548 | mtc.stop; |
| 549 | } |
| 550 | |
| 551 | /* Make sure response is no wildcard */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 552 | flow.osmux.remote_cid := f_mgcp_osmux_cid_decode(cid_response); |
| 553 | if (flow.osmux.remote_cid == -1) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 554 | setverdict(fail, "Osmux CID in MGCP response contains unexpected wildcard"); |
| 555 | mtc.stop; |
| 556 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 557 | tx_hdl := valueof(t_TxHandleAMR590(flow.osmux.remote_cid)); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 558 | f_osmuxem_register_txhandle(pt, tx_hdl); |
| 559 | |
| 560 | /* finally, connect the emulation-side RTP socket to the MGW */ |
| 561 | f_osmuxem_connect(pt, flow.mgw.hostname, flow.mgw.portnr); |
| 562 | } |
| 563 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 564 | /* Modify an existing RTP flow */ |
| 565 | function f_flow_modify(RTPEM_CTRL_PT pt, MgcpEndpoint ep, MgcpCallId call_id, charstring mode, inout RtpFlowData flow) |
| 566 | runs on dummy_CT { |
| 567 | var template MgcpCommand cmd; |
| 568 | var MgcpResponse resp; |
| 569 | |
| 570 | /* rebind local RTP emulation socket to the new address */ |
| 571 | f_rtpem_bind(pt, flow.em.hostname, flow.em.portnr); |
| 572 | |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 573 | /* reconfigure rtp-emulation */ |
| 574 | if (ispresent(flow.rtp_cfg)) { |
| 575 | f_rtpem_configure(pt, flow.rtp_cfg); |
| 576 | } else { |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 577 | f_rtpem_configure(pt, f_gen_rtpem_config_from_flow(flow)); |
Philipp Maier | 28bb829 | 2018-07-20 17:09:17 +0200 | [diff] [blame] | 578 | } |
| 579 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 580 | /* connect MGW side RTP socket to the emulation-side RTP socket using SDP */ |
| 581 | cmd := ts_MDCX(get_next_trans_id(), ep, mode, call_id, flow.mgcp_conn_id); |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 582 | cmd.sdp := f_gen_sdp(flow); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 583 | resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK); |
| 584 | |
| 585 | /* extract MGW-side port number from response. (usually this |
| 586 | * will not change, but thats is up to the MGW) */ |
| 587 | flow.mgw.portnr := |
| 588 | resp.sdp.media_list[0].media_field.ports.port_number; |
| 589 | |
| 590 | /* reconnect the emulation-side RTP socket to the MGW */ |
| 591 | f_rtpem_connect(pt, flow.mgw.hostname, flow.mgw.portnr); |
| 592 | } |
| 593 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 594 | /* Modify an existing Osmux flow */ |
| 595 | function f_flow_modify_osmux(OsmuxEM_CTRL_PT pt, MgcpEndpoint ep, MgcpCallId call_id, charstring mode, inout RtpFlowData flow) |
| 596 | runs on dummy_CT { |
| 597 | var template MgcpCommand cmd; |
| 598 | var MgcpResponse resp; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 599 | var OsmuxRxHandle rx_hdl; |
| 600 | var charstring cid_response; |
| 601 | var OsmuxCID cid_resp_parsed |
| 602 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 603 | /* rebind local Osmux emulation socket to the new address */ |
| 604 | f_osmuxem_bind(pt, flow.em.hostname, flow.em.portnr); |
| 605 | |
| 606 | /* configure osmux-emulation */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 607 | if (ispresent(flow.osmux.cfg)) { |
| 608 | f_osmuxem_configure(pt, flow.osmux.cfg); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 609 | } else { |
| 610 | var OsmuxemConfig osmux_cfg := c_OsmuxemDefaultCfg; |
| 611 | f_osmuxem_configure(pt, osmux_cfg); |
| 612 | } |
| 613 | |
| 614 | /* We didn't send a non-wildcarded Osmux CID yet. If caller wants to submit it, register handler */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 615 | if (flow.osmux.local_cid_sent == false and flow.osmux.local_cid != -1) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 616 | rx_hdl := c_OsmuxemDefaultRxHandle; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 617 | rx_hdl.cid := flow.osmux.local_cid; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 618 | f_osmuxem_register_rxhandle(pt, rx_hdl); |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 619 | flow.osmux.local_cid_sent := true; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /* connect MGW side Osmux socket to the emulation-side Osmux socket using SDP */ |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 623 | cmd := ts_MDCX_osmux(get_next_trans_id(), ep, mode, call_id, flow.mgcp_conn_id, flow.osmux.local_cid); |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 624 | cmd.sdp := f_gen_sdp(flow); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 625 | resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK); |
| 626 | |
| 627 | /* extract MGW-side port number from response. (usually this |
| 628 | * will not change, but thats is up to the MGW) */ |
| 629 | flow.mgw.portnr := |
| 630 | resp.sdp.media_list[0].media_field.ports.port_number; |
| 631 | |
| 632 | /* extract Osmux CID we got assigned by the MGW */ |
| 633 | var MgcpMessage resp_msg := { |
| 634 | response := resp |
| 635 | } |
| 636 | |
| 637 | if (f_mgcp_find_param(resp_msg, "X-OSMUX", cid_response) == false) { |
| 638 | setverdict(fail, "No Osmux CID in MGCP response", resp); |
| 639 | mtc.stop; |
| 640 | } |
| 641 | |
| 642 | /* Make sure response is no wildcard */ |
| 643 | cid_resp_parsed := f_mgcp_osmux_cid_decode(cid_response); |
| 644 | if (cid_resp_parsed == -1) { |
| 645 | setverdict(fail, "Osmux CID in MGCP response contains unexpected wildcard"); |
| 646 | mtc.stop; |
| 647 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 648 | if (cid_resp_parsed != flow.osmux.remote_cid) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 649 | setverdict(fail, "Osmux CID in MGCP MDCX response changed from prev value"); |
| 650 | mtc.stop; |
| 651 | } |
| 652 | |
| 653 | /* reconnect the emulation-side Osmux socket to the MGW */ |
| 654 | f_osmuxem_connect(pt, flow.mgw.hostname, flow.mgw.portnr); |
| 655 | } |
| 656 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 657 | /* Delete an existing RTP flow */ |
| 658 | function f_flow_delete(RTPEM_CTRL_PT pt, template MgcpEndpoint ep := omit, template MgcpCallId call_id := omit) |
| 659 | runs on dummy_CT { |
| 660 | var template MgcpCommand cmd; |
| 661 | var MgcpResponse resp; |
| 662 | |
| 663 | /* Switch off RTP flow */ |
| 664 | f_rtpem_mode(pt, RTPEM_MODE_NONE); |
| 665 | |
| 666 | /* Delete connection on MGW (if needed) */ |
| 667 | if (isvalue(call_id) and isvalue(ep)) { |
| 668 | f_sleep(0.1); |
| 669 | f_dlcx_ok(valueof(ep), call_id); |
| 670 | } |
| 671 | } |
| 672 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 673 | /* Delete an existing Osmux flow */ |
| 674 | function f_flow_delete_osmux(OsmuxEM_CTRL_PT pt, template MgcpEndpoint ep := omit, template MgcpCallId call_id := omit) |
| 675 | runs on dummy_CT { |
| 676 | var template MgcpCommand cmd; |
| 677 | var MgcpResponse resp; |
| 678 | |
| 679 | /* Switch off Osmux flow */ |
| 680 | f_osmuxem_mode(pt, OSMUXEM_MODE_NONE); |
| 681 | |
| 682 | /* Delete connection on MGW (if needed) */ |
| 683 | if (isvalue(call_id) and isvalue(ep)) { |
| 684 | f_sleep(0.1); |
| 685 | f_dlcx_ok(valueof(ep), call_id); |
| 686 | } |
| 687 | } |
| 688 | |
Pau Espin Pedrol | b26d446 | 2023-06-15 11:38:02 +0200 | [diff] [blame] | 689 | /* Send an AuditEndpoint message to the MGW */ |
| 690 | function f_auep(charstring ep_prefix) runs on dummy_CT { |
| 691 | var MgcpEndpoint ep := ep_prefix & "@" & c_mgw_domain; |
| 692 | var template MgcpCommand cmd; |
| 693 | var MgcpResponse resp; |
| 694 | |
| 695 | f_init(ep); |
| 696 | |
| 697 | cmd := ts_AUEP(get_next_trans_id(), ep); |
| 698 | resp := mgcp_transceive_mgw(cmd, tr_AUEP_ACK); |
| 699 | } |
| 700 | |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 701 | function f_crcx(charstring ep_prefix) runs on dummy_CT { |
| 702 | var MgcpEndpoint ep := ep_prefix & "2@" & c_mgw_domain; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 703 | var template MgcpCommand cmd; |
| 704 | var MgcpResponse resp; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 705 | var MgcpCallId call_id := '1234'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 706 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 707 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 708 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 709 | /* create the connection on the MGW */ |
| 710 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 711 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 712 | extract_conn_id(resp); |
| 713 | |
| 714 | /* clean-up */ |
| 715 | f_dlcx_ok(ep, call_id); |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 716 | } |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 717 | |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 718 | function f_crcx_no_lco(charstring ep_prefix) runs on dummy_CT { |
| 719 | var MgcpEndpoint ep := ep_prefix & "2@" & c_mgw_domain; |
| 720 | var template MgcpCommand cmd; |
| 721 | var MgcpResponse resp; |
| 722 | var MgcpCallId call_id := '1234'H; |
| 723 | |
| 724 | f_init(ep); |
| 725 | |
| 726 | /* create the connection on the MGW */ |
| 727 | cmd := ts_CRCX_no_lco(get_next_trans_id(), ep, "recvonly", call_id); |
| 728 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 729 | extract_conn_id(resp); |
| 730 | |
| 731 | /* clean-up */ |
| 732 | f_dlcx_ok(ep, call_id); |
| 733 | |
| 734 | /* See also OS#2658: Even when we omit the LCO information, we |
| 735 | expect the MGW to pick a sane payload type for us. This |
| 736 | payload type should be visible in the SDP of the response. */ |
Philipp Maier | 76a8d01 | 2018-06-21 10:03:13 +0200 | [diff] [blame] | 737 | if (resp.sdp.media_list[0].media_field.fmts[0] != "0") { |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 738 | setverdict(fail, "SDP contains unexpected codec"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 739 | mtc.stop; |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /* See also OS#2658: We also expect the MGW to assign a port |
| 743 | number to us. */ |
| 744 | if (isbound(resp.sdp.media_list[0].media_field.ports.port_number) == false) { |
| 745 | setverdict(fail, "SDP does not contain a port number"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 746 | mtc.stop; |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 747 | } |
| 748 | } |
| 749 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 750 | function f_crcx_osmux(charstring ep_prefix, MgcpOsmuxCID osmux_cid, boolean run_init := true) runs on dummy_CT { |
| 751 | var MgcpEndpoint ep := ep_prefix & "2@" & c_mgw_domain; |
| 752 | var template MgcpCommand cmd; |
| 753 | var MgcpResponse resp; |
| 754 | var MgcpCallId call_id := '1234'H; |
| 755 | var charstring cid_response; |
| 756 | |
| 757 | if (run_init) { |
| 758 | f_init(ep, true); |
| 759 | } |
| 760 | |
| 761 | /* create the connection on the MGW */ |
| 762 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, "recvonly", call_id, osmux_cid); |
| 763 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK_osmux); |
| 764 | extract_conn_id(resp); |
| 765 | |
| 766 | /* extract Osmux CID we got assigned by the MGW */ |
| 767 | var MgcpMessage resp_msg := { |
| 768 | response := resp |
| 769 | } |
| 770 | |
| 771 | if (f_mgcp_find_param(resp_msg, "X-OSMUX", cid_response) == false) { |
| 772 | setverdict(fail, "No Osmux CID in MGCP response", resp); |
| 773 | mtc.stop; |
| 774 | } |
| 775 | |
| 776 | /* Make sure response is no wildcard */ |
| 777 | if (f_mgcp_osmux_cid_decode(cid_response) == -1) { |
| 778 | setverdict(fail, "Osmux CID in MGCP response contains unexpected wildcard"); |
| 779 | mtc.stop; |
| 780 | } |
| 781 | |
| 782 | /* clean-up */ |
| 783 | f_dlcx_ok(ep, call_id); |
| 784 | } |
| 785 | |
Pau Espin Pedrol | b26d446 | 2023-06-15 11:38:02 +0200 | [diff] [blame] | 786 | /* test valid AUEP towards "null" endpoint */ |
| 787 | testcase TC_auep_null() runs on dummy_CT { |
| 788 | f_auep("null"); |
| 789 | setverdict(pass); |
| 790 | } |
| 791 | |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 792 | /* test valid CRCX without SDP */ |
| 793 | testcase TC_crcx() runs on dummy_CT { |
| 794 | f_crcx(c_mgw_ep_rtpbridge); |
| 795 | setverdict(pass); |
| 796 | } |
| 797 | |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 798 | /* test valid CRCX without SDP and LCO */ |
| 799 | testcase TC_crcx_no_lco() runs on dummy_CT { |
| 800 | f_crcx_no_lco(c_mgw_ep_rtpbridge); |
| 801 | setverdict(pass); |
| 802 | } |
| 803 | |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 804 | /* test valid CRCX without SDP (older method without endpoint prefix) */ |
| 805 | testcase TC_crcx_noprefix() runs on dummy_CT { |
| 806 | f_crcx(""); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 807 | setverdict(pass); |
| 808 | } |
| 809 | |
| 810 | /* test CRCX with unsupported mode, expect 517 */ |
| 811 | testcase TC_crcx_unsupp_mode() runs on dummy_CT { |
| 812 | var template MgcpCommand cmd; |
| 813 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 814 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 815 | var MgcpCallId call_id := '1233'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 816 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("517"); |
| 817 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 818 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 819 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 820 | cmd := ts_CRCX(get_next_trans_id(), ep, "netwtest", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 821 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 822 | setverdict(pass); |
| 823 | } |
| 824 | |
Pau Espin Pedrol | befd3aa | 2020-09-21 10:54:42 +0200 | [diff] [blame] | 825 | /* Test CRCX with X-Osmo-IGN, using same message as SYS#5063 to make sure it doesn't cause a crash. */ |
| 826 | testcase TC_crcx_osmo_ign() runs on dummy_CT { |
| 827 | var template MgcpCommand cmd; |
| 828 | var MgcpResponse resp; |
| 829 | var MgcpEndpoint ep := "7@" & c_mgw_domain; |
| 830 | var MgcpCallId call_id := '3'H; |
| 831 | |
| 832 | f_init(ep); |
| 833 | |
| 834 | /* CRCX 1 7@mgw MGCP 1.0 |
| 835 | C: 3 |
| 836 | L: p:20, a:GSM-EFR, nt:IN |
| 837 | M: recvonly |
| 838 | X-Osmo-IGN: C |
| 839 | */ |
| 840 | |
| 841 | cmd := ts_CRCX(get_next_trans_id(), ep, "netwtest", call_id); |
| 842 | cmd.params := {ts_MgcpParCallId(call_id), |
| 843 | t_MgcpParLocConnOpt("p:20, a:GSM-EFR, nt:IN"), |
| 844 | t_MgcpParConnMode("recvonly"), |
| 845 | t_MgcpParOsmoIGN("C")}; |
| 846 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 847 | extract_conn_id(resp); |
| 848 | |
| 849 | /* clean-up */ |
| 850 | f_dlcx_ok(ep, call_id); |
| 851 | setverdict(pass); |
| 852 | } |
| 853 | |
Harald Welte | 21ba557 | 2017-09-19 17:55:05 +0800 | [diff] [blame] | 854 | /* test CRCX with early bi-directional mode, expect 527 as |
| 855 | * bi-diretional media can only be established once both local and |
| 856 | * remote side are specified, see MGCP RFC */ |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 857 | testcase TC_crcx_early_bidir_mode() runs on dummy_CT { |
| 858 | var template MgcpCommand cmd; |
| 859 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 860 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 861 | var MgcpCallId call_id := '1232'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 862 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("527"); |
| 863 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 864 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 865 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 866 | cmd := ts_CRCX(get_next_trans_id(), ep, "sendrecv", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 867 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 868 | setverdict(pass); |
| 869 | } |
| 870 | |
| 871 | /* test CRCX with unsupported Parameters */ |
| 872 | testcase TC_crcx_unsupp_param() runs on dummy_CT { |
| 873 | var template MgcpCommand cmd; |
| 874 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 875 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 876 | var MgcpCallId call_id := '1231'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 877 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("539"); |
| 878 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 879 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 880 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 881 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 882 | /* osmo-bsc_mgcp/mgw doesn't implement notifications */ |
| 883 | f_mgcp_par_append(cmd.params, MgcpParameter:{ "N", "foobar" }); |
| 884 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 885 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 886 | setverdict(pass); |
| 887 | } |
| 888 | |
| 889 | /* test CRCX with missing CallId */ |
| 890 | testcase TC_crcx_missing_callid() runs on dummy_CT { |
| 891 | var template MgcpCommand cmd; |
| 892 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 893 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | f91edf3 | 2017-12-28 14:16:21 +0100 | [diff] [blame] | 894 | var template MgcpResponse rtmpl := tr_MgcpResp_Err(("400","516")); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 895 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 896 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 897 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 898 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", '1230'H); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 899 | cmd.params := { |
| 900 | t_MgcpParConnMode("recvonly"), |
| 901 | t_MgcpParLocConnOpt("p:20") |
| 902 | } |
| 903 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 904 | setverdict(pass); |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 905 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | /* test CRCX with missing Mode */ |
| 909 | testcase TC_crcx_missing_mode() runs on dummy_CT { |
| 910 | var template MgcpCommand cmd; |
| 911 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 912 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 913 | var MgcpCallId call_id := '1229'H; |
Harald Welte | f91edf3 | 2017-12-28 14:16:21 +0100 | [diff] [blame] | 914 | var template MgcpResponse rtmpl := tr_MgcpResp_Err(("400","517")); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 915 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 916 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 917 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 918 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 919 | cmd.params := { |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 920 | ts_MgcpParCallId(call_id), |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 921 | t_MgcpParLocConnOpt("p:20") |
| 922 | } |
| 923 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 924 | setverdict(pass); |
| 925 | } |
| 926 | |
| 927 | /* test CRCX with unsupported packetization interval */ |
| 928 | testcase TC_crcx_unsupp_packet_intv() runs on dummy_CT { |
| 929 | var template MgcpCommand cmd; |
| 930 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 931 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 932 | var MgcpCallId call_id := '1228'H; |
Harald Welte | 0d19861 | 2017-11-18 19:58:31 +0100 | [diff] [blame] | 933 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("535"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 934 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 935 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 936 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 937 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 938 | cmd.params[2] := t_MgcpParLocConnOpt("p:111"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 939 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 940 | setverdict(pass); |
| 941 | } |
| 942 | |
| 943 | /* test CRCX with illegal double presence of local connection option */ |
| 944 | testcase TC_crcx_illegal_double_lco() runs on dummy_CT { |
| 945 | var template MgcpCommand cmd; |
| 946 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 947 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 948 | var MgcpCallId call_id := '1227'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 949 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("524"); |
| 950 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 951 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 952 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 953 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | a01e38d | 2017-11-18 18:40:01 +0100 | [diff] [blame] | 954 | /* p:20 is permitted only once and not twice! */ |
| 955 | cmd.params[2] := t_MgcpParLocConnOpt("p:20, a:AMR, p:20"); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 956 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 957 | setverdict(pass); |
| 958 | } |
| 959 | |
| 960 | /* test valid CRCX with valid SDP */ |
| 961 | testcase TC_crcx_sdp() runs on dummy_CT { |
| 962 | var template MgcpCommand cmd; |
| 963 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 964 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 965 | var MgcpCallId call_id := '1226'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 966 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 967 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 968 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 969 | cmd := ts_CRCX(get_next_trans_id(), ep, "sendrecv", call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 970 | cmd.sdp := ts_SDP("127.0.0.1", "127.0.0.2", "23", "42", 2344, { "98" }, |
| 971 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 972 | valueof(ts_SDP_ptime(20)) }); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 973 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Philipp Maier | dffa6a4 | 2018-02-02 11:55:44 +0100 | [diff] [blame] | 974 | |
| 975 | /* clean-up */ |
| 976 | f_dlcx_ok(ep, call_id); |
| 977 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 978 | setverdict(pass); |
| 979 | } |
| 980 | |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 981 | /* test valid wildcarded CRCX */ |
| 982 | testcase TC_crcx_wildcarded() runs on dummy_CT { |
| 983 | var template MgcpCommand cmd; |
| 984 | var MgcpResponse resp; |
| 985 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; |
| 986 | var MgcpCallId call_id := '1234'H; |
| 987 | var MgcpEndpoint ep_assigned; |
| 988 | f_init(); |
| 989 | |
| 990 | /* create the connection on the MGW */ |
| 991 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 992 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 993 | extract_conn_id(resp); |
| 994 | |
| 995 | /* extract endpoint name we got assigned by the MGW */ |
| 996 | var MgcpMessage resp_msg := { |
| 997 | response := resp |
| 998 | } |
| 999 | if (f_mgcp_find_param(resp_msg, "Z", ep_assigned) == false) { |
| 1000 | setverdict(fail, "No SpecificEndpointName in MGCP response", resp); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1001 | mtc.stop; |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | /* clean-up */ |
| 1005 | f_dlcx_ok(ep_assigned, call_id); |
| 1006 | |
| 1007 | setverdict(pass); |
| 1008 | } |
| 1009 | |
| 1010 | /* test valid wildcarded CRCX */ |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1011 | type record of MgcpEndpoint MgcpEndpointList; |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1012 | testcase TC_crcx_wildcarded_exhaust() runs on dummy_CT { |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1013 | var integer i; |
| 1014 | var template MgcpCommand cmd; |
| 1015 | var MgcpResponse resp; |
| 1016 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; |
| 1017 | var MgcpCallId call_id := '1234'H; |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1018 | var MgcpEndpoint ep_assigned; |
| 1019 | var MgcpEndpointList ep_assigned_li := {}; |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1020 | f_init(); |
| 1021 | |
| 1022 | /* Exhaust all endpoint resources on the virtual trunk */ |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1023 | for (i := 0; i < mp_num_endpoints; i := i+1) { |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1024 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1025 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1026 | |
| 1027 | /* Make sure we got a connection id */ |
| 1028 | extract_conn_id(resp); |
| 1029 | |
| 1030 | var MgcpMessage resp_msg := { |
| 1031 | response := resp |
| 1032 | } |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1033 | if (f_mgcp_find_param(resp_msg, "Z", ep_assigned) == false) { |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1034 | setverdict(fail, "No SpecificEndpointName in MGCP response", resp); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1035 | mtc.stop; |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1036 | } |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1037 | ep_assigned_li := ep_assigned_li & {ep_assigned} |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | /* Try to allocate one more endpoint, which should fail */ |
| 1041 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1042 | var template MgcpResponse rtmpl := tr_MgcpResp_Err("403"); |
| 1043 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1044 | setverdict(pass); |
| 1045 | |
| 1046 | /* clean-up */ |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1047 | for (i := 0; i < mp_num_endpoints; i := i+1) { |
| 1048 | f_dlcx_ok(ep_assigned_li[i], call_id); |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 1049 | } |
| 1050 | setverdict(pass); |
| 1051 | } |
| 1052 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1053 | /* TODO: various SDP related bits */ |
| 1054 | |
| 1055 | |
| 1056 | /* TODO: CRCX with X-Osmux */ |
| 1057 | /* TODO: double CRCX without force_realloc */ |
| 1058 | |
| 1059 | /* TODO: MDCX (various) */ |
| 1060 | |
| 1061 | /* TODO: MDCX without CRCX first */ |
| 1062 | testcase TC_mdcx_without_crcx() runs on dummy_CT { |
| 1063 | var template MgcpCommand cmd; |
| 1064 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1065 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "3@" & c_mgw_domain; |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 1066 | var MgcpCallId call_id := '1225'H; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1067 | var template MgcpResponse rtmpl := { |
| 1068 | line := { |
| 1069 | /* TODO: accept/enforce better error? */ |
| 1070 | code := "400", |
| 1071 | string := ? |
| 1072 | }, |
| 1073 | params:= { }, |
| 1074 | sdp := omit |
| 1075 | }; |
| 1076 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 1077 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1078 | |
Harald Welte | 2bcfd3a | 2017-11-18 22:14:35 +0100 | [diff] [blame] | 1079 | cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, call_id); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1080 | cmd.sdp := ts_SDP("127.0.0.1", "127.0.0.2", "23", "42", 2344, { "98" }, |
| 1081 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 1082 | valueof(ts_SDP_ptime(20)) }); |
| 1083 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1084 | setverdict(pass); |
| 1085 | } |
| 1086 | |
| 1087 | /* DLCX without CRCX first */ |
| 1088 | testcase TC_dlcx_without_crcx() runs on dummy_CT { |
| 1089 | var template MgcpCommand cmd; |
| 1090 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1091 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "4@" & c_mgw_domain; |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1092 | var template MgcpResponse rtmpl := { |
| 1093 | line := { |
Harald Welte | f91edf3 | 2017-12-28 14:16:21 +0100 | [diff] [blame] | 1094 | code := ("400", "515"), |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1095 | string := ? |
| 1096 | }, |
| 1097 | params:= { }, |
| 1098 | sdp := omit |
| 1099 | }; |
| 1100 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 1101 | f_init(ep); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1102 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 1103 | cmd := ts_DLCX(get_next_trans_id(), ep, '41234'H); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1104 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1105 | setverdict(pass); |
| 1106 | } |
| 1107 | |
Philipp Maier | 21c1cff | 2021-07-20 14:22:53 +0200 | [diff] [blame] | 1108 | /* DLCX to non existing endpoint */ |
| 1109 | testcase TC_dlcx_non_existant_ep() runs on dummy_CT { |
| 1110 | var template MgcpCommand cmd; |
| 1111 | var MgcpResponse resp; |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1112 | var charstring non_existant_ep := hex2str(int2hex(mp_num_endpoints + 1, 4)) |
| 1113 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & non_existant_ep & "@" & c_mgw_domain; |
Philipp Maier | 21c1cff | 2021-07-20 14:22:53 +0200 | [diff] [blame] | 1114 | var template MgcpResponse rtmpl := { |
| 1115 | line := { |
| 1116 | code := ("500"), |
| 1117 | string := ? |
| 1118 | }, |
| 1119 | params:= { }, |
| 1120 | sdp := omit |
| 1121 | }; |
| 1122 | |
| 1123 | f_init(ep); |
| 1124 | |
| 1125 | cmd := ts_DLCX(get_next_trans_id(), ep, '41234'H); |
| 1126 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1127 | setverdict(pass); |
| 1128 | } |
| 1129 | |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1130 | /* test valid wildcarded MDCX */ |
| 1131 | testcase TC_mdcx_wildcarded() runs on dummy_CT { |
| 1132 | /* Note: A wildcarded MDCX is not allowed, so we expect the |
| 1133 | * MGW to reject this request */ |
| 1134 | var template MgcpCommand cmd; |
| 1135 | var MgcpResponse resp; |
| 1136 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; |
| 1137 | var MgcpCallId call_id := '1225'H; |
| 1138 | var template MgcpResponse rtmpl := { |
| 1139 | line := { |
| 1140 | /* TODO: accept/enforce better error? */ |
| 1141 | code := "507", |
| 1142 | string := ? |
| 1143 | }, |
| 1144 | params:= { }, |
| 1145 | sdp := omit |
| 1146 | }; |
| 1147 | |
| 1148 | f_init(ep); |
| 1149 | |
| 1150 | cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, call_id); |
| 1151 | cmd.sdp := ts_SDP("127.0.0.1", "127.0.0.2", "23", "42", 2344, { "98" }, |
| 1152 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 1153 | valueof(ts_SDP_ptime(20)) }); |
| 1154 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1155 | setverdict(pass); |
| 1156 | } |
| 1157 | |
| 1158 | /* test valid wildcarded DLCX */ |
| 1159 | testcase TC_dlcx_wildcarded() runs on dummy_CT { |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1160 | var template MgcpCommand cmd; |
| 1161 | var MgcpResponse resp; |
| 1162 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1163 | var integer i; |
| 1164 | var MgcpCallId call_id := '1234'H; |
| 1165 | var StatsDExpects expect; |
| 1166 | f_init(ep); |
| 1167 | |
| 1168 | /* Allocate a few endpoints */ |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1169 | for (i := 0; i < mp_num_endpoints; i := i+1) { |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1170 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1171 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1172 | } |
| 1173 | |
Philipp Maier | 1298b09 | 2021-11-18 18:33:39 +0100 | [diff] [blame] | 1174 | /* Wait until the stats items have seteled and then check if we get the expected number (all) of |
| 1175 | * occupied endpoints */ |
| 1176 | f_sleep(1.0) |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1177 | expect := { |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1178 | { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := mp_num_endpoints, max := mp_num_endpoints} |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1179 | }; |
| 1180 | f_statsd_expect(expect); |
| 1181 | |
| 1182 | /* Send wildcarded DLCX */ |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1183 | var template MgcpResponse rtmpl := { |
| 1184 | line := { |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1185 | code := "200", |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1186 | string := ? |
| 1187 | }, |
| 1188 | params:= { }, |
| 1189 | sdp := omit |
| 1190 | }; |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1191 | cmd := ts_DLCX(get_next_trans_id(), ep); |
| 1192 | mgcp_transceive_mgw(cmd, rtmpl); |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1193 | |
Philipp Maier | 6c740e8 | 2022-06-30 12:04:34 +0200 | [diff] [blame] | 1194 | /* Query a the statsd once to ensure that intermediate results are pulled from the |
| 1195 | * pipeline. The second query (below) will return the actual result. */ |
| 1196 | expect := { |
Pau Espin Pedrol | e792887 | 2022-10-07 10:57:11 +0200 | [diff] [blame] | 1197 | { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := 0, max := mp_num_endpoints} |
Philipp Maier | 6c740e8 | 2022-06-30 12:04:34 +0200 | [diff] [blame] | 1198 | }; |
| 1199 | f_statsd_expect(expect); |
| 1200 | |
| 1201 | /* The second query must resturn a result with 0 endpoints in use. */ |
Philipp Maier | 55b9054 | 2021-07-02 12:33:19 +0200 | [diff] [blame] | 1202 | expect := { |
| 1203 | { name := "TTCN3.trunk.virtual-0.common.endpoints.used", mtype := "g", min := 0, max := 0} |
| 1204 | }; |
| 1205 | f_statsd_expect(expect); |
| 1206 | |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 1207 | setverdict(pass); |
| 1208 | } |
| 1209 | |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 1210 | /* Test (valid) CRCX followed by (valid) DLCX containig EP+CallId+ConnId */ |
| 1211 | testcase TC_crcx_and_dlcx_ep_callid_connid() runs on dummy_CT { |
| 1212 | var template MgcpCommand cmd; |
| 1213 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1214 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 1215 | var MgcpCallId call_id := '51234'H; |
| 1216 | |
| 1217 | f_init(ep); |
| 1218 | |
| 1219 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1220 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1221 | |
| 1222 | f_dlcx_ok(ep, call_id, extract_conn_id(resp)); |
| 1223 | |
| 1224 | setverdict(pass); |
| 1225 | } |
| 1226 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1227 | /* test valid CRCX without SDP */ |
| 1228 | testcase TC_crcx_osmux_wildcard() runs on dummy_CT { |
| 1229 | f_crcx_osmux(c_mgw_ep_rtpbridge, -1); |
| 1230 | setverdict(pass); |
| 1231 | } |
| 1232 | |
| 1233 | /* test valid CRCX without SDP */ |
| 1234 | testcase TC_crcx_osmux_fixed() runs on dummy_CT { |
| 1235 | f_crcx_osmux(c_mgw_ep_rtpbridge, 2); |
| 1236 | setverdict(pass); |
| 1237 | } |
| 1238 | |
| 1239 | /* test valid CRCX without SDP, twice, to make sure CID is freed fine during first step. */ |
| 1240 | testcase TC_crcx_osmux_fixed_twice() runs on dummy_CT { |
| 1241 | f_crcx_osmux(c_mgw_ep_rtpbridge, 3, true); |
| 1242 | f_crcx_osmux(c_mgw_ep_rtpbridge, 3, false); |
| 1243 | setverdict(pass); |
| 1244 | } |
| 1245 | |
Pau Espin Pedrol | 787e2e4 | 2022-10-07 10:58:35 +0200 | [diff] [blame] | 1246 | /* test Creating 257 concurrent osmux conns. It should fail since maximum is 256. */ |
| 1247 | testcase TC_crcx_osmux_257() runs on dummy_CT { |
| 1248 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "*@" & c_mgw_domain; |
| 1249 | var template MgcpCommand cmd; |
| 1250 | var MgcpResponse resp; |
| 1251 | var charstring cid_response; |
| 1252 | var integer i; |
| 1253 | |
| 1254 | f_init(ep, true); |
| 1255 | |
| 1256 | for (i := 0; i < 256; i := i + 1) { |
| 1257 | |
| 1258 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, "recvonly", int2hex(i, 4), -1); |
| 1259 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK_osmux); |
| 1260 | extract_conn_id(resp); |
| 1261 | |
| 1262 | /* extract Osmux CID we got assigned by the MGW */ |
| 1263 | var MgcpMessage resp_msg := { |
| 1264 | response := resp |
| 1265 | } |
| 1266 | |
| 1267 | if (f_mgcp_find_param(resp_msg, "X-OSMUX", cid_response) == false) { |
| 1268 | setverdict(fail, "No Osmux CID in MGCP response", resp); |
| 1269 | mtc.stop; |
| 1270 | } |
| 1271 | |
| 1272 | /* Make sure response is no wildcard */ |
| 1273 | if (f_mgcp_osmux_cid_decode(cid_response) == -1) { |
| 1274 | setverdict(fail, "Osmux CID in MGCP response contains unexpected wildcard"); |
| 1275 | mtc.stop; |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | /* Now conn num 257, it should fail due to all Osmux conns already allocated: */ |
| 1280 | cmd := ts_CRCX_osmux(get_next_trans_id(), ep, "recvonly", int2hex(i, 4), -1); |
| 1281 | resp := mgcp_transceive_mgw(cmd, tr_MgcpResp_Err("400")); |
| 1282 | |
| 1283 | setverdict(pass); |
| 1284 | |
| 1285 | /* Clean up */ |
| 1286 | for (i := 0; i < 256; i := i + 1) { |
| 1287 | f_dlcx_ok(ep, int2hex(i, 4)); |
| 1288 | } |
| 1289 | } |
| 1290 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1291 | /* Create one half open connection in receive-only mode. The MGW must accept |
| 1292 | * the packets but must not send any. */ |
| 1293 | testcase TC_one_crcx_receive_only_osmux() runs on dummy_CT { |
| 1294 | var RtpFlowData flow; |
| 1295 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; |
| 1296 | var MgcpCallId call_id := '1225'H; |
| 1297 | var OsmuxemStats stats; |
| 1298 | var OsmuxTxHandle tx_hdl; |
| 1299 | |
| 1300 | f_init(ep, true); |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 1301 | flow := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 112, "AMR/8000/1")); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1302 | flow.em.portnr := mp_local_osmux_port; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1303 | flow.osmux.local_cid := -1; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1304 | f_flow_create_osmux(OsmuxEM, ep, call_id, "recvonly", flow, false); |
| 1305 | |
| 1306 | /* create a transmitter not yet known by MGW */ |
| 1307 | tx_hdl := valueof(t_TxHandleAMR590(2)); |
| 1308 | f_osmuxem_register_txhandle(OsmuxEM, tx_hdl); |
| 1309 | |
| 1310 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_TXONLY); |
| 1311 | f_sleep(1.0); |
| 1312 | f_flow_delete_osmux(OsmuxEM, ep, call_id); |
| 1313 | |
| 1314 | stats := f_osmuxem_stats_get(OsmuxEM); |
| 1315 | |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1316 | if (stats.num_pkts_tx < 40 / flow.osmux.cfg.batch_size) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1317 | setverdict(fail); |
| 1318 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1319 | if (stats.bytes_payload_tx < stats.num_pkts_tx * f_amrft_payload_len(tx_hdl.amr_ft) * flow.osmux.cfg.batch_size) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1320 | setverdict(fail); |
| 1321 | } |
| 1322 | |
| 1323 | f_osmuxem_stats_err_check(stats); |
| 1324 | |
| 1325 | setverdict(pass); |
| 1326 | } |
| 1327 | |
| 1328 | /* Create one connection in loopback mode, test if the Osmux packets are |
| 1329 | * actually reflected */ |
| 1330 | testcase TC_one_crcx_loopback_osmux() runs on dummy_CT { |
| 1331 | var RtpFlowData flow; |
| 1332 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; |
| 1333 | var MgcpCallId call_id := '1225'H; |
| 1334 | var OsmuxemStats stats; |
| 1335 | var OsmuxTxHandle tx_hdl; |
| 1336 | |
| 1337 | f_init(ep, true); |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 1338 | flow := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 111, "GSM-HR-08/8000/1")); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1339 | flow.em.portnr := mp_local_osmux_port; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1340 | flow.osmux.local_cid := 2; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1341 | f_flow_create_osmux(OsmuxEM, ep, call_id, "loopback", flow); |
| 1342 | |
| 1343 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_BIDIR); |
| 1344 | f_sleep(1.0); |
| 1345 | |
| 1346 | /* Switch off both Tx, wait to receive delayed frames from MGW */ |
| 1347 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_RXONLY); |
| 1348 | f_sleep(0.1); |
| 1349 | f_flow_delete_osmux(OsmuxEM, ep, call_id); |
| 1350 | |
| 1351 | stats := f_osmuxem_stats_get(OsmuxEM); |
| 1352 | |
| 1353 | if (stats.num_pkts_tx != stats.num_pkts_rx) { |
| 1354 | setverdict(fail); |
| 1355 | } |
| 1356 | if (stats.bytes_payload_tx != stats.bytes_payload_rx) { |
| 1357 | setverdict(fail); |
| 1358 | } |
| 1359 | |
| 1360 | f_osmuxem_stats_err_check(stats); |
| 1361 | |
| 1362 | setverdict(pass); |
| 1363 | } |
| 1364 | |
| 1365 | /* Cross-compare two osmuxem-statistics. The transmission statistics on the a side |
| 1366 | * must match the reception statistics on the other side and vice versa. The |
| 1367 | * user may also supply a tolerance value (number of packets) when deviations |
| 1368 | * are acceptable */ |
| 1369 | function f_rtp_osmux_stats_compare(RtpemStats a, OsmuxemStats b, integer batch_size, integer tolerance := 0) return boolean { |
| 1370 | var integer plen; |
| 1371 | |
| 1372 | log("stats A: ", a); |
| 1373 | log("stats B: ", b); |
| 1374 | log("tolerance: ", tolerance, " packets"); |
| 1375 | log("batch_size: ", batch_size, " packets"); |
| 1376 | |
| 1377 | var integer tolerance_batch := tolerance + (batch_size - tolerance mod batch_size); |
| 1378 | |
| 1379 | if (f_osmuxem_stats_compare_value(a.num_pkts_tx, b.num_pkts_rx * batch_size, tolerance_batch) == false) { |
| 1380 | return false; |
| 1381 | } |
| 1382 | |
| 1383 | if (f_osmuxem_stats_compare_value(a.num_pkts_rx / batch_size, b.num_pkts_tx, tolerance_batch) == false) { |
| 1384 | return false; |
| 1385 | } |
| 1386 | |
| 1387 | if(a.num_pkts_tx > 0) { |
| 1388 | plen := a.bytes_payload_tx / a.num_pkts_tx; |
| 1389 | } else { |
| 1390 | plen := 0; |
| 1391 | } |
| 1392 | |
| 1393 | /* Each RTP pcket payload contains 2 extra bytes due to AMR ToC at start */ |
| 1394 | if (f_osmuxem_stats_compare_value(a.bytes_payload_tx, b.bytes_payload_rx + a.num_pkts_tx * 2, tolerance_batch * plen) == false) { |
| 1395 | log("incorrect payload A->B: " , a.bytes_payload_tx, " vs ", b.bytes_payload_rx + a.num_pkts_rx * 2); |
| 1396 | return false; |
| 1397 | } |
| 1398 | |
| 1399 | if (f_osmuxem_stats_compare_value(a.bytes_payload_rx, b.bytes_payload_tx + b.num_pkts_tx * 2 * batch_size, tolerance_batch * plen) == false) { |
| 1400 | log("incorrect payload B->A: " , b.bytes_payload_tx + b.num_pkts_tx * 2 * batch_size, " vs ", a.bytes_payload_rx); |
| 1401 | return false; |
| 1402 | } |
| 1403 | |
| 1404 | return true; |
| 1405 | } |
| 1406 | |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1407 | function f_TC_two_crcx_and_rtp_osmux(boolean bidir, boolean rtp_amr_oa, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1408 | charstring local_ip_rtp, charstring remote_ip_rtp, |
| 1409 | charstring local_ip_osmux, charstring remote_ip_osmux) runs on dummy_CT { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1410 | var RtpFlowData flow[2]; |
| 1411 | var RtpemStats stats_rtp; |
| 1412 | var OsmuxemStats stats_osmux; |
| 1413 | var MgcpResponse resp; |
| 1414 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 1415 | var MgcpCallId call_id := '1226'H; |
| 1416 | var integer tolerance := 0; |
| 1417 | |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1418 | var octetstring amr_payload; |
| 1419 | var charstring fmtp; |
| 1420 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1421 | f_init(ep, true); |
| 1422 | |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1423 | var AMRFT cmr := AMR_FT_0; |
| 1424 | var AMRFT ft := AMR_FT_2; |
| 1425 | if (rtp_amr_oa) { |
| 1426 | fmtp := "octet-align=1"; |
| 1427 | var RTP_AMR_Hdr amr_oa_hdr := valueof(ts_RTP_AMR_Hdr(enum2int(cmr), enum2int(ft))); |
| 1428 | amr_payload := enc_RTP_AMR_Hdr(amr_oa_hdr) & |
| 1429 | f_osmux_gen_expected_rx_rtp_payload(enum2int(ft), c_OsmuxemDefaultCfg.tx_fixed_payload); |
| 1430 | } else { |
| 1431 | fmtp := "octet-align=0"; |
| 1432 | /* Convert OA to BWE: */ |
| 1433 | var RTP_AMR_BWE_Hdr amr_bwe_hdr := valueof(ts_RTP_AMR_BWE_Hdr(enum2int(cmr), enum2int(ft))); |
| 1434 | var bitstring amr_bwe_hdr_bits := substr(oct2bit(enc_RTP_AMR_BWE_Hdr(amr_bwe_hdr)), 0 , 10); |
| 1435 | var bitstring amr_data_bits := oct2bit(f_osmux_gen_expected_rx_rtp_payload(enum2int(ft), c_OsmuxemDefaultCfg.tx_fixed_payload)); |
| 1436 | var bitstring amr_payload_bits := amr_bwe_hdr_bits & substr(amr_data_bits, 0, f_amrft_payload_bits_len(enum2int(ft))); |
| 1437 | amr_payload := bit2oct(f_pad_bit(amr_payload_bits, (lengthof(amr_payload_bits)+7)/8*8, '0'B)); |
| 1438 | }; |
| 1439 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1440 | /* from us to MGW */ |
Philipp Maier | 6b41e15 | 2023-03-31 11:45:24 +0200 | [diff] [blame] | 1441 | flow[0] := valueof(t_RtpFlow(local_ip_rtp, remote_ip_rtp, 112, "AMR/8000", fmtp)); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1442 | flow[0].rtp_cfg := c_RtpemDefaultCfg |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 1443 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 1444 | flow[0].rtp_cfg.rx_payloads[0].fixed_payload := amr_payload; |
| 1445 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 1446 | flow[0].rtp_cfg.tx_payloads[0].fixed_payload := amr_payload; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1447 | /* bind local RTP emulation sockets */ |
| 1448 | flow[0].em.portnr := 10000; |
| 1449 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 1450 | |
| 1451 | /* from MGW back to us */ |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1452 | flow[1] := valueof(t_RtpFlow(local_ip_osmux, remote_ip_osmux, 110, "AMR/8000")); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1453 | flow[1].em.portnr := mp_local_osmux_port; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1454 | flow[1].osmux.local_cid := 2; |
| 1455 | flow[1].osmux.cfg := c_OsmuxemDefaultCfg; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1456 | f_flow_create_osmux(OsmuxEM, ep, call_id, "sendrecv", flow[1]); |
| 1457 | |
| 1458 | if (bidir) { |
| 1459 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 1460 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_BIDIR); |
| 1461 | |
| 1462 | /* Note: When we test bidirectional we may |
| 1463 | * loose packets during switch off because |
| 1464 | * both ends are transmitting and we only |
| 1465 | * can switch them off one by one. */ |
| 1466 | tolerance := 3; |
| 1467 | } else { |
| 1468 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 1469 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_TXONLY); |
| 1470 | } |
| 1471 | |
| 1472 | f_sleep(1.0); |
| 1473 | |
| 1474 | /* Switch off both Tx, wait to receive delayed frames from MGW */ |
| 1475 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 1476 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_RXONLY); |
| 1477 | f_sleep(0.1); |
| 1478 | |
| 1479 | f_flow_delete_osmux(OsmuxEM, ep, call_id); |
| 1480 | f_flow_delete(RTPEM[1]); |
| 1481 | |
| 1482 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1483 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1484 | if (not f_rtp_osmux_stats_compare(stats_rtp, stats_osmux, flow[1].osmux.cfg.batch_size, tolerance)) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1485 | setverdict(fail, "RTP and Osmux endpoint statistics don't match"); |
| 1486 | mtc.stop; |
| 1487 | } |
| 1488 | |
| 1489 | f_rtpem_stats_err_check(stats_rtp); |
| 1490 | f_osmuxem_stats_err_check(stats_osmux); |
| 1491 | |
| 1492 | setverdict(pass); |
| 1493 | } |
| 1494 | |
| 1495 | /* create one RTP and one OSmux emulations; create two connections on MGW EP, exchange some data */ |
| 1496 | testcase TC_two_crcx_and_rtp_osmux() runs on dummy_CT { |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1497 | f_TC_two_crcx_and_rtp_osmux(false, true, mp_local_ipv4, mp_remote_ipv4, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1498 | mp_local_ipv4, mp_remote_ipv4); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | /* create one RTP and one OSmux emulations; create two connections on MGW EP, |
| 1502 | * exchange some data in both directions */ |
| 1503 | testcase TC_two_crcx_and_rtp_osmux_bidir() runs on dummy_CT { |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1504 | f_TC_two_crcx_and_rtp_osmux(true, true, mp_local_ipv4, mp_remote_ipv4, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1505 | mp_local_ipv4, mp_remote_ipv4); |
| 1506 | } |
| 1507 | |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1508 | /* create one RTP and one OSmux emulations; create two connections on MGW EP, |
| 1509 | * exchange some data in both directions. RTP side is configured to |
| 1510 | * rx/rx AMR in bandwidth-efficient mode. */ |
| 1511 | testcase TC_two_crcx_and_rtp_osmux_bidir_amr_bwe() runs on dummy_CT { |
| 1512 | f_TC_two_crcx_and_rtp_osmux(true, false, mp_local_ipv4, mp_remote_ipv4, |
| 1513 | mp_local_ipv4, mp_remote_ipv4); |
| 1514 | } |
| 1515 | |
| 1516 | |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1517 | /* Same as TC_two_crcx_and_rtp_osmux_bidir, but using IPv6 */ |
| 1518 | testcase TC_two_crcx_and_rtp_osmux_bidir_ipv6() runs on dummy_CT { |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1519 | f_TC_two_crcx_and_rtp_osmux(true, true, mp_local_ipv6, mp_remote_ipv6, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1520 | mp_local_ipv6, mp_remote_ipv6); |
| 1521 | } |
| 1522 | /* Same as TC_two_crcx_and_rtp_osmux_bidir, but using IPv4 (RTP) and IPv6 (Osmux) */ |
| 1523 | testcase TC_two_crcx_and_rtp_osmux_bidir_ipv4_ipv6() runs on dummy_CT { |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1524 | f_TC_two_crcx_and_rtp_osmux(true, true, mp_local_ipv4, mp_remote_ipv4, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1525 | mp_local_ipv6, mp_remote_ipv6); |
| 1526 | } |
| 1527 | /* Same as TC_two_crcx_and_rtp_osmux_bidir, but using IPv6 (RTP) and IPv4 (Osmux) */ |
| 1528 | testcase TC_two_crcx_and_rtp_osmux_bidir_ipv6_ipv4() runs on dummy_CT { |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 1529 | f_TC_two_crcx_and_rtp_osmux(true, true, mp_local_ipv6, mp_remote_ipv6, |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1530 | mp_local_ipv4, mp_remote_ipv4); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1531 | } |
| 1532 | |
| 1533 | |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1534 | function f_two_crcx_mdcx_and_rtp_osmux(boolean crcx_osmux_wildcard, |
| 1535 | charstring local_ip_rtp, charstring remote_ip_rtp, |
| 1536 | charstring local_ip_osmux, charstring remote_ip_osmux) runs on dummy_CT { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1537 | var RtpFlowData flow[2]; |
| 1538 | var RtpemStats stats_rtp; |
| 1539 | var OsmuxemStats stats_osmux; |
| 1540 | var MgcpResponse resp; |
| 1541 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 1542 | var MgcpCallId call_id := '1227'H; |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1543 | var integer num_pkts_tx[2], num_pkts_rx[2]; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1544 | var integer temp; |
| 1545 | |
| 1546 | f_init(ep, true); |
| 1547 | |
| 1548 | /* Create the first connection in receive only mode */ |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1549 | flow[0] := valueof(t_RtpFlow(local_ip_rtp, remote_ip_rtp, 112, "AMR/8000")); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1550 | flow[0].rtp_cfg := c_RtpemDefaultCfg |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 1551 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 1552 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1553 | /* 0014 is the ToC (CMR=AMR4.75) in front of AMR Payload in RTP Payload */ |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 1554 | flow[0].rtp_cfg.rx_payloads[0].fixed_payload := '0014'O & f_osmux_gen_expected_rx_rtp_payload(2 /* AMR_FT_2, 5.90 */, c_OsmuxemDefaultCfg.tx_fixed_payload); |
| 1555 | flow[0].rtp_cfg.tx_payloads[0].fixed_payload := flow[0].rtp_cfg.rx_payloads[0].fixed_payload; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1556 | /* bind local RTP emulation sockets */ |
| 1557 | flow[0].em.portnr := 10000; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1558 | f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow[0], true); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1559 | |
| 1560 | |
| 1561 | /* Create the second connection. This connection will be also |
| 1562 | * in receive only mode */ |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1563 | flow[1] := valueof(t_RtpFlow(local_ip_osmux, remote_ip_osmux, 110, "AMR/8000")); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1564 | flow[1].em.portnr := mp_local_osmux_port; |
| 1565 | if (crcx_osmux_wildcard) { |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1566 | flow[1].osmux.local_cid := -1; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1567 | } else { |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1568 | flow[1].osmux.local_cid := 2; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1569 | } |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1570 | flow[1].osmux.cfg := c_OsmuxemDefaultCfg; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1571 | f_flow_create_osmux(OsmuxEM, ep, call_id, "recvonly", flow[1], true); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1572 | |
| 1573 | |
| 1574 | /* The first leg starts transmitting */ |
| 1575 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 1576 | f_sleep(0.5); |
| 1577 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1578 | if (stats_rtp.num_pkts_rx_err_disabled != 0) { |
| 1579 | setverdict(fail, "received packets from RTP MGW on recvonly connection"); |
| 1580 | mtc.stop; |
| 1581 | } |
| 1582 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
| 1583 | if (stats_osmux.num_pkts_rx_err_disabled != 0) { |
| 1584 | setverdict(fail, "received packets from Osmux MGW on recvonly connection"); |
| 1585 | mtc.stop; |
| 1586 | } |
| 1587 | |
| 1588 | /* The second leg starts transmitting a little later */ |
| 1589 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_TXONLY); |
| 1590 | f_sleep(1.0); |
| 1591 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1592 | if (stats_rtp.num_pkts_rx_err_disabled != 0) { |
| 1593 | setverdict(fail, "received packets from RTP MGW on recvonly connection"); |
| 1594 | mtc.stop; |
| 1595 | } |
| 1596 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
| 1597 | if (stats_osmux.num_pkts_rx_err_disabled != 0) { |
| 1598 | setverdict(fail, "received packets from Osmux MGW on recvonly connection"); |
| 1599 | mtc.stop; |
| 1600 | } |
| 1601 | |
| 1602 | /* The first leg will now be switched into bidirectional |
| 1603 | * mode, but we do not expect any data comming back yet. */ |
Pau Espin Pedrol | e67b1c6 | 2020-09-08 12:16:17 +0200 | [diff] [blame] | 1604 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1605 | f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1606 | /* At this point in time, flow[1](Osmux)->MGW->flow[0](RTP) is active, |
| 1607 | * hence if local CID was provided during CRCX we should already be seeing packets |
| 1608 | * flowing in one direction, aka stats_rtp.num_pkts_rx sould be >0 after a while: */ |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1609 | f_sleep(0.5); |
| 1610 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1611 | if (stats_rtp.num_pkts_rx_err_disabled != 0) { |
| 1612 | setverdict(fail, "received packets from RTP MGW on recvonly connection"); |
| 1613 | mtc.stop; |
| 1614 | } |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1615 | if (not crcx_osmux_wildcard and stats_rtp.num_pkts_rx == 0) { |
| 1616 | setverdict(fail, "received 0 packets Osmux->MGW->RTP"); |
| 1617 | mtc.stop; |
| 1618 | } |
| 1619 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1620 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
| 1621 | if (stats_osmux.num_pkts_rx_err_disabled != 0) { |
| 1622 | setverdict(fail, "received packets from Osmux MGW on recvonly connection"); |
| 1623 | mtc.stop; |
| 1624 | } |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1625 | if (stats_osmux.num_pkts_rx > 0) { |
| 1626 | setverdict(fail, "received unexpected ", stats_osmux.num_pkts_rx, " packets RTP->MGW->Osmux"); |
| 1627 | mtc.stop; |
| 1628 | } |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1629 | |
| 1630 | /* When the second leg is switched into bidirectional mode |
| 1631 | * as well, then the MGW will connect the two together and |
| 1632 | * we should see RTP streams passing through from both ends. */ |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1633 | f_osmuxem_mode(OsmuxEM, OSMUXEM_MODE_BIDIR); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1634 | if (crcx_osmux_wildcard) { |
Pau Espin Pedrol | 982b979 | 2022-10-07 11:48:13 +0200 | [diff] [blame] | 1635 | /* We set now the local CID in MDCX: */ |
| 1636 | flow[1].osmux.local_cid := 2; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1637 | } |
| 1638 | f_flow_modify_osmux(OsmuxEM, ep, call_id, "sendrecv", flow[1]); |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1639 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1640 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
| 1641 | num_pkts_tx[0] := stats_rtp.num_pkts_tx; |
| 1642 | num_pkts_tx[1] := stats_osmux.num_pkts_tx; |
| 1643 | num_pkts_rx[0] := stats_rtp.num_pkts_rx; |
| 1644 | num_pkts_rx[1] := stats_osmux.num_pkts_rx; |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1645 | f_sleep(2.0); |
| 1646 | |
| 1647 | stats_rtp := f_rtpem_stats_get(RTPEM[0]); |
| 1648 | stats_osmux := f_osmuxem_stats_get(OsmuxEM); |
| 1649 | |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1650 | temp := (stats_rtp.num_pkts_tx - num_pkts_tx[0]) - |
| 1651 | (stats_osmux.num_pkts_rx - num_pkts_rx[1]) * flow[1].osmux.cfg.batch_size; |
Pau Espin Pedrol | 779e4a7 | 2022-10-07 12:44:42 +0200 | [diff] [blame] | 1652 | if (temp > 3 * flow[1].osmux.cfg.batch_size or temp < -3 * flow[1].osmux.cfg.batch_size) { |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1653 | log("stats_rtp: ", stats_rtp); |
| 1654 | log("stats_osmux: ", stats_osmux); |
| 1655 | log("old_rtp_tx: ", num_pkts_tx[0]); |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1656 | setverdict(fail, "RTP-Tx vs OSmux-Rx number of packets not within normal parameters (" & int2str(temp) & ")"); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1657 | mtc.stop; |
| 1658 | } |
| 1659 | |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1660 | temp := (stats_osmux.num_pkts_tx - num_pkts_tx[1]) - |
| 1661 | ((stats_rtp.num_pkts_rx - num_pkts_rx[0])/ flow[1].osmux.cfg.batch_size); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1662 | if (temp > 3 or temp < -3) { |
Pau Espin Pedrol | db1e068 | 2022-10-06 19:40:29 +0200 | [diff] [blame] | 1663 | log("stats_rtp: ", stats_rtp); |
| 1664 | log("stats_osmux: ", stats_osmux); |
| 1665 | log("old_osmux_tx: ", num_pkts_tx[1]); |
Pau Espin Pedrol | f369983 | 2022-10-06 19:54:46 +0200 | [diff] [blame] | 1666 | setverdict(fail, "Osmux-Tx vs RTP-Rx number of packets not within normal parameters (" & int2str(temp) & ")"); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1667 | mtc.stop; |
| 1668 | } |
| 1669 | |
| 1670 | f_rtpem_stats_err_check(stats_rtp); |
| 1671 | f_osmuxem_stats_err_check(stats_osmux); |
| 1672 | |
| 1673 | /* Tear down */ |
| 1674 | f_flow_delete(RTPEM[0]); |
| 1675 | f_flow_delete_osmux(OsmuxEM, ep, call_id); |
| 1676 | setverdict(pass); |
| 1677 | } |
| 1678 | |
| 1679 | /* create one RTP and one OSmux emulations and pass data in both |
| 1680 | directions. Create CRCX with wildcard Osmux CID and set it later |
| 1681 | during MDCX. This is similar to how MSC sets up the call in AoIP. */ |
| 1682 | testcase TC_two_crcx_mdcx_and_rtp_osmux_wildcard() runs on dummy_CT { |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1683 | f_two_crcx_mdcx_and_rtp_osmux(true, mp_local_ipv4, mp_remote_ipv4, |
| 1684 | mp_local_ipv4, mp_remote_ipv4); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | /* create one RTP and one OSmux emulations and pass data in both |
| 1688 | directions. Create CRCX with fixed Osmux CID and keep it during |
| 1689 | MDCX. This is similar to how BSC sets up the call in AoIP. */ |
| 1690 | testcase TC_two_crcx_mdcx_and_rtp_osmux_fixed() runs on dummy_CT { |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 1691 | f_two_crcx_mdcx_and_rtp_osmux(false, mp_local_ipv4, mp_remote_ipv4, |
| 1692 | mp_local_ipv4, mp_remote_ipv4); |
| 1693 | } |
| 1694 | |
| 1695 | /* Same as TC_two_crcx_mdcx_and_rtp_osmux_wildcard, but using IPv6. */ |
| 1696 | testcase TC_two_crcx_mdcx_and_rtp_osmux_ipv6() runs on dummy_CT { |
| 1697 | f_two_crcx_mdcx_and_rtp_osmux(false, mp_local_ipv6, mp_remote_ipv6, |
| 1698 | mp_local_ipv6, mp_remote_ipv6); |
| 1699 | } |
| 1700 | /* Same as TC_two_crcx_mdcx_and_rtp_osmux_wildcard, but using IPv4 (RTP) and IPv6 (Osmux). */ |
| 1701 | testcase TC_two_crcx_mdcx_and_rtp_osmux_ipv4_ipv6() runs on dummy_CT { |
| 1702 | f_two_crcx_mdcx_and_rtp_osmux(false, mp_local_ipv4, mp_remote_ipv4, |
| 1703 | mp_local_ipv6, mp_remote_ipv6); |
| 1704 | } |
| 1705 | /* Same as TC_two_crcx_mdcx_and_rtp_osmux_wildcard, but using IPv6 (RTP) and IPv4 (Osmux). */ |
| 1706 | testcase TC_two_crcx_mdcx_and_rtp_osmux_ipv6_ipv4() runs on dummy_CT { |
| 1707 | f_two_crcx_mdcx_and_rtp_osmux(false, mp_local_ipv6, mp_remote_ipv6, |
| 1708 | mp_local_ipv4, mp_remote_ipv4); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 1709 | } |
| 1710 | |
Harald Welte | 646ecdb | 2017-12-28 03:21:57 +0100 | [diff] [blame] | 1711 | function f_crcx_and_dlcx_ep_callid_connid(MgcpEndpoint ep, MgcpCallId call_id) runs on dummy_CT { |
| 1712 | var template MgcpCommand cmd; |
| 1713 | var MgcpResponse resp; |
| 1714 | |
| 1715 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1716 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1717 | |
| 1718 | f_dlcx_ok(ep, call_id, extract_conn_id(resp)); |
| 1719 | |
| 1720 | setverdict(pass); |
| 1721 | } |
| 1722 | |
| 1723 | testcase TC_crcx_dlcx_30ep() runs on dummy_CT { |
| 1724 | var MgcpEndpoint ep; |
| 1725 | var MgcpCallId call_id; |
| 1726 | var integer ep_nr; |
| 1727 | |
| 1728 | f_init(); |
| 1729 | |
| 1730 | for (ep_nr := 1; ep_nr < 30; ep_nr := ep_nr+1) { |
Philipp Maier | 4c2a1ea | 2020-05-15 18:37:05 +0200 | [diff] [blame] | 1731 | if(ep_nr > 15) { |
| 1732 | ep := c_mgw_ep_rtpbridge & hex2str(int2hex(ep_nr, 2)) & "@" & c_mgw_domain; |
| 1733 | } else { |
| 1734 | ep := c_mgw_ep_rtpbridge & hex2str(int2hex(ep_nr, 1)) & "@" & c_mgw_domain; |
| 1735 | } |
Harald Welte | 646ecdb | 2017-12-28 03:21:57 +0100 | [diff] [blame] | 1736 | call_id := int2hex(ep_nr, 2) & '1234'H; |
| 1737 | f_crcx_and_dlcx_ep_callid_connid(ep, call_id); |
| 1738 | } |
| 1739 | } |
| 1740 | |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 1741 | /* Test (valid) CRCX followed by (valid) DLCX containing EP+CallId */ |
| 1742 | testcase TC_crcx_and_dlcx_ep_callid() runs on dummy_CT { |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 1743 | var template MgcpCommand cmd; |
| 1744 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1745 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 1746 | var MgcpCallId call_id := '51233'H; |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 1747 | |
Harald Welte | edc45c1 | 2017-11-18 19:15:05 +0100 | [diff] [blame] | 1748 | f_init(ep); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 1749 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 1750 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
Harald Welte | 9988d28 | 2017-11-18 19:22:00 +0100 | [diff] [blame] | 1751 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 1752 | |
Harald Welte | ba62c8c | 2017-11-18 18:26:49 +0100 | [diff] [blame] | 1753 | f_dlcx_ok(ep, call_id); |
Harald Welte | 5b4c44e | 2017-09-17 16:35:27 +0800 | [diff] [blame] | 1754 | |
| 1755 | setverdict(pass); |
| 1756 | } |
| 1757 | |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 1758 | /* Test (valid) CRCX followed by (valid) DLCX containing EP */ |
| 1759 | testcase TC_crcx_and_dlcx_ep() runs on dummy_CT { |
| 1760 | var template MgcpCommand cmd; |
| 1761 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1762 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 1763 | var MgcpCallId call_id := '51232'H; |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 1764 | |
| 1765 | f_init(ep); |
| 1766 | |
| 1767 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1768 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1769 | |
| 1770 | f_dlcx_ok(ep); |
| 1771 | |
| 1772 | setverdict(pass); |
| 1773 | } |
| 1774 | |
| 1775 | |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 1776 | /* CRCX + DLCX of valid endpoint but invalid call-id */ |
| 1777 | testcase TC_crcx_and_dlcx_ep_callid_inval() runs on dummy_CT { |
| 1778 | var template MgcpCommand cmd; |
| 1779 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1780 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 1781 | var MgcpCallId call_id := '51231'H; |
| 1782 | |
| 1783 | f_init(ep); |
| 1784 | |
| 1785 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1786 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1787 | |
| 1788 | f_dlcx(ep, "516", *, 'ffff'H); |
| 1789 | |
| 1790 | setverdict(pass); |
| 1791 | } |
| 1792 | |
| 1793 | |
| 1794 | /* CRCX + DLCX of valid endpoint and call-id but invalid conn-id */ |
| 1795 | testcase TC_crcx_and_dlcx_ep_callid_connid_inval() runs on dummy_CT { |
| 1796 | var template MgcpCommand cmd; |
| 1797 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1798 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 1799 | var MgcpCallId call_id := '51230'H; |
| 1800 | |
| 1801 | f_init(ep); |
| 1802 | |
| 1803 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1804 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1805 | |
| 1806 | f_dlcx(ep, "515", *, call_id, 'ffff'H); |
| 1807 | |
| 1808 | setverdict(pass); |
| 1809 | } |
| 1810 | |
| 1811 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 1812 | /* TODO: Double-DLCX (retransmission) */ |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 1813 | testcase TC_crcx_and_dlcx_retrans() runs on dummy_CT { |
| 1814 | var template MgcpCommand cmd; |
| 1815 | var MgcpResponse resp; |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 1816 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "5@" & c_mgw_domain; |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 1817 | var MgcpCallId call_id := '51229'H; |
| 1818 | var template MgcpResponse rtmpl := { |
| 1819 | line := { |
| 1820 | code := "200", |
| 1821 | string := "OK" |
| 1822 | }, |
| 1823 | params:= { }, |
| 1824 | sdp := omit |
| 1825 | }; |
| 1826 | |
| 1827 | f_init(ep); |
| 1828 | |
| 1829 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 1830 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 1831 | |
| 1832 | cmd := ts_DLCX(get_next_trans_id(), ep, call_id); |
| 1833 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1834 | resp := mgcp_transceive_mgw(cmd, rtmpl); |
| 1835 | |
| 1836 | setverdict(pass); |
| 1837 | } |
| 1838 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1839 | /* transmit RTP streams between two RTP Emulations back-to-back; expect no loss */ |
| 1840 | testcase TC_rtpem_selftest() runs on dummy_CT { |
| 1841 | var RtpemStats stats[2]; |
| 1842 | var integer local_port := 10000; |
| 1843 | var integer local_port2 := 20000; |
| 1844 | |
| 1845 | f_init(); |
| 1846 | |
| 1847 | f_rtpem_bind(RTPEM[0], "127.0.0.1", local_port); |
| 1848 | f_rtpem_bind(RTPEM[1], "127.0.0.2", local_port2); |
| 1849 | |
| 1850 | f_rtpem_connect(RTPEM[0], "127.0.0.2", local_port2); |
| 1851 | f_rtpem_connect(RTPEM[1], "127.0.0.1", local_port); |
| 1852 | |
| 1853 | log("=== starting"); |
| 1854 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 1855 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 1856 | |
| 1857 | f_sleep(5.0); |
| 1858 | |
| 1859 | log("=== stopping"); |
| 1860 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 1861 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 1862 | f_sleep(0.5); |
| 1863 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_NONE); |
| 1864 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 1865 | |
| 1866 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 1867 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 1868 | if (not f_rtpem_stats_compare(stats[0], stats[1])) { |
| 1869 | setverdict(fail, "RTP endpoint statistics don't match"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1870 | mtc.stop; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1871 | } |
| 1872 | setverdict(pass); |
| 1873 | } |
| 1874 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1875 | /* Create one half open connection in receive-only mode. The MGW must accept |
| 1876 | * the packets but must not send any. */ |
| 1877 | testcase TC_one_crcx_receive_only_rtp() runs on dummy_CT { |
| 1878 | var RtpFlowData flow; |
| 1879 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; |
| 1880 | var MgcpCallId call_id := '1225'H; |
| 1881 | var RtpemStats stats; |
| 1882 | |
| 1883 | f_init(ep); |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 1884 | flow := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 112, "AMR/8000/1")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1885 | flow.em.portnr := 10000; |
Pau Espin Pedrol | 25f47a7 | 2020-09-08 18:10:54 +0200 | [diff] [blame] | 1886 | f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow, true); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1887 | |
| 1888 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 1889 | f_sleep(1.0); |
| 1890 | f_flow_delete(RTPEM[0], ep, call_id); |
| 1891 | |
| 1892 | stats := f_rtpem_stats_get(RTPEM[0]); |
| 1893 | |
Philipp Maier | 42b17cc | 2019-10-01 13:53:17 +0200 | [diff] [blame] | 1894 | /* Make sure that at least some amount of RTP packets/bytes |
| 1895 | * have has been transmitted. The compare values for |
| 1896 | * stats.num_pkts_tx and stats.bytes_payload_tx are determined |
| 1897 | * using a testrun and the results were devided by 2, so even |
| 1898 | * in load situations we should reach the minimum amount of |
| 1899 | * required packets/bytes */ |
| 1900 | |
| 1901 | if (stats.num_pkts_tx < 24) { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1902 | setverdict(fail); |
| 1903 | } |
Philipp Maier | 42b17cc | 2019-10-01 13:53:17 +0200 | [diff] [blame] | 1904 | if (stats.bytes_payload_tx < 96) { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1905 | setverdict(fail); |
| 1906 | } |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 1907 | |
| 1908 | f_rtpem_stats_err_check(stats); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1909 | |
| 1910 | setverdict(pass); |
| 1911 | } |
| 1912 | |
| 1913 | /* Create one connection in loopback mode, test if the RTP packets are |
| 1914 | * actually reflected */ |
Philipp Maier | eba70db | 2021-05-17 18:31:39 +0200 | [diff] [blame] | 1915 | function f_TC_one_crcx_loopback_rtp(charstring local_ip, charstring remote_ip, boolean one_phase := true) runs on dummy_CT { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1916 | var RtpFlowData flow; |
| 1917 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; |
| 1918 | var MgcpCallId call_id := '1225'H; |
| 1919 | var RtpemStats stats; |
| 1920 | |
| 1921 | f_init(ep); |
Philipp Maier | 47ec812 | 2023-05-23 11:38:30 +0200 | [diff] [blame] | 1922 | flow := valueof(t_RtpFlow(local_ip, remote_ip, 112, "GSM-HR-08/8000/1")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1923 | flow.em.portnr := 10000; |
Philipp Maier | 1ac1398 | 2021-05-07 23:06:07 +0200 | [diff] [blame] | 1924 | f_flow_create(RTPEM[0], ep, call_id, "loopback", flow, one_phase := one_phase); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1925 | |
| 1926 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 1927 | f_sleep(1.0); |
| 1928 | f_flow_delete(RTPEM[0], ep, call_id); |
| 1929 | |
| 1930 | stats := f_rtpem_stats_get(RTPEM[0]); |
| 1931 | |
| 1932 | if (stats.num_pkts_tx != stats.num_pkts_rx) { |
| 1933 | setverdict(fail); |
| 1934 | } |
| 1935 | if (stats.bytes_payload_tx != stats.bytes_payload_rx) { |
| 1936 | setverdict(fail); |
| 1937 | } |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 1938 | |
| 1939 | f_rtpem_stats_err_check(stats); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1940 | |
| 1941 | setverdict(pass); |
| 1942 | } |
| 1943 | |
Philipp Maier | 1ac1398 | 2021-05-07 23:06:07 +0200 | [diff] [blame] | 1944 | /* Create one connection in loopback mode, test if the RTP packets are |
| 1945 | * actually reflected */ |
| 1946 | testcase TC_one_crcx_loopback_rtp() runs on dummy_CT { |
Philipp Maier | eba70db | 2021-05-17 18:31:39 +0200 | [diff] [blame] | 1947 | f_TC_one_crcx_loopback_rtp(mp_local_ipv4, mp_remote_ipv4, one_phase := true) |
Philipp Maier | 1ac1398 | 2021-05-07 23:06:07 +0200 | [diff] [blame] | 1948 | } |
Philipp Maier | c0ca42d | 2021-05-17 18:41:19 +0200 | [diff] [blame] | 1949 | testcase TC_one_crcx_loopback_rtp_ipv6() runs on dummy_CT { |
| 1950 | f_TC_one_crcx_loopback_rtp(mp_local_ipv6, mp_remote_ipv6, one_phase := true) |
| 1951 | } |
Philipp Maier | 1ac1398 | 2021-05-07 23:06:07 +0200 | [diff] [blame] | 1952 | |
| 1953 | /* Same as above, but we will intenionally not tell the MGW where to |
| 1954 | * send the outgoing traffic. The connection is still created in |
| 1955 | * loopback mode, so the MGW should take the originating address from |
| 1956 | * the incoming RTP packet and send it back to the source */ |
| 1957 | testcase TC_one_crcx_loopback_rtp_implicit() runs on dummy_CT { |
Philipp Maier | eba70db | 2021-05-17 18:31:39 +0200 | [diff] [blame] | 1958 | f_TC_one_crcx_loopback_rtp(mp_local_ipv6, mp_remote_ipv6, one_phase := false) |
Philipp Maier | 1ac1398 | 2021-05-07 23:06:07 +0200 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | |
Philipp Maier | 7df85f6 | 2018-07-25 10:26:09 +0200 | [diff] [blame] | 1962 | function f_TC_two_crcx_and_rtp(boolean bidir, charstring codec_name_a, integer pt_a, |
| 1963 | charstring codec_name_b, integer pt_b) runs on dummy_CT { |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1964 | var RtpFlowData flow[2]; |
| 1965 | var RtpemStats stats[2]; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1966 | var MgcpResponse resp; |
| 1967 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 1968 | var MgcpCallId call_id := '1226'H; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1969 | var integer tolerance := 0; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1970 | |
| 1971 | f_init(ep); |
| 1972 | |
| 1973 | /* from us to MGW */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 1974 | flow[0] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, pt_a, codec_name_a)); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1975 | /* bind local RTP emulation sockets */ |
| 1976 | flow[0].em.portnr := 10000; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1977 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1978 | |
| 1979 | /* from MGW back to us */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 1980 | flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, pt_b, codec_name_b)); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 1981 | flow[1].em.portnr := 20000; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 1982 | f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 1983 | |
| 1984 | if (bidir) { |
| 1985 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 1986 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 1987 | |
| 1988 | /* Note: When we test bidirectional we may |
| 1989 | * loose packets during switch off because |
| 1990 | * both ends are transmitting and we only |
| 1991 | * can switch them off one by one. */ |
| 1992 | tolerance := 3; |
| 1993 | } else { |
| 1994 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 1995 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 1996 | } |
| 1997 | |
| 1998 | f_sleep(1.0); |
| 1999 | |
| 2000 | f_flow_delete(RTPEM[1]); |
| 2001 | f_flow_delete(RTPEM[0], ep, call_id); |
| 2002 | |
| 2003 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2004 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2005 | if (not f_rtpem_stats_compare(stats[0], stats[1], tolerance)) { |
| 2006 | setverdict(fail, "RTP endpoint statistics don't match"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2007 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2008 | } |
| 2009 | |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 2010 | f_rtpem_stats_err_check(stats[0]); |
| 2011 | f_rtpem_stats_err_check(stats[1]); |
Philipp Maier | c290d72 | 2018-07-24 18:51:36 +0200 | [diff] [blame] | 2012 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2013 | setverdict(pass); |
| 2014 | } |
| 2015 | |
| 2016 | /* create two local RTP emulations; create two connections on MGW EP, exchange some data */ |
| 2017 | testcase TC_two_crcx_and_rtp() runs on dummy_CT { |
Philipp Maier | 7df85f6 | 2018-07-25 10:26:09 +0200 | [diff] [blame] | 2018 | f_TC_two_crcx_and_rtp(false, "AMR/8000", 98, "AMR/8000", 98); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2019 | } |
| 2020 | |
| 2021 | /* create two local RTP emulations; create two connections on MGW EP, |
| 2022 | * exchange some data in both directions */ |
| 2023 | testcase TC_two_crcx_and_rtp_bidir() runs on dummy_CT { |
Philipp Maier | 7df85f6 | 2018-07-25 10:26:09 +0200 | [diff] [blame] | 2024 | f_TC_two_crcx_and_rtp(true, "AMR/8000", 98, "AMR/8000", 98); |
| 2025 | } |
| 2026 | |
| 2027 | /* same as TC_two_crcx_and_rtp, but with different PT number on both ends */ |
| 2028 | testcase TC_two_crcx_diff_pt_and_rtp() runs on dummy_CT { |
| 2029 | f_TC_two_crcx_and_rtp(false, "AMR/8000", 98, "AMR/8000", 112); |
| 2030 | } |
| 2031 | |
| 2032 | /* same as TC_two_crcx_and_rtp, but with different PT number on both ends */ |
| 2033 | testcase TC_two_crcx_diff_pt_and_rtp_bidir() runs on dummy_CT { |
| 2034 | f_TC_two_crcx_and_rtp(true, "AMR/8000", 98, "AMR/8000", 112); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2035 | } |
| 2036 | |
| 2037 | /* create two local RTP emulations and pass data in both directions */ |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 2038 | function f_tc_two_crcx_mdcx_and_rtp(charstring local_ip_a, charstring remote_ip_a, |
Oliver Smith | 3cfa2cc | 2023-01-24 13:50:26 +0100 | [diff] [blame] | 2039 | charstring local_ip_b, charstring remote_ip_b, |
| 2040 | uint7_t payload_type := 3, |
| 2041 | charstring codec_name := "GSM/8000/1") runs on dummy_CT { |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2042 | var RtpFlowData flow[2]; |
| 2043 | var RtpemStats stats[2]; |
| 2044 | var MgcpResponse resp; |
| 2045 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2046 | var MgcpCallId call_id := '1227'H; |
| 2047 | var integer num_pkts_tx[2]; |
| 2048 | var integer temp; |
| 2049 | |
| 2050 | f_init(ep); |
| 2051 | |
| 2052 | /* Create the first connection in receive only mode */ |
Oliver Smith | 3cfa2cc | 2023-01-24 13:50:26 +0100 | [diff] [blame] | 2053 | flow[0] := valueof(t_RtpFlow(local_ip_a, remote_ip_a, payload_type, codec_name)); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2054 | flow[0].em.portnr := 10000; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 2055 | f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow[0], true); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2056 | |
| 2057 | /* Create the second connection. This connection will be also |
| 2058 | * in receive only mode */ |
Oliver Smith | 3cfa2cc | 2023-01-24 13:50:26 +0100 | [diff] [blame] | 2059 | flow[1] := valueof(t_RtpFlow(local_ip_b, remote_ip_b, payload_type, codec_name)); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2060 | flow[1].em.portnr := 20000; |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 2061 | f_flow_create(RTPEM[1], ep, call_id, "recvonly", flow[1], true); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2062 | |
| 2063 | /* The first leg starts transmitting */ |
| 2064 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 2065 | f_sleep(0.5); |
| 2066 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2067 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2068 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2069 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2070 | } |
| 2071 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2072 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2073 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2074 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | /* The second leg starts transmitting a little later */ |
| 2078 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 2079 | f_sleep(1.0); |
| 2080 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2081 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2082 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2083 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2084 | } |
| 2085 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2086 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2087 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2088 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2089 | } |
| 2090 | |
| 2091 | /* The first leg will now be switched into bidirectional |
| 2092 | * mode, but we do not expect any data comming back yet. */ |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2093 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2094 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2095 | num_pkts_tx[1] := stats[1].num_pkts_tx; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2096 | f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2097 | f_sleep(0.5); |
| 2098 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2099 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2100 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2101 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2102 | } |
| 2103 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2104 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2105 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2106 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2107 | } |
| 2108 | |
| 2109 | /* When the second leg is switched into bidirectional mode |
| 2110 | * as well, then the MGW will connect the two together and |
| 2111 | * we should see RTP streams passing through from both ends. */ |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2112 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 2113 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2114 | num_pkts_tx[0] := stats[0].num_pkts_tx; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2115 | f_flow_modify(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2116 | f_sleep(2.0); |
| 2117 | |
| 2118 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2119 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2120 | |
| 2121 | temp := stats[0].num_pkts_tx - num_pkts_tx[0] - stats[1].num_pkts_rx; |
| 2122 | if (temp > 3 or temp < -3) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2123 | setverdict(fail, "number of packets not within normal parameters:", temp); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2124 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2125 | } |
| 2126 | |
| 2127 | temp := stats[1].num_pkts_tx - num_pkts_tx[1] - stats[0].num_pkts_rx; |
| 2128 | if (temp > 3 or temp < -3) { |
Pau Espin Pedrol | 89c76d2 | 2020-09-07 18:42:04 +0200 | [diff] [blame] | 2129 | setverdict(fail, "number of packets not within normal parameters:", temp); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2130 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2131 | } |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 2132 | |
| 2133 | f_rtpem_stats_err_check(stats[0]); |
| 2134 | f_rtpem_stats_err_check(stats[1]); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2135 | |
| 2136 | /* Tear down */ |
| 2137 | f_flow_delete(RTPEM[0]); |
| 2138 | f_flow_delete(RTPEM[1], ep, call_id); |
| 2139 | setverdict(pass); |
| 2140 | } |
| 2141 | |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 2142 | testcase TC_two_crcx_mdcx_and_rtp() runs on dummy_CT { |
| 2143 | f_tc_two_crcx_mdcx_and_rtp(mp_local_ipv4, mp_remote_ipv4, |
| 2144 | mp_local_ipv4, mp_remote_ipv4); |
| 2145 | } |
| 2146 | |
| 2147 | testcase TC_two_crcx_mdcx_and_rtp_ipv6() runs on dummy_CT { |
| 2148 | f_tc_two_crcx_mdcx_and_rtp(mp_local_ipv6, mp_remote_ipv6, |
| 2149 | mp_local_ipv6, mp_remote_ipv6); |
| 2150 | } |
| 2151 | |
| 2152 | testcase TC_two_crcx_mdcx_and_rtp_ipv4_ipv6() runs on dummy_CT { |
| 2153 | f_tc_two_crcx_mdcx_and_rtp(mp_local_ipv4, mp_remote_ipv4, |
| 2154 | mp_local_ipv6, mp_remote_ipv6); |
| 2155 | } |
| 2156 | |
Oliver Smith | 871f45a | 2023-01-24 16:21:50 +0100 | [diff] [blame] | 2157 | testcase TC_two_crcx_mdcx_and_rtp_clearmode() runs on dummy_CT { |
| 2158 | f_tc_two_crcx_mdcx_and_rtp(mp_local_ipv4, mp_remote_ipv4, |
| 2159 | mp_local_ipv4, mp_remote_ipv4, |
| 2160 | 120, /* 3GPP TS 48.103 table 5.4.2.2.1 */ |
| 2161 | "CLEARMODE/8000"); |
| 2162 | } |
| 2163 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2164 | /* Test what happens when two RTP streams from different sources target |
| 2165 | * a single connection. Is the unsolicited stream properly ignored? */ |
| 2166 | testcase TC_two_crcx_and_unsolicited_rtp() runs on dummy_CT { |
| 2167 | var RtpFlowData flow[2]; |
| 2168 | var RtpemStats stats[2]; |
| 2169 | var MgcpResponse resp; |
| 2170 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2171 | var MgcpCallId call_id := '1234321326'H; |
| 2172 | var integer unsolicited_port := 10002; |
| 2173 | |
| 2174 | f_init(ep); |
| 2175 | |
| 2176 | /* from us to MGW */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2177 | flow[0] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 98, "AMR/8000")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2178 | /* bind local RTP emulation sockets */ |
| 2179 | flow[0].em.portnr := 10000; |
| 2180 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2181 | |
| 2182 | /* from MGW back to us */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2183 | flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 98, "AMR/8000")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2184 | flow[1].em.portnr := 20000; |
| 2185 | f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2186 | |
| 2187 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 2188 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 2189 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2190 | f_sleep(0.5); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2191 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2192 | /* Start inserting unsolicited RTP packets */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2193 | f_rtpem_bind(RTPEM[2], mp_local_ipv4, unsolicited_port); |
| 2194 | f_rtpem_connect(RTPEM[2], mp_remote_ipv4, flow[0].mgw.portnr); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2195 | f_rtpem_mode(RTPEM[2], RTPEM_MODE_TXONLY); |
| 2196 | |
| 2197 | f_sleep(0.5); |
| 2198 | |
Daniel Willmann | a069d38 | 2018-12-13 13:53:33 +0100 | [diff] [blame] | 2199 | /* Stop transmitting packets and tear down the flows */ |
| 2200 | f_rtpem_mode(RTPEM[2], RTPEM_MODE_NONE); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2201 | f_flow_delete(RTPEM[0]); |
| 2202 | f_flow_delete(RTPEM[1], ep, call_id); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2203 | |
| 2204 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2205 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2206 | if (not f_rtpem_stats_compare(stats[0], stats[1])) { |
| 2207 | setverdict(fail, "RTP endpoint statistics don't match"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2208 | mtc.stop; |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2209 | } |
| 2210 | |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 2211 | f_rtpem_stats_err_check(stats[0]); |
| 2212 | f_rtpem_stats_err_check(stats[0]); |
Philipp Maier | c290d72 | 2018-07-24 18:51:36 +0200 | [diff] [blame] | 2213 | |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2214 | setverdict(pass); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2215 | } |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2216 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2217 | /* Test a handover situation. We first create two connections transmit |
| 2218 | * some data bidirectionally. Then we will simulate a handover situation. */ |
| 2219 | testcase TC_two_crcx_and_one_mdcx_rtp_ho() runs on dummy_CT { |
| 2220 | var RtpFlowData flow[2]; |
| 2221 | var RtpemStats stats[3]; |
| 2222 | var MgcpResponse resp; |
| 2223 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "4@" & c_mgw_domain; |
| 2224 | var MgcpCallId call_id := '76338'H; |
| 2225 | var integer port_old; |
| 2226 | |
| 2227 | f_init(ep); |
| 2228 | |
| 2229 | /* First connection (BTS) */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2230 | flow[0] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 110, "GSM-EFR/8000")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2231 | /* bind local RTP emulation sockets */ |
| 2232 | flow[0].em.portnr := 10000; |
| 2233 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2234 | |
| 2235 | /* Second connection (PBX) */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2236 | flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 110, "GSM-EFR/8000")); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2237 | flow[1].em.portnr := 20000; |
| 2238 | f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2239 | |
| 2240 | /* Normal rtp flow for one second */ |
| 2241 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2242 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 2243 | f_sleep(1.0); |
| 2244 | |
| 2245 | /* Now switch the flow over to a new port (BTS) */ |
| 2246 | port_old := flow[0].em.portnr; |
| 2247 | flow[0].em.portnr := 10002; |
Daniel Willmann | 43a1a0b | 2018-08-01 11:19:39 +0200 | [diff] [blame] | 2248 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2249 | f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
Daniel Willmann | 43a1a0b | 2018-08-01 11:19:39 +0200 | [diff] [blame] | 2250 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2251 | |
| 2252 | /* When handing over a call, the old source may still keep |
| 2253 | * transmitting for a while. We simulate this by injecting |
| 2254 | * some unsolicited packets on the behalf of the old source, |
| 2255 | * (old remote port) */ |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2256 | f_rtpem_bind(RTPEM[2], mp_local_ipv4, port_old); |
| 2257 | f_rtpem_connect(RTPEM[2], mp_remote_ipv4, flow[0].mgw.portnr); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2258 | f_rtpem_mode(RTPEM[2], RTPEM_MODE_TXONLY); |
| 2259 | f_sleep(1.0); |
| 2260 | f_rtpem_mode(RTPEM[2], RTPEM_MODE_NONE); |
| 2261 | f_sleep(1.0); |
| 2262 | |
| 2263 | /* Terminate call */ |
| 2264 | f_flow_delete(RTPEM[0]); |
| 2265 | f_flow_delete(RTPEM[1], ep, call_id); |
| 2266 | |
| 2267 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2268 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2269 | if (not f_rtpem_stats_compare(stats[0], stats[1], 5)) { |
| 2270 | setverdict(fail, "RTP endpoint statistics don't match"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2271 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2272 | } |
| 2273 | stats[2] := f_rtpem_stats_get(RTPEM[2]); |
| 2274 | if (stats[2].num_pkts_rx_err_disabled != 0) { |
| 2275 | setverdict(fail, "received packets on old leg after handover"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2276 | mtc.stop; |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2277 | } |
| 2278 | |
Philipp Maier | 3629139 | 2018-07-25 09:40:44 +0200 | [diff] [blame] | 2279 | f_rtpem_stats_err_check(stats[0]); |
| 2280 | f_rtpem_stats_err_check(stats[1]); |
| 2281 | f_rtpem_stats_err_check(stats[2]); |
Philipp Maier | c290d72 | 2018-07-24 18:51:36 +0200 | [diff] [blame] | 2282 | |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 2283 | setverdict(pass); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 2284 | } |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 2285 | |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2286 | |
| 2287 | /* create two local RTP emulations; create two connections on MGW EP, see if |
Philipp Maier | 8ed48c5 | 2023-02-07 11:24:31 +0100 | [diff] [blame] | 2288 | * exchanged data is converted between ts101318 and rfc5993 */ |
| 2289 | function f_ts101318_rfc5993_rtp_conversion(octetstring pl0, octetstring pl1, charstring fmtp0, charstring fmtp1) runs on dummy_CT { |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2290 | var RtpFlowData flow[2]; |
| 2291 | var RtpemStats stats[2]; |
| 2292 | var MgcpResponse resp; |
| 2293 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2294 | var MgcpCallId call_id := '1226'H; |
| 2295 | |
| 2296 | f_init(ep); |
| 2297 | |
| 2298 | /* Turn on conversion mode */ |
| 2299 | f_vty_enter_config(MGWVTY); |
| 2300 | f_vty_transceive(MGWVTY, "mgcp"); |
| 2301 | f_vty_transceive(MGWVTY, "rtp-patch rfc5993hr"); |
| 2302 | |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2303 | /* Connection #0 (Bidirectional) */ |
Philipp Maier | 6b41e15 | 2023-03-31 11:45:24 +0200 | [diff] [blame] | 2304 | flow[0] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 111, "GSM-HR-08/8000", fmtp0)); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2305 | /* bind local RTP emulation sockets */ |
| 2306 | flow[0].em.portnr := 10000; |
| 2307 | flow[0].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2308 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2309 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2310 | flow[0].rtp_cfg.rx_payloads[0].fixed_payload := pl0; |
| 2311 | flow[0].rtp_cfg.tx_payloads[0].fixed_payload := pl0; |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2312 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2313 | |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2314 | /* Connection #1 (Bidirectional) */ |
Philipp Maier | 6b41e15 | 2023-03-31 11:45:24 +0200 | [diff] [blame] | 2315 | flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 111, "GSM-HR-08/8000", fmtp1)); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2316 | flow[1].em.portnr := 20000; |
| 2317 | flow[1].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2318 | flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
| 2319 | flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
| 2320 | flow[1].rtp_cfg.rx_payloads[0].fixed_payload := pl1; |
| 2321 | flow[1].rtp_cfg.tx_payloads[0].fixed_payload := pl1; |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2322 | f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2323 | |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2324 | /* Send RTP packets to connection #0, receive on connection #1 */ |
| 2325 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 2326 | f_sleep(0.5); |
| 2327 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2328 | f_sleep(1.0); |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2329 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2330 | f_sleep(0.5); |
| 2331 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_NONE); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2332 | |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2333 | /* Send RTP packets to connection #1, receive on connection #0 */ |
| 2334 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 2335 | f_sleep(0.5); |
| 2336 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 2337 | f_sleep(1.0); |
| 2338 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_NONE); |
| 2339 | f_sleep(0.5); |
| 2340 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2341 | |
| 2342 | /* Remove RTP flows and check statistics */ |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2343 | f_flow_delete(RTPEM[0]); |
| 2344 | f_flow_delete(RTPEM[1], ep, call_id); |
| 2345 | |
Philipp Maier | faa1d2f | 2019-10-01 14:07:35 +0200 | [diff] [blame] | 2346 | /* Check for errors */ |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2347 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2348 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2349 | f_rtpem_stats_err_check(stats[0]); |
| 2350 | f_rtpem_stats_err_check(stats[1]); |
| 2351 | |
| 2352 | /* Turn off conversion mode */ |
| 2353 | f_vty_transceive(MGWVTY, "no rtp-patch rfc5993hr"); |
| 2354 | |
| 2355 | setverdict(pass); |
| 2356 | } |
| 2357 | |
Philipp Maier | 8ed48c5 | 2023-02-07 11:24:31 +0100 | [diff] [blame] | 2358 | const octetstring rtp_hr_gsm_ts101318 := '0b11b3eede60be4e3ec68838c7b5'O; |
| 2359 | const octetstring rtp_hr_gsm_rfc5993 := '000b11b3eede60be4e3ec68838c7b5'O; |
| 2360 | |
| 2361 | testcase TC_ts101318_rfc5993_rtp_conversion() runs on dummy_CT { |
| 2362 | f_ts101318_rfc5993_rtp_conversion(rtp_hr_gsm_ts101318, rtp_hr_gsm_rfc5993, "", ""); |
| 2363 | } |
| 2364 | |
| 2365 | testcase TC_ts101318_rfc5993_rtp_conversion_fmtp() runs on dummy_CT { |
| 2366 | f_ts101318_rfc5993_rtp_conversion(rtp_hr_gsm_ts101318, rtp_hr_gsm_rfc5993, "gsm-hr-format=ts101318", "gsm-hr-format=rfc5993"); |
| 2367 | } |
| 2368 | |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2369 | /* create two local RTP emulations; create two connections on MGW EP, see if |
Philipp Maier | eb5e813 | 2023-04-13 16:20:37 +0200 | [diff] [blame] | 2370 | * exchanged data is converted between AMR octet-aligned and bandwidth |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2371 | * efficient-mode */ |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2372 | function f_TC_amr_x_x_rtp_conversion(charstring fmtp0, octetstring pl0, |
| 2373 | charstring fmtp1a, octetstring pl1a, |
| 2374 | charstring fmtp1b, octetstring pl1b) runs on dummy_CT { |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2375 | var RtpFlowData flow[2]; |
| 2376 | var RtpemStats stats[2]; |
| 2377 | var MgcpResponse resp; |
| 2378 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2379 | var MgcpCallId call_id := '1226'H; |
| 2380 | |
| 2381 | f_init(ep); |
| 2382 | |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2383 | /* Connection #0 (Bidirectional) */ |
Philipp Maier | 6b41e15 | 2023-03-31 11:45:24 +0200 | [diff] [blame] | 2384 | flow[0] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 96, "AMR/8000", fmtp0)); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2385 | /* bind local RTP emulation sockets */ |
| 2386 | flow[0].em.portnr := 10000; |
| 2387 | flow[0].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2388 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2389 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2390 | flow[0].rtp_cfg.rx_payloads[0].fixed_payload := pl0; |
| 2391 | flow[0].rtp_cfg.tx_payloads[0].fixed_payload := pl0; |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2392 | f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2393 | |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2394 | /* Connection #1 (Bidirectional) */ |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2395 | flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 112, "AMR/8000", fmtp1a)); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2396 | flow[1].em.portnr := 20000; |
| 2397 | flow[1].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2398 | flow[1].rtp_cfg.rx_payloads := {}; |
| 2399 | flow[1].rtp_cfg.tx_payloads := {}; |
| 2400 | if (pl1a != ''O) { |
| 2401 | flow[1].rtp_cfg.rx_payloads := flow[1].rtp_cfg.rx_payloads & {{112, pl1a}}; |
| 2402 | flow[1].rtp_cfg.tx_payloads := flow[1].rtp_cfg.tx_payloads & {{112, pl1a}}; |
| 2403 | } |
| 2404 | |
| 2405 | /* The second fmtp parameter is to simulate a call agent that offers the transmission both modes. */ |
| 2406 | if (fmtp1b != "") { |
| 2407 | flow[1].codec_descr := flow[1].codec_descr & {{113, "AMR/8000", fmtp1b}}; |
| 2408 | if (pl1b != ''O) { |
| 2409 | flow[1].rtp_cfg.rx_payloads := flow[1].rtp_cfg.rx_payloads & {{113, pl1b}}; |
| 2410 | flow[1].rtp_cfg.tx_payloads := flow[1].rtp_cfg.tx_payloads & {{113, pl1b}}; |
| 2411 | } |
| 2412 | } |
| 2413 | |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2414 | f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2415 | |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2416 | /* Send RTP packets to connection #0, receive on connection #1 */ |
| 2417 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 2418 | f_sleep(0.5); |
| 2419 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2420 | f_sleep(1.0); |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2421 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2422 | f_sleep(0.5); |
| 2423 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_NONE); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2424 | |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2425 | /* Send RTP packets to connection #1, receive on connection #0 */ |
| 2426 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 2427 | f_sleep(0.5); |
| 2428 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 2429 | f_sleep(1.0); |
| 2430 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_NONE); |
| 2431 | f_sleep(0.5); |
| 2432 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2433 | |
| 2434 | /* Remove RTP flows and check statistics */ |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2435 | f_flow_delete(RTPEM[0]); |
| 2436 | f_flow_delete(RTPEM[1], ep, call_id); |
| 2437 | |
Philipp Maier | 9ff0f8a | 2019-10-01 13:21:28 +0200 | [diff] [blame] | 2438 | /* Check for errors */ |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2439 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2440 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2441 | f_rtpem_stats_err_check(stats[0]); |
| 2442 | f_rtpem_stats_err_check(stats[1]); |
| 2443 | |
| 2444 | setverdict(pass); |
| 2445 | } |
| 2446 | |
Philipp Maier | 882843d | 2020-05-25 15:33:13 +0200 | [diff] [blame] | 2447 | /* Note: The hexstrings used with the f_TC_amr_x_x_rtp_conversion test |
| 2448 | * functions are real world AMR RTP payloads including AMR header. The |
| 2449 | * payloads were extracted from a trace with known good payloads. */ |
| 2450 | |
Philipp Maier | cd756ed | 2023-02-13 11:12:24 +0100 | [diff] [blame] | 2451 | const octetstring rtp_amr_5_90k_oa := '2014e959f35fdfe5e9667ffbc088818088'O; |
| 2452 | const octetstring rtp_amr_5_90k_bwe := '217a567cd7f7f97a599ffef022206022'O; |
| 2453 | const octetstring rtp_amr_5_15k_oa := '100c4e9ba850e30d5d53d04de41e7c'O; |
| 2454 | const octetstring rtp_amr_5_15k_bwe := '10d3a6ea1438c35754f41379079f'O; |
| 2455 | |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2456 | /* Only one codec on each side */ |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2457 | testcase TC_amr_oa_bwe_rtp_conversion() runs on dummy_CT { |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2458 | f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_90k_oa, "octet-align=0", rtp_amr_5_90k_bwe, "", ''O); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2459 | } |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2460 | testcase TC_amr_oa_oa_rtp_conversion() runs on dummy_CT { |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2461 | f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa, "octet-align=1", rtp_amr_5_15k_oa, "", ''O); |
| 2462 | } |
| 2463 | testcase TC_amr_bwe_bwe_rtp_conversion() runs on dummy_CT { |
| 2464 | f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe, "octet-align=0", rtp_amr_5_15k_bwe, "", ''O); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2465 | } |
| 2466 | |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 2467 | /* Only one codec on one side, two codecs (compatibility) on other side. The payloads are the same on both |
| 2468 | * sides, so the expectation is that conversion must not be performed. Each test is done with both formats in |
| 2469 | * two different configurations.*/ |
| 2470 | testcase TC_amr_oa_oa_no_bwe_rtp_conversion() runs on dummy_CT { |
| 2471 | f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa, |
| 2472 | "octet-align=1", rtp_amr_5_15k_oa, |
| 2473 | "octet-align=0", ''O); /* We expect to see NO bandwidth efficient packets! */ |
| 2474 | } |
| 2475 | testcase TC_amr_oa_no_bwe_oa_rtp_conversion() runs on dummy_CT { |
| 2476 | /* (Same as above but flipped on the opposite side) */ |
| 2477 | f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa, |
| 2478 | "octet-align=0", ''O, /* We expect to see NO bandwidth efficient packets! */ |
| 2479 | "octet-align=1", rtp_amr_5_15k_oa); |
| 2480 | } |
| 2481 | testcase TC_amr_bwe_bwe_no_oa_rtp_conversion() runs on dummy_CT { |
| 2482 | f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe, |
| 2483 | "octet-align=0", rtp_amr_5_15k_bwe, |
| 2484 | "octet-align=1", ''O); /* We expect to see NO octet aligned packets! */ |
| 2485 | } |
| 2486 | testcase TC_amr_bwe_no_oa_bwe_rtp_conversion() runs on dummy_CT { |
| 2487 | /* (Same as above but flipped on the opposite side) */ |
| 2488 | f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe, |
| 2489 | "octet-align=1", ''O, /* We expect to see NO octet aligned packets! */ |
| 2490 | "octet-align=0", rtp_amr_5_15k_bwe); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 2491 | } |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 2492 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 2493 | /* TODO: Double-DLCX (no retransmission) */ |
| 2494 | |
| 2495 | |
| 2496 | |
| 2497 | /* TODO: AUEP (various) */ |
| 2498 | /* TODO: RSIP (various) */ |
| 2499 | /* TODO: RQNT (various) */ |
| 2500 | /* TODO: EPCF (various) */ |
| 2501 | /* TODO: AUCX (various) */ |
| 2502 | /* TODO: invalid verb (various) */ |
| 2503 | |
Oliver Smith | 021141e | 2019-06-25 12:09:01 +0200 | [diff] [blame] | 2504 | |
| 2505 | testcase TC_conn_timeout() runs on dummy_CT { |
| 2506 | var RtpFlowData flow; |
| 2507 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "1@" & c_mgw_domain; |
| 2508 | var MgcpCallId call_id := '1225'H; |
| 2509 | var MGCP_RecvFrom mrf; |
| 2510 | |
| 2511 | f_init(ep); |
| 2512 | log("Setting conn-timeout to 1s"); |
| 2513 | f_vty_config(MGWVTY, "mgcp", "conn-timeout 1"); /* reset in f_init_vty() */ |
| 2514 | |
| 2515 | log("Sending RTP data for 1.5s"); |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2516 | flow := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 111, "GSM-HR-08/8000/1")); |
Oliver Smith | 021141e | 2019-06-25 12:09:01 +0200 | [diff] [blame] | 2517 | flow.em.portnr := 10000; |
| 2518 | f_flow_create(RTPEM[0], ep, call_id, "loopback", flow); |
| 2519 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2520 | f_sleep(1.5); |
| 2521 | |
| 2522 | log("Stopping for 0.5s and resuming"); |
| 2523 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2524 | f_sleep(0.5); |
| 2525 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2526 | f_sleep(0.1); |
| 2527 | |
| 2528 | log("Stopping for 1.5s, expecting to run into timeout"); |
| 2529 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_NONE); |
| 2530 | f_sleep(1.5); |
| 2531 | |
| 2532 | log("Resuming should fail now"); |
| 2533 | f_rtpem_conn_refuse_expect(RTPEM[0]); |
| 2534 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2535 | f_sleep(0.2); |
| 2536 | f_rtpem_conn_refuse_verify(RTPEM[0]); |
| 2537 | |
| 2538 | setverdict(pass); |
| 2539 | } |
| 2540 | |
Philipp Maier | 2609c75 | 2020-07-08 12:38:09 +0200 | [diff] [blame] | 2541 | /* Test (valid) CRCX followed by (valid) DLCX containing EP (E1) */ |
| 2542 | testcase TC_e1_crcx_and_dlcx_ep() runs on dummy_CT { |
| 2543 | var template MgcpCommand cmd; |
| 2544 | var MgcpResponse resp; |
| 2545 | var MgcpEndpoint ep := "ds/e1-1/s-1/su16-0@" & c_mgw_domain; |
| 2546 | var MgcpCallId call_id := '8376F297'H; |
| 2547 | |
| 2548 | f_init(ep); |
| 2549 | |
| 2550 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2551 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2552 | |
| 2553 | f_dlcx_ok(ep); |
| 2554 | |
| 2555 | setverdict(pass); |
| 2556 | } |
| 2557 | |
| 2558 | /* Test what happens when overlapping endpoints are selected (E1) */ |
| 2559 | testcase TC_e1_crcx_with_overlap() runs on dummy_CT { |
| 2560 | var template MgcpCommand cmd; |
| 2561 | var MgcpResponse resp; |
| 2562 | var MgcpEndpoint ep_1 := "ds/e1-1/s-1/su8-0@" & c_mgw_domain; |
| 2563 | var MgcpEndpoint ep_2 := "ds/e1-1/s-1/su16-0@" & c_mgw_domain; |
| 2564 | var MgcpCallId call_id_1 := '8376F297'H; |
| 2565 | var MgcpCallId call_id_2 := '837AF2A7'H; |
| 2566 | |
| 2567 | f_init(); |
| 2568 | |
| 2569 | /* ep_1 and ep_2 are overlapping, selecting both one after |
| 2570 | * another should work fine: */ |
| 2571 | cmd := ts_CRCX(get_next_trans_id(), ep_1, "recvonly", call_id_1); |
| 2572 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2573 | f_dlcx_ok(ep_1); |
| 2574 | cmd := ts_CRCX(get_next_trans_id(), ep_2, "recvonly", call_id_2); |
| 2575 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2576 | f_dlcx_ok(ep_2); |
| 2577 | |
| 2578 | /* When ep_1 is serving a call we can not select ep_2 becaus |
| 2579 | * it is overlapping with ep_1 */ |
| 2580 | cmd := ts_CRCX(get_next_trans_id(), ep_1, "recvonly", call_id_1); |
| 2581 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2582 | cmd := ts_CRCX(get_next_trans_id(), ep_2, "recvonly", call_id_2); |
| 2583 | resp := mgcp_transceive_mgw(cmd, ?); |
| 2584 | if (resp.line.code != "501") { |
| 2585 | setverdict(fail, "unexpected CRCX returncode, CRCX should fail!"); |
| 2586 | } |
| 2587 | f_dlcx_ok(ep_1); |
| 2588 | |
| 2589 | setverdict(pass); |
| 2590 | } |
| 2591 | |
| 2592 | /* Create one connection in loopback mode, test if the RTP packets are |
| 2593 | * actually reflected */ |
| 2594 | testcase TC_e1_crcx_loopback() runs on dummy_CT { |
| 2595 | var RtpFlowData flow; |
| 2596 | var MgcpEndpoint ep := "ds/e1-1/s-1/su16-0@" & c_mgw_domain; |
| 2597 | var MgcpCallId call_id := '12250989'H; |
| 2598 | var RtpemStats stats; |
| 2599 | |
| 2600 | f_init(ep); |
Pau Espin Pedrol | b604af0 | 2020-09-07 17:12:39 +0200 | [diff] [blame] | 2601 | flow := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 111, "GSM-HR-08/8000/1")); |
Philipp Maier | 2609c75 | 2020-07-08 12:38:09 +0200 | [diff] [blame] | 2602 | flow.em.portnr := 10000; |
| 2603 | f_flow_create(RTPEM[0], ep, call_id, "loopback", flow); |
| 2604 | |
| 2605 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2606 | f_sleep(1.0); |
| 2607 | f_flow_delete(RTPEM[0], ep, call_id); |
| 2608 | |
| 2609 | stats := f_rtpem_stats_get(RTPEM[0]); |
| 2610 | |
| 2611 | if (stats.num_pkts_tx != stats.num_pkts_rx) { |
| 2612 | setverdict(fail); |
| 2613 | } |
| 2614 | if (stats.bytes_payload_tx != stats.bytes_payload_rx) { |
| 2615 | setverdict(fail); |
| 2616 | } |
| 2617 | |
| 2618 | f_rtpem_stats_err_check(stats); |
| 2619 | |
| 2620 | setverdict(pass); |
| 2621 | } |
| 2622 | |
Philipp Maier | 13aff99 | 2022-06-30 16:19:59 +0200 | [diff] [blame] | 2623 | /* test valid wildcarded DLCX on an E1 trunk */ |
| 2624 | testcase TC_e1_dlcx_wildcarded() runs on dummy_CT { |
| 2625 | var template MgcpCommand cmd; |
| 2626 | var MgcpEndpoint ep; |
| 2627 | var MgcpCallId call_id := '8376F297'H; |
| 2628 | var integer n_e1_ts := 4; |
| 2629 | var StatsDExpects expect; |
| 2630 | |
| 2631 | f_init(); |
| 2632 | |
| 2633 | /* Open a few E1 timeslots */ |
| 2634 | for (var integer i := 0; i < n_e1_ts; i := i+1) { |
| 2635 | ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-0@" & c_mgw_domain; |
| 2636 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2637 | mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2638 | ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-2@" & c_mgw_domain; |
| 2639 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2640 | mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2641 | ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-4@" & c_mgw_domain; |
| 2642 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2643 | mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2644 | ep := "ds/e1-1/s-" & int2str(i+1) & "/su16-6@" & c_mgw_domain; |
| 2645 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2646 | mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2647 | } |
| 2648 | |
| 2649 | /* Wait until the stats items have seteled and then check if we get the expected number (all) of |
| 2650 | * occupied endpoints */ |
| 2651 | f_sleep(1.0) |
| 2652 | expect := { |
| 2653 | { name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := n_e1_ts * 4, max := n_e1_ts * 4} |
| 2654 | }; |
| 2655 | f_statsd_expect(expect); |
| 2656 | |
| 2657 | /* Send wildcarded DLCX */ |
| 2658 | var template MgcpResponse rtmpl := { |
| 2659 | line := { |
| 2660 | code := "200", |
| 2661 | string := ? |
| 2662 | }, |
| 2663 | params:= { }, |
| 2664 | sdp := omit |
| 2665 | }; |
| 2666 | ep := "ds/e1-1/*@" & c_mgw_domain; |
| 2667 | cmd := ts_DLCX(get_next_trans_id(), ep); |
| 2668 | mgcp_transceive_mgw(cmd, rtmpl); |
| 2669 | |
| 2670 | /* Query a the statsd once to ensure that intermediate results are pulled from the |
| 2671 | * pipeline. The second query (below) will return the actual result. */ |
| 2672 | expect := { |
| 2673 | { name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := 0, max := n_e1_ts * 4} |
| 2674 | }; |
| 2675 | f_statsd_expect(expect); |
| 2676 | |
| 2677 | /* The second query must resturn a result with 0 endpoints in use. */ |
| 2678 | expect := { |
| 2679 | { name := "TTCN3.trunk.e1-1.common.endpoints.used", mtype := "g", min := 0, max := 0} |
| 2680 | }; |
| 2681 | f_statsd_expect(expect); |
| 2682 | |
| 2683 | setverdict(pass); |
| 2684 | } |
| 2685 | |
Pau Espin Pedrol | db2dc04 | 2020-09-07 16:30:29 +0200 | [diff] [blame] | 2686 | /* test valid CRCX then MDCX with IPv4 address, MGW provides a local IPv4 too */ |
| 2687 | testcase TC_crcx_mdcx_ip4() runs on dummy_CT { |
| 2688 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2689 | var template MgcpCommand cmd; |
| 2690 | var MgcpResponse resp; |
| 2691 | var MgcpCallId call_id := '1234'H; |
| 2692 | var MgcpConnectionId conn_id; |
| 2693 | |
| 2694 | f_init(ep); |
| 2695 | |
| 2696 | /* create the connection on the MGW */ |
| 2697 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2698 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2699 | conn_id := extract_conn_id(resp); |
| 2700 | |
| 2701 | cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, conn_id); |
| 2702 | cmd.sdp := ts_SDP("127.0.0.2", "127.0.0.1", "23", "42", 2344, { "98" }, |
| 2703 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 2704 | valueof(ts_SDP_ptime(20)) }); |
| 2705 | resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK); |
| 2706 | |
| 2707 | if (not ispresent(resp.sdp) or not ispresent(resp.sdp.connection)) { |
| 2708 | setverdict(fail, "No RemoteConnection info found in MDCX ACK!"); |
| 2709 | } |
| 2710 | if (not match(resp.sdp.connection, ts_SDP_connection_IP("127.0.0.1", "IP4"))) { |
| 2711 | setverdict(fail, "Wrong RemoteConnection in MDCX ACK!", resp.sdp.connection); |
| 2712 | } |
| 2713 | |
| 2714 | /* clean-up */ |
| 2715 | f_dlcx_ok(ep, call_id); |
| 2716 | setverdict(pass); |
| 2717 | } |
| 2718 | |
| 2719 | /* test valid CRCX then MDCX with IPv6 address, MGW provides a local IPv6 too */ |
| 2720 | testcase TC_crcx_mdcx_ip6() runs on dummy_CT { |
| 2721 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2722 | var template MgcpCommand cmd; |
| 2723 | var MgcpResponse resp; |
| 2724 | var MgcpCallId call_id := '1234'H; |
| 2725 | var MgcpConnectionId conn_id; |
| 2726 | |
| 2727 | f_init(ep); |
| 2728 | |
| 2729 | /* create the connection on the MGW */ |
| 2730 | cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id); |
| 2731 | resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK); |
| 2732 | conn_id := extract_conn_id(resp); |
| 2733 | |
| 2734 | cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, conn_id); |
| 2735 | cmd.sdp := ts_SDP("::2", "::1", "23", "42", 2344, { "98" }, |
| 2736 | { valueof(ts_SDP_rtpmap(98, "AMR/8000")), |
| 2737 | valueof(ts_SDP_ptime(20)) }); |
| 2738 | resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK); |
| 2739 | |
| 2740 | if (not ispresent(resp.sdp) or not ispresent(resp.sdp.connection)) { |
| 2741 | setverdict(fail, "No RemoteConnection info found in MDCX ACK!"); |
| 2742 | } |
| 2743 | if (not match(resp.sdp.connection, ts_SDP_connection_IP("::1", "IP6"))) { |
| 2744 | setverdict(fail, "Wrong RemoteConnection in MDCX ACK!", resp.sdp.connection); |
| 2745 | } |
| 2746 | |
| 2747 | /* clean-up */ |
| 2748 | f_dlcx_ok(ep, call_id); |
| 2749 | setverdict(pass); |
| 2750 | } |
| 2751 | |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2752 | /* create two local RTP+IuUP emulations and pass data in both directions */ |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2753 | function f_tc_two_crcx_mdcx_and_iuup(charstring local_ip_a, charstring remote_ip_a, |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 2754 | IuUP_RabFlowCombinationList rfcl_a, |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2755 | charstring local_ip_b, charstring remote_ip_b) runs on dummy_CT { |
| 2756 | var RtpFlowData flow[2]; |
| 2757 | var RtpemStats stats[2]; |
| 2758 | var MgcpResponse resp; |
| 2759 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2760 | var MgcpCallId call_id := '1227'H; |
| 2761 | var integer num_pkts_tx[2]; |
| 2762 | var integer temp; |
| 2763 | |
| 2764 | f_init(ep); |
| 2765 | |
| 2766 | /* Create the first connection in receive only mode (RNC side, IuUP-Init active) */ |
| 2767 | flow[0] := valueof(t_RtpFlow(local_ip_a, remote_ip_a, 96, "VND.3GPP.IUFP/16000")); |
| 2768 | flow[0].em.portnr := 10000; |
| 2769 | flow[0].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2770 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2771 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2772 | flow[0].rtp_cfg.iuup_mode := true; |
Pau Espin Pedrol | 6ed7630 | 2022-05-25 18:09:37 +0200 | [diff] [blame] | 2773 | flow[0].rtp_cfg.iuup_cfg.active_init := true; |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 2774 | flow[0].rtp_cfg.iuup_cfg.rab_flow_combs := rfcl_a; |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2775 | f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow[0], true); |
| 2776 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 2777 | |
| 2778 | /* Create the second connection. This connection will be also |
| 2779 | * in receive only mode (CN side, IuUP-Init passive) */ |
| 2780 | flow[1] := valueof(t_RtpFlow(local_ip_b, remote_ip_b, 96, "VND.3GPP.IUFP/16000")); |
| 2781 | flow[1].em.portnr := 20000; |
| 2782 | flow[1].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2783 | flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
| 2784 | flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2785 | flow[1].rtp_cfg.iuup_mode := true; |
Pau Espin Pedrol | 6ed7630 | 2022-05-25 18:09:37 +0200 | [diff] [blame] | 2786 | flow[1].rtp_cfg.iuup_cfg.active_init := false; |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2787 | f_flow_create(RTPEM[1], ep, call_id, "recvonly", flow[1], true); |
| 2788 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 2789 | |
| 2790 | /* The first leg starts transmitting */ |
| 2791 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 2792 | f_sleep(0.5); |
| 2793 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2794 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2795 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2796 | mtc.stop; |
| 2797 | } |
| 2798 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2799 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2800 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2801 | mtc.stop; |
| 2802 | } |
| 2803 | |
| 2804 | /* The second leg starts transmitting a little later */ |
| 2805 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 2806 | f_sleep(1.0); |
| 2807 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2808 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2809 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2810 | mtc.stop; |
| 2811 | } |
| 2812 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2813 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2814 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2815 | mtc.stop; |
| 2816 | } |
| 2817 | |
| 2818 | /* The first leg will now be switched into bidirectional |
| 2819 | * mode, but we do not expect any data coming back yet. */ |
| 2820 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2821 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2822 | num_pkts_tx[1] := stats[1].num_pkts_tx; |
| 2823 | f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2824 | f_sleep(0.5); |
| 2825 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2826 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2827 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2828 | mtc.stop; |
| 2829 | } |
| 2830 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2831 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2832 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2833 | mtc.stop; |
| 2834 | } |
| 2835 | |
| 2836 | /* When the second leg is switched into bidirectional mode |
| 2837 | * as well, then the MGW will connect the two together and |
| 2838 | * we should see RTP streams passing through from both ends. */ |
| 2839 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 2840 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2841 | num_pkts_tx[0] := stats[0].num_pkts_tx; |
| 2842 | f_flow_modify(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2843 | f_sleep(2.0); |
| 2844 | |
| 2845 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2846 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2847 | |
| 2848 | temp := stats[0].num_pkts_tx - num_pkts_tx[0] - stats[1].num_pkts_rx; |
| 2849 | if (temp > 3 or temp < -3) { |
| 2850 | setverdict(fail, "number of packets not within normal parameters:", temp); |
| 2851 | mtc.stop; |
| 2852 | } |
| 2853 | |
| 2854 | temp := stats[1].num_pkts_tx - num_pkts_tx[1] - stats[0].num_pkts_rx; |
| 2855 | if (temp > 3 or temp < -3) { |
| 2856 | setverdict(fail, "number of packets not within normal parameters:", temp); |
| 2857 | mtc.stop; |
| 2858 | } |
| 2859 | |
| 2860 | f_rtpem_stats_err_check(stats[0]); |
| 2861 | f_rtpem_stats_err_check(stats[1]); |
| 2862 | |
| 2863 | /* Tear down */ |
| 2864 | f_flow_delete(RTPEM[0]); |
| 2865 | f_flow_delete(RTPEM[1], ep, call_id); |
| 2866 | setverdict(pass); |
| 2867 | } |
| 2868 | testcase TC_two_crcx_mdcx_and_iuup() runs on dummy_CT { |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 2869 | var template (value) IuUP_RabFlowCombinationList rfcl := { |
| 2870 | t_IuUP_RFC_AMR_12_2(0), |
| 2871 | t_IuUP_RFC_AMR_SID(1), |
| 2872 | t_IuUP_RFC_AMR_NO_DATA(2) |
| 2873 | }; |
| 2874 | f_tc_two_crcx_mdcx_and_iuup(mp_local_ipv4, mp_remote_ipv4, valueof(rfcl), |
| 2875 | mp_local_ipv4, mp_remote_ipv4); |
| 2876 | } |
| 2877 | /* Same as TC_two_crcx_mdcx_and_iuup, but passing unordered RFCI list (ID != position) */ |
| 2878 | testcase TC_two_crcx_mdcx_and_iuup_rfci_unordered() runs on dummy_CT { |
| 2879 | var template (value) IuUP_RabFlowCombinationList rfcl := { |
| 2880 | t_IuUP_RFC_AMR_12_2(1), |
| 2881 | t_IuUP_RFC_AMR_SID(2), |
| 2882 | t_IuUP_RFC_AMR_NO_DATA(0) |
| 2883 | }; |
| 2884 | f_tc_two_crcx_mdcx_and_iuup(mp_local_ipv4, mp_remote_ipv4, valueof(rfcl), |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 2885 | mp_local_ipv4, mp_remote_ipv4); |
| 2886 | } |
| 2887 | |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2888 | /* create two local emulations (1 RTP, 1 RTP+IuUP) and pass data in both directions */ |
| 2889 | function f_tc_two_crcx_mdcx_and_iuup_rtp(charstring local_ip_a, charstring remote_ip_a, |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 2890 | IuUP_RabFlowCombinationList rfcl_a, |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2891 | charstring local_ip_b, charstring remote_ip_b) runs on dummy_CT { |
| 2892 | var RtpFlowData flow[2]; |
| 2893 | var RtpemStats stats[2]; |
| 2894 | var MgcpResponse resp; |
| 2895 | var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; |
| 2896 | var MgcpCallId call_id := '1227'H; |
| 2897 | var integer num_pkts_tx[2]; |
| 2898 | var integer temp; |
| 2899 | |
| 2900 | f_init(ep); |
| 2901 | |
| 2902 | /* Create the first connection in receive only mode (RNC side, IuUP-Init active) */ |
| 2903 | flow[0] := valueof(t_RtpFlow(local_ip_a, remote_ip_a, 96, "VND.3GPP.IUFP/16000")); |
| 2904 | flow[0].em.portnr := 10000; |
| 2905 | flow[0].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2906 | flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2907 | flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; |
| 2908 | flow[0].rtp_cfg.tx_payloads[0].fixed_payload := '4f28959ffeb80181f5c4e83d176c897b4a4e333298333419a493ca63ded6e0'O; |
| 2909 | /* flow[1].rtp_cfg.rx_payloads[0].fixed_payload converted AMR-BE-RTP->AMR-IUUP*/ |
| 2910 | flow[0].rtp_cfg.rx_payloads[0].fixed_payload := '08556d944c71a1a081e7ead204244480000ecd82b81118000097c4794e7740'O; |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2911 | flow[0].rtp_cfg.iuup_mode := true; |
Pau Espin Pedrol | 6ed7630 | 2022-05-25 18:09:37 +0200 | [diff] [blame] | 2912 | flow[0].rtp_cfg.iuup_cfg.active_init := true; |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 2913 | flow[0].rtp_cfg.iuup_cfg.rab_flow_combs := rfcl_a; |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2914 | f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow[0], true); |
| 2915 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); |
| 2916 | |
| 2917 | /* Create the second connection. This connection will be also |
| 2918 | * in receive only mode (CN side, regular RTP) */ |
| 2919 | flow[1] := valueof(t_RtpFlow(local_ip_b, remote_ip_b, 112, "AMR/8000")); |
| 2920 | flow[1].em.portnr := 20000; |
| 2921 | flow[1].rtp_cfg := c_RtpemDefaultCfg; |
Philipp Maier | bbe454d | 2023-03-28 15:31:57 +0200 | [diff] [blame] | 2922 | flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
| 2923 | flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt; |
| 2924 | flow[1].rtp_cfg.tx_payloads[0].fixed_payload := '0382155b65131c68682079fab4810911200003b360ae0446000025f11e539dd0'O; |
| 2925 | /* flow[0].rtp_cfg.rx_payloads[0].fixed_payload converted AMR-IuUP->AMR-BE-RTP*/ |
| 2926 | flow[1].rtp_cfg.rx_payloads[0].fixed_payload := 'f3d3ca2567ffae00607d713a0f45db225ed2938ccca60ccd066924f298f7b5b8'O; |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 2927 | flow[1].rtp_cfg.iuup_mode := false; |
| 2928 | f_flow_create(RTPEM[1], ep, call_id, "recvonly", flow[1], true); |
| 2929 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); |
| 2930 | |
| 2931 | /* The first leg starts transmitting */ |
| 2932 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); |
| 2933 | f_sleep(0.5); |
| 2934 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2935 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2936 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2937 | mtc.stop; |
| 2938 | } |
| 2939 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2940 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2941 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2942 | mtc.stop; |
| 2943 | } |
| 2944 | |
| 2945 | /* The second leg starts transmitting a little later */ |
| 2946 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); |
| 2947 | f_sleep(1.0); |
| 2948 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2949 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2950 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2951 | mtc.stop; |
| 2952 | } |
| 2953 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2954 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2955 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2956 | mtc.stop; |
| 2957 | } |
| 2958 | |
| 2959 | /* The first leg will now be switched into bidirectional |
| 2960 | * mode, but we do not expect any data coming back yet. */ |
| 2961 | f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); |
| 2962 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2963 | num_pkts_tx[1] := stats[1].num_pkts_tx; |
| 2964 | f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); |
| 2965 | f_sleep(0.5); |
| 2966 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2967 | if (stats[0].num_pkts_rx_err_disabled != 0) { |
| 2968 | setverdict(fail, "received packets from MGW on recvonly connection 0"); |
| 2969 | mtc.stop; |
| 2970 | } |
| 2971 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2972 | if (stats[1].num_pkts_rx_err_disabled != 0) { |
| 2973 | setverdict(fail, "received packets from MGW on recvonly connection 1"); |
| 2974 | mtc.stop; |
| 2975 | } |
| 2976 | |
| 2977 | /* When the second leg is switched into bidirectional mode |
| 2978 | * as well, then the MGW will connect the two together and |
| 2979 | * we should see RTP streams passing through from both ends. */ |
| 2980 | f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); |
| 2981 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2982 | num_pkts_tx[0] := stats[0].num_pkts_tx; |
| 2983 | f_flow_modify(RTPEM[1], ep, call_id, "sendrecv", flow[1]); |
| 2984 | f_sleep(2.0); |
| 2985 | |
| 2986 | stats[0] := f_rtpem_stats_get(RTPEM[0]); |
| 2987 | stats[1] := f_rtpem_stats_get(RTPEM[1]); |
| 2988 | |
| 2989 | temp := stats[0].num_pkts_tx - num_pkts_tx[0] - stats[1].num_pkts_rx; |
| 2990 | if (temp > 3 or temp < -3) { |
| 2991 | setverdict(fail, "number of packets not within normal parameters:", temp); |
| 2992 | mtc.stop; |
| 2993 | } |
| 2994 | |
| 2995 | temp := stats[1].num_pkts_tx - num_pkts_tx[1] - stats[0].num_pkts_rx; |
| 2996 | if (temp > 3 or temp < -3) { |
| 2997 | setverdict(fail, "number of packets not within normal parameters:", temp); |
| 2998 | mtc.stop; |
| 2999 | } |
| 3000 | |
| 3001 | f_rtpem_stats_err_check(stats[0]); |
| 3002 | f_rtpem_stats_err_check(stats[1]); |
| 3003 | |
| 3004 | /* Tear down */ |
| 3005 | f_flow_delete(RTPEM[0]); |
| 3006 | f_flow_delete(RTPEM[1], ep, call_id); |
| 3007 | setverdict(pass); |
| 3008 | } |
| 3009 | testcase TC_two_crcx_mdcx_and_iuup_rtp() runs on dummy_CT { |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 3010 | var template (value) IuUP_RabFlowCombinationList rfcl := { |
| 3011 | t_IuUP_RFC_AMR_12_2(0), |
| 3012 | t_IuUP_RFC_AMR_SID(1), |
| 3013 | t_IuUP_RFC_AMR_NO_DATA(2) |
| 3014 | }; |
| 3015 | f_tc_two_crcx_mdcx_and_iuup_rtp(mp_local_ipv4, mp_remote_ipv4, valueof(rfcl), |
| 3016 | mp_local_ipv4, mp_remote_ipv4); |
| 3017 | } |
| 3018 | /* Same as TC_two_crcx_mdcTC_two_crcx_mdcx_and_iuup_rtpx_and_iuup, but passing unordered RFCI list (ID != position) */ |
| 3019 | testcase TC_two_crcx_mdcx_and_iuup_rtp_rfci_unordered() runs on dummy_CT { |
| 3020 | var template (value) IuUP_RabFlowCombinationList rfcl := { |
| 3021 | t_IuUP_RFC_AMR_12_2(1), |
| 3022 | t_IuUP_RFC_AMR_SID(2), |
| 3023 | t_IuUP_RFC_AMR_NO_DATA(0) |
| 3024 | }; |
| 3025 | f_tc_two_crcx_mdcx_and_iuup_rtp(mp_local_ipv4, mp_remote_ipv4, valueof(rfcl), |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 3026 | mp_local_ipv4, mp_remote_ipv4); |
| 3027 | } |
| 3028 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 3029 | control { |
| 3030 | execute(TC_selftest()); |
Pau Espin Pedrol | b26d446 | 2023-06-15 11:38:02 +0200 | [diff] [blame] | 3031 | execute(TC_auep_null()); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 3032 | execute(TC_crcx()); |
Philipp Maier | 45635f4 | 2018-06-05 17:28:02 +0200 | [diff] [blame] | 3033 | execute(TC_crcx_no_lco()); |
Philipp Maier | bb7a01c | 2018-02-01 12:32:57 +0100 | [diff] [blame] | 3034 | execute(TC_crcx_noprefix()); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 3035 | execute(TC_crcx_unsupp_mode()); |
Pau Espin Pedrol | befd3aa | 2020-09-21 10:54:42 +0200 | [diff] [blame] | 3036 | execute(TC_crcx_osmo_ign()); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 3037 | execute(TC_crcx_early_bidir_mode()); |
| 3038 | execute(TC_crcx_unsupp_param()); |
| 3039 | execute(TC_crcx_missing_callid()); |
| 3040 | execute(TC_crcx_missing_mode()); |
| 3041 | execute(TC_crcx_unsupp_packet_intv()); |
| 3042 | execute(TC_crcx_illegal_double_lco()); |
| 3043 | execute(TC_crcx_sdp()); |
Philipp Maier | 5e06cee | 2018-02-01 18:28:08 +0100 | [diff] [blame] | 3044 | execute(TC_crcx_wildcarded()); |
| 3045 | execute(TC_crcx_wildcarded_exhaust()); |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 3046 | execute(TC_mdcx_without_crcx()); |
| 3047 | execute(TC_dlcx_without_crcx()); |
Philipp Maier | 21c1cff | 2021-07-20 14:22:53 +0200 | [diff] [blame] | 3048 | execute(TC_dlcx_non_existant_ep()); |
Philipp Maier | 8a3dc92 | 2018-02-02 14:55:12 +0100 | [diff] [blame] | 3049 | execute(TC_mdcx_wildcarded()); |
| 3050 | execute(TC_dlcx_wildcarded()); |
Harald Welte | 79181ff | 2017-11-18 19:26:11 +0100 | [diff] [blame] | 3051 | execute(TC_crcx_and_dlcx_ep_callid_connid()); |
| 3052 | execute(TC_crcx_and_dlcx_ep_callid()); |
| 3053 | execute(TC_crcx_and_dlcx_ep()); |
Harald Welte | 6d167f8 | 2017-11-18 19:41:35 +0100 | [diff] [blame] | 3054 | execute(TC_crcx_and_dlcx_ep_callid_inval()); |
| 3055 | execute(TC_crcx_and_dlcx_ep_callid_connid_inval()); |
Harald Welte | f53f164 | 2017-11-18 19:57:11 +0100 | [diff] [blame] | 3056 | execute(TC_crcx_and_dlcx_retrans()); |
Harald Welte | 33d8216 | 2017-12-28 03:21:57 +0100 | [diff] [blame] | 3057 | |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 3058 | execute(TC_crcx_osmux_wildcard()); |
| 3059 | execute(TC_crcx_osmux_fixed()); |
| 3060 | execute(TC_crcx_osmux_fixed_twice()); |
Pau Espin Pedrol | 787e2e4 | 2022-10-07 10:58:35 +0200 | [diff] [blame] | 3061 | execute(TC_crcx_osmux_257()); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 3062 | execute(TC_one_crcx_receive_only_osmux()); |
| 3063 | execute(TC_one_crcx_loopback_osmux()); |
| 3064 | execute(TC_two_crcx_and_rtp_osmux()); |
| 3065 | execute(TC_two_crcx_and_rtp_osmux_bidir()); |
Pau Espin Pedrol | 2625847 | 2022-10-25 12:51:24 +0200 | [diff] [blame] | 3066 | execute(TC_two_crcx_and_rtp_osmux_bidir_amr_bwe()); |
Pau Espin Pedrol | b2c6b38 | 2019-05-14 13:40:49 +0200 | [diff] [blame] | 3067 | execute(TC_two_crcx_mdcx_and_rtp_osmux_wildcard()); |
| 3068 | execute(TC_two_crcx_mdcx_and_rtp_osmux_fixed()); |
| 3069 | |
Harald Welte | 33d8216 | 2017-12-28 03:21:57 +0100 | [diff] [blame] | 3070 | execute(TC_crcx_dlcx_30ep()); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 3071 | |
| 3072 | execute(TC_rtpem_selftest()); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 3073 | |
| 3074 | execute(TC_one_crcx_receive_only_rtp()); |
| 3075 | execute(TC_one_crcx_loopback_rtp()); |
Philipp Maier | c0ca42d | 2021-05-17 18:41:19 +0200 | [diff] [blame] | 3076 | execute(TC_one_crcx_loopback_rtp_ipv6()); |
Harald Welte | bb7523b | 2018-03-29 08:52:01 +0200 | [diff] [blame] | 3077 | execute(TC_two_crcx_and_rtp()); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 3078 | execute(TC_two_crcx_and_rtp_bidir()); |
Philipp Maier | 7df85f6 | 2018-07-25 10:26:09 +0200 | [diff] [blame] | 3079 | execute(TC_two_crcx_diff_pt_and_rtp()); |
| 3080 | execute(TC_two_crcx_diff_pt_and_rtp_bidir()); |
Philipp Maier | 2321ef9 | 2018-06-27 17:52:04 +0200 | [diff] [blame] | 3081 | execute(TC_two_crcx_mdcx_and_rtp()); |
| 3082 | execute(TC_two_crcx_and_unsolicited_rtp()); |
| 3083 | execute(TC_two_crcx_and_one_mdcx_rtp_ho()); |
Philipp Maier | 6d4e094 | 2019-02-21 17:35:01 +0100 | [diff] [blame] | 3084 | execute(TC_ts101318_rfc5993_rtp_conversion()); |
Philipp Maier | 8ed48c5 | 2023-02-07 11:24:31 +0100 | [diff] [blame] | 3085 | execute(TC_ts101318_rfc5993_rtp_conversion_fmtp()); |
Philipp Maier | 4f764ce | 2019-03-07 10:54:10 +0100 | [diff] [blame] | 3086 | execute(TC_amr_oa_bwe_rtp_conversion()); |
| 3087 | execute(TC_amr_oa_oa_rtp_conversion()); |
| 3088 | execute(TC_amr_bwe_bwe_rtp_conversion()); |
Philipp Maier | 7148428 | 2023-04-04 18:00:53 +0200 | [diff] [blame] | 3089 | execute(TC_amr_oa_oa_no_bwe_rtp_conversion()); |
| 3090 | execute(TC_amr_oa_no_bwe_oa_rtp_conversion()); |
| 3091 | execute(TC_amr_bwe_bwe_no_oa_rtp_conversion()); |
| 3092 | execute(TC_amr_bwe_no_oa_bwe_rtp_conversion()); |
Oliver Smith | 021141e | 2019-06-25 12:09:01 +0200 | [diff] [blame] | 3093 | |
Pau Espin Pedrol | d19ba6d | 2020-01-03 20:01:48 +0100 | [diff] [blame] | 3094 | execute(TC_conn_timeout()); |
Philipp Maier | 2609c75 | 2020-07-08 12:38:09 +0200 | [diff] [blame] | 3095 | |
| 3096 | execute(TC_e1_crcx_and_dlcx_ep()); |
| 3097 | execute(TC_e1_crcx_with_overlap()); |
| 3098 | execute(TC_e1_crcx_loopback()); |
Philipp Maier | 13aff99 | 2022-06-30 16:19:59 +0200 | [diff] [blame] | 3099 | execute(TC_e1_dlcx_wildcarded()); |
Philipp Maier | 2609c75 | 2020-07-08 12:38:09 +0200 | [diff] [blame] | 3100 | |
Pau Espin Pedrol | db2dc04 | 2020-09-07 16:30:29 +0200 | [diff] [blame] | 3101 | execute(TC_crcx_mdcx_ip4()); |
| 3102 | execute(TC_crcx_mdcx_ip6()); |
Pau Espin Pedrol | 9e0141a | 2020-09-07 17:25:56 +0200 | [diff] [blame] | 3103 | execute(TC_two_crcx_mdcx_and_rtp_ipv4_ipv6()); |
| 3104 | execute(TC_two_crcx_mdcx_and_rtp_ipv6()); |
| 3105 | execute(TC_two_crcx_and_rtp_osmux_bidir_ipv6()); |
| 3106 | execute(TC_two_crcx_and_rtp_osmux_bidir_ipv4_ipv6()); |
| 3107 | execute(TC_two_crcx_and_rtp_osmux_bidir_ipv6_ipv4()); |
| 3108 | execute(TC_two_crcx_mdcx_and_rtp_osmux_ipv6()); |
| 3109 | execute(TC_two_crcx_mdcx_and_rtp_osmux_ipv4_ipv6()); |
| 3110 | execute(TC_two_crcx_mdcx_and_rtp_osmux_ipv6_ipv4()); |
Philipp Maier | 3796508 | 2021-05-25 16:44:25 +0200 | [diff] [blame] | 3111 | |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 3112 | execute(TC_two_crcx_mdcx_and_iuup()); |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 3113 | execute(TC_two_crcx_mdcx_and_iuup_rfci_unordered()); |
Pau Espin Pedrol | 2803cd3 | 2022-01-10 18:44:32 +0100 | [diff] [blame] | 3114 | execute(TC_two_crcx_mdcx_and_iuup_rtp()); |
Pau Espin Pedrol | d7963bb | 2022-05-25 18:19:52 +0200 | [diff] [blame] | 3115 | execute(TC_two_crcx_mdcx_and_iuup_rtp_rfci_unordered()); |
Pau Espin Pedrol | a6b9c4c | 2021-12-24 13:50:26 +0100 | [diff] [blame] | 3116 | |
Oliver Smith | 871f45a | 2023-01-24 16:21:50 +0100 | [diff] [blame] | 3117 | execute(TC_two_crcx_mdcx_and_rtp_clearmode()); |
| 3118 | |
Philipp Maier | 3796508 | 2021-05-25 16:44:25 +0200 | [diff] [blame] | 3119 | /* Note: This testcase will trigger an OSMO_ASSERT() bug in |
| 3120 | * older versions of osmo-mgw. This eventually leads into |
| 3121 | * a failure of all subsequent testcases, so it is important |
| 3122 | * not to add new testcaes after this one. */ |
| 3123 | execute(TC_one_crcx_loopback_rtp_implicit()); |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 3124 | } |
| 3125 | } |