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