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