neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/34539?usp=email )
Change subject: mgw: add f_TC_amr_switch_to_iuup ......................................................................
mgw: add f_TC_amr_switch_to_iuup
Change-Id: I08eca9ea123029c37892d5de7c94a8ed6cc0a913 --- M mgw/MGCP_Test.ttcn 1 file changed, 160 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/39/34539/1
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn index 73591b2..ca6e520 100644 --- a/mgw/MGCP_Test.ttcn +++ b/mgw/MGCP_Test.ttcn @@ -3078,6 +3078,155 @@ mp_local_ipv4, mp_remote_ipv4); }
+ function f_tc_amr_switch_to_iuup(charstring local_ip_a, charstring remote_ip_a, + IuUP_RabFlowCombinationList rfcl_a, + charstring local_ip_b, charstring remote_ip_b) runs on dummy_CT { + var RtpFlowData flow[2]; + var RtpemStats stats[2]; + var MgcpResponse resp; + var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain; + var MgcpCallId call_id := '1227'H; + var integer num_pkts_tx[2]; + var integer temp; + + f_init(ep); + + /* Create the first connection in receive only mode (RNC side, IuUP-Init active) */ + flow[0] := valueof(t_RtpFlow(local_ip_a, remote_ip_a, 96, "VND.3GPP.IUFP/16000")); + flow[0].em.portnr := 10000; + flow[0].rtp_cfg := c_RtpemDefaultCfg; + flow[0].rtp_cfg.tx_payloads[0].payload_type := flow[0].codec_descr[0].pt; + flow[0].rtp_cfg.rx_payloads[0].payload_type := flow[0].codec_descr[0].pt; + flow[0].rtp_cfg.tx_payloads[0].fixed_payload := '4f28959ffeb80181f5c4e83d176c897b4a4e333298333419a493ca63ded6e0'O; + /* flow[1].rtp_cfg.rx_payloads[0].fixed_payload converted AMR-BE-RTP->AMR-IUUP*/ + flow[0].rtp_cfg.rx_payloads[0].fixed_payload := '08556d944c71a1a081e7ead204244480000ecd82b81118000097c4794e7740'O; + flow[0].rtp_cfg.iuup_mode := true; + flow[0].rtp_cfg.iuup_cfg.active_init := true; + flow[0].rtp_cfg.iuup_cfg.rab_flow_combs := rfcl_a; + f_flow_create(RTPEM[0], ep, call_id, "recvonly", flow[0], true); + f_rtpem_mode(RTPEM[0], RTPEM_MODE_RXONLY); + + /* Create the second connection. This connection will be also + * in receive only mode (CN side, regular RTP) */ + flow[1] := valueof(t_RtpFlow(local_ip_b, remote_ip_b, 112, "AMR/8000")); + flow[1].em.portnr := 20000; + flow[1].rtp_cfg := c_RtpemDefaultCfg; + flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt; + flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt; + flow[1].rtp_cfg.tx_payloads[0].fixed_payload := '0382155b65131c68682079fab4810911200003b360ae0446000025f11e539dd0'O; + /* flow[0].rtp_cfg.rx_payloads[0].fixed_payload converted AMR-IuUP->AMR-BE-RTP*/ + flow[1].rtp_cfg.rx_payloads[0].fixed_payload := 'f3d3ca2567ffae00607d713a0f45db225ed2938ccca60ccd066924f298f7b5b8'O; + flow[1].rtp_cfg.iuup_mode := false; + f_flow_create(RTPEM[1], ep, call_id, "recvonly", flow[1], true); + f_rtpem_mode(RTPEM[1], RTPEM_MODE_RXONLY); + + /* The first leg starts transmitting */ + f_rtpem_mode(RTPEM[0], RTPEM_MODE_TXONLY); + f_sleep(0.5); + stats[0] := f_rtpem_stats_get(RTPEM[0]); + if (stats[0].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 0"); + mtc.stop; + } + stats[1] := f_rtpem_stats_get(RTPEM[1]); + if (stats[1].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 1"); + mtc.stop; + } + + /* The second leg starts transmitting a little later */ + f_rtpem_mode(RTPEM[1], RTPEM_MODE_TXONLY); + f_sleep(1.0); + stats[0] := f_rtpem_stats_get(RTPEM[0]); + if (stats[0].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 0"); + mtc.stop; + } + stats[1] := f_rtpem_stats_get(RTPEM[1]); + if (stats[1].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 1"); + mtc.stop; + } + + /* The first leg will now be switched into bidirectional + * mode, but we do not expect any data coming back yet. */ + f_rtpem_mode(RTPEM[0], RTPEM_MODE_BIDIR); + stats[1] := f_rtpem_stats_get(RTPEM[1]); + num_pkts_tx[1] := stats[1].num_pkts_tx; + f_flow_modify(RTPEM[0], ep, call_id, "sendrecv", flow[0]); + f_sleep(0.5); + stats[0] := f_rtpem_stats_get(RTPEM[0]); + if (stats[0].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 0"); + mtc.stop; + } + stats[1] := f_rtpem_stats_get(RTPEM[1]); + if (stats[1].num_pkts_rx_err_disabled != 0) { + setverdict(fail, "received packets from MGW on recvonly connection 1"); + mtc.stop; + } + + /* When the second leg is switched into bidirectional mode + * as well, then the MGW will connect the two together and + * we should see RTP streams passing through from both ends. */ + f_rtpem_mode(RTPEM[1], RTPEM_MODE_BIDIR); + stats[0] := f_rtpem_stats_get(RTPEM[0]); + num_pkts_tx[0] := stats[0].num_pkts_tx; + f_flow_modify(RTPEM[1], ep, call_id, "sendrecv", flow[1]); + f_sleep(2.0); + + stats[0] := f_rtpem_stats_get(RTPEM[0]); + stats[1] := f_rtpem_stats_get(RTPEM[1]); + + temp := stats[0].num_pkts_tx - num_pkts_tx[0] - stats[1].num_pkts_rx; + if (temp > 3 or temp < -3) { + setverdict(fail, "number of packets not within normal parameters:", temp); + mtc.stop; + } + + temp := stats[1].num_pkts_tx - num_pkts_tx[1] - stats[0].num_pkts_rx; + if (temp > 3 or temp < -3) { + setverdict(fail, "number of packets not within normal parameters:", temp); + mtc.stop; + } + + f_rtpem_stats_err_check(stats[0]); + f_rtpem_stats_err_check(stats[1]); + + /* Modify the AMR side to also do IuUP */ + flow[1].codec_descr := {{ + pt := 96, + codec := "VND.3GPP.IUFP/16000", + fmtp := omit + }}; + flow[1].rtp_cfg.iuup_mode := true; /* <-- does it work to switch this on with f_flow_modify()? */ + flow[1].rtp_cfg.iuup_cfg.active_init := false; + flow[1].rtp_cfg.iuup_cfg.rab_flow_combs := rfcl_a; + flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt; + flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt; + f_flow_modify(RTPEM[1], ep, call_id, "sendrecv", flow[1]); + + // ... now what + // want to verify that the RTP packets switched from AMR to IuUP, + // and that an IuUP Initialization happened by initiative of osmo-mgw. + // In the pcap, I see a switch to IuUP without Initialization, and then invalid IuUP PDUs being + // forwarded out of flow[1] (wireshark: "Unknown PDU Type(15)"). + f_sleep(3.0); + + /* Tear down */ + f_flow_delete(RTPEM[0]); + f_flow_delete(RTPEM[1], ep, call_id); + setverdict(pass); + } + testcase TC_amr_switch_to_iuup() runs on dummy_CT { + var template (value) IuUP_RabFlowCombinationList rfcl := { + t_IuUP_RFC_AMR_12_2(0), + t_IuUP_RFC_AMR_SID(1), + t_IuUP_RFC_AMR_NO_DATA(2) + }; + f_tc_amr_switch_to_iuup(mp_local_ipv4, mp_remote_ipv4, valueof(rfcl), + mp_local_ipv4, mp_remote_ipv4); + } control { execute(TC_selftest()); execute(TC_auep_null()); @@ -3167,6 +3316,8 @@ execute(TC_two_crcx_mdcx_and_iuup_rtp()); execute(TC_two_crcx_mdcx_and_iuup_rtp_rfci_unordered());
+ execute(TC_amr_switch_to_iuup()); + execute(TC_two_crcx_mdcx_and_rtp_clearmode());
/* Note: This testcase will trigger an OSMO_ASSERT() bug in