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