Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1 | module BSC_Tests { |
| 2 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 3 | /* Integration Tests for OsmoBSC |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 4 | * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This test suite tests OsmoBSC while emulating both multiple BTS + MS as |
| 11 | * well as the MSC. See README for more details. |
| 12 | * |
| 13 | * There are test cases that run in so-called 'handler mode' and test cases |
| 14 | * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode" |
| 15 | * tests abstract the multiplexing/demultiplexing of multiple SCCP connections |
| 16 | * and/or RSL channels and are hence suitable for higher-level test cases, while |
| 17 | * the "raw" tests directly on top of the CodecPorts are more suitable for lower- |
| 18 | * level testing. |
| 19 | */ |
| 20 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 21 | import from General_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 22 | import from Osmocom_Types all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 23 | import from GSM_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 24 | import from IPL4asp_Types all; |
| 25 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 26 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 27 | import from RAN_Adapter all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 28 | import from BSSAP_CodecPort all; |
| 29 | import from BSSMAP_Templates all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 30 | import from IPA_Emulation all; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 31 | import from IPA_CodecPort all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 32 | import from IPA_Types all; |
Stefan Sperling | 0796a82 | 2018-10-05 13:01:39 +0200 | [diff] [blame] | 33 | import from IPA_Testing all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 34 | import from RSL_Types all; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 35 | import from RSL_Emulation all; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 36 | import from MGCP_Emulation all; |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 37 | import from MGCP_Templates all; |
| 38 | import from MGCP_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 39 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 40 | import from Osmocom_CTRL_Functions all; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 41 | import from Osmocom_CTRL_Types all; |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 42 | import from Osmocom_CTRL_Adapter all; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 43 | |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 44 | import from Osmocom_VTY_Functions all; |
| 45 | import from TELNETasp_PortType all; |
| 46 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 47 | import from MobileL3_CommonIE_Types all; |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 48 | import from MobileL3_Types all; |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 49 | import from MobileL3_RRM_Types all; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 50 | import from L3_Templates all; |
| 51 | import from GSM_RR_Types all; |
| 52 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 53 | import from SCCP_Templates all; |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 54 | import from BSSMAP_Templates all; |
| 55 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 56 | import from SCCPasp_Types all; |
| 57 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 58 | const integer NUM_BTS := 3; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 59 | const float T3101_MAX := 12.0; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 60 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 61 | /* make sure to sync this with the osmo-bts.cfg you're using */ |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 62 | const integer NUM_TCHH_PER_BTS := 2; |
| 63 | const integer NUM_TCHF_PER_BTS := 4; |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 64 | const integer NUM_SDCCH_PER_BTS := 4; |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 65 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 66 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 67 | /* per-BTS state which we keep */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 68 | type record BTS_State { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 69 | /* component reference to the IPA_Client component used for RSL */ |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 70 | IPA_Client rsl |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 73 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 74 | /* Array of per-BTS state */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 75 | var BTS_State bts[NUM_BTS]; |
Harald Welte | 89ab191 | 2018-02-23 18:56:29 +0100 | [diff] [blame] | 76 | /* RSL common Channel Port (for RSL_Emulation) */ |
| 77 | port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS]; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 78 | /* array of per-BTS RSL test ports */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 79 | port IPA_RSL_PT IPA_RSL[NUM_BTS]; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 80 | port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */ |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 81 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 82 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 83 | port TELNETasp_PT BSCVTY; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 84 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 85 | var RAN_Adapter g_bssap; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 86 | /* for old legacy-tests only */ |
| 87 | port BSSAP_CODEC_PT BSSAP; |
| 88 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 89 | /* are we initialized yet */ |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 90 | var boolean g_initialized := false; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 91 | |
| 92 | /* global test case guard timer */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 93 | timer T_guard := 30.0; |
| 94 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | modulepar { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 98 | /* IP address at which the BSC can be reached */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 99 | charstring mp_bsc_ip := "127.0.0.1"; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 100 | /* port number to which to establish the IPA OML connections */ |
| 101 | integer mp_bsc_oml_port := 3002; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 102 | /* port number to which to establish the IPA RSL connections */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 103 | integer mp_bsc_rsl_port := 3003; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 104 | /* port number to which to establish the IPA CTRL connection */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 105 | integer mp_bsc_ctrl_port := 4249; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 106 | /* IP address at which the test binds */ |
| 107 | charstring mp_test_ip := "127.0.0.1"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 108 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 109 | RAN_Configuration mp_bssap_cfg := { |
Harald Welte | 7ef51aa | 2018-04-16 19:16:01 +0200 | [diff] [blame] | 110 | transport := BSSAP_TRANSPORT_AoIP, |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 111 | sccp_service_type := "mtp3_itu", |
| 112 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 113 | own_pc := 185, |
| 114 | own_ssn := 254, |
| 115 | peer_pc := 187, |
| 116 | peer_ssn := 254, |
Philipp Maier | 38d6894 | 2018-03-29 15:38:09 +0200 | [diff] [blame] | 117 | sio := '83'O, |
| 118 | rctx := 0 |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 119 | }; |
| 120 | } |
| 121 | |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 122 | private function f_gen_test_hdlr_pars() return TestHdlrParams { |
| 123 | |
| 124 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 125 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 126 | pars.aoip := true; |
| 127 | } else { |
| 128 | pars.aoip := false; |
| 129 | } |
| 130 | |
| 131 | return pars; |
| 132 | } |
| 133 | |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 134 | private function f_shutdown_helper() runs on test_CT { |
Daniel Willmann | 637ef6c | 2018-07-25 10:49:09 +0200 | [diff] [blame] | 135 | all component.stop; |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 136 | setverdict(pass); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 137 | mtc.stop; |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 140 | private function f_legacy_bssap_reset() runs on test_CT { |
| 141 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 142 | timer T := 5.0; |
| 143 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0))); |
| 144 | T.start; |
| 145 | alt { |
| 146 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { |
| 147 | log("Received RESET-ACK in response to RESET, we're ready to go!"); |
| 148 | } |
| 149 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 150 | log("Respoding to inbound RESET with RESET-ACK"); |
| 151 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 152 | ts_BSSMAP_ResetAck)); |
| 153 | repeat; |
| 154 | } |
| 155 | [] BSSAP.receive { repeat; } |
| 156 | [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); } |
| 157 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 158 | } |
| 159 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 160 | type record IPA_Client { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 161 | /* IPA Emulation component reference */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 162 | IPA_Emulation_CT vc_IPA, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 163 | /* Unit-ID and other CCM parameters to use for IPA client emulation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 164 | IPA_CCM_Parameters ccm_pars, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 165 | /* String identifier for this IPA Client */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 166 | charstring id, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 167 | /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 168 | RSL_Emulation_CT vc_RSL optional |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 169 | } |
| 170 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 171 | /*! Start the IPA/RSL related bits for one IPA_Client. |
| 172 | * \param clnt IPA_Client for which to establish |
| 173 | * \param bsc_host IP address / hostname of the BSC |
| 174 | * \param bsc_port TCP port number of the BSC |
| 175 | * \param i number identifying this BTS |
| 176 | * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 177 | function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i, |
| 178 | boolean handler_mode := false) |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 179 | runs on test_CT { |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 180 | timer T := 10.0; |
| 181 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 182 | clnt.id := "IPA" & int2str(i) & "-RSL"; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 183 | clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA"); |
| 184 | clnt.ccm_pars := c_IPA_default_ccm_pars; |
| 185 | clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 186 | clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0"; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 187 | if (handler_mode) { |
| 188 | clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL"); |
Harald Welte | 89ab191 | 2018-02-23 18:56:29 +0100 | [diff] [blame] | 189 | connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 190 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 191 | |
| 192 | map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 193 | if (handler_mode) { |
| 194 | connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT); |
| 195 | } else { |
| 196 | connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]); |
| 197 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 198 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 199 | clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars)); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 200 | if (handler_mode) { |
| 201 | clnt.vc_RSL.start(RSL_Emulation.main()); |
| 202 | return; |
| 203 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 204 | |
| 205 | /* wait for IPA RSL link to connect and send ID ACK */ |
| 206 | T.start; |
| 207 | alt { |
| 208 | [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) { |
| 209 | T.stop; |
| 210 | IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23))); |
| 211 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 212 | [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 213 | [] IPA_RSL[i].receive { repeat } |
| 214 | [] T.timeout { |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 215 | setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 216 | mtc.stop; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
Harald Welte | 1205547 | 2018-03-17 20:10:08 +0100 | [diff] [blame] | 221 | function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT { |
| 222 | if (not isbound(clnt) or not isbound(clnt.vc_IPA)) { |
| 223 | return; |
| 224 | } |
| 225 | clnt.vc_IPA.stop; |
| 226 | if (isbound(clnt.vc_RSL)) { |
| 227 | clnt.vc_RSL.stop; |
| 228 | } |
| 229 | } |
| 230 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 231 | /* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */ |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 232 | function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT { |
| 233 | timer T := secs_max; |
| 234 | T.start; |
| 235 | while (true) { |
| 236 | if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) { |
| 237 | T.stop; |
Harald Welte | bd868bd | 2017-12-10 18:28:40 +0100 | [diff] [blame] | 238 | /* the 'degraded' state exists from OML connection time, and we have to wait |
| 239 | * until all MO's are initialized */ |
| 240 | T.start(1.0); |
| 241 | T.timeout; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 242 | return; |
| 243 | } |
Harald Welte | f0d6ac6 | 2017-12-17 17:02:21 +0100 | [diff] [blame] | 244 | f_sleep(0.1); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 245 | if (not T.running) { |
Max | 9925390 | 2018-11-16 17:57:39 +0100 | [diff] [blame] | 246 | setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 247 | mtc.stop; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 252 | /* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 253 | altstep as_Tguard() runs on test_CT { |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 254 | var BSSAP_N_UNITDATA_ind ud_ind; |
Neels Hofmeyr | cc3f76a | 2018-03-12 01:43:25 +0100 | [diff] [blame] | 255 | [] T_guard.timeout { |
| 256 | setverdict(fail, "Timeout of T_guard"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 257 | mtc.stop; |
Neels Hofmeyr | cc3f76a | 2018-03-12 01:43:25 +0100 | [diff] [blame] | 258 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 259 | /* always respond with RESET ACK to RESET */ |
| 260 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 261 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 262 | ts_BSSMAP_ResetAck)); |
Harald Welte | 69c1c26 | 2017-12-13 21:02:08 +0100 | [diff] [blame] | 263 | repeat; |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 264 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 267 | altstep no_bssmap_reset() runs on test_CT { |
| 268 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
| 269 | setverdict(fail, "unexpected BSSMAP Reset"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 270 | mtc.stop; |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 274 | function f_init_mgcp(charstring id) runs on test_CT { |
| 275 | id := id & "-MGCP"; |
| 276 | |
| 277 | var MGCPOps ops := { |
| 278 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 279 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 280 | }; |
| 281 | var MGCP_conn_parameters mgcp_pars := { |
| 282 | callagent_ip := mp_bsc_ip, |
Harald Welte | 9e4273e | 2018-01-29 22:01:22 +0100 | [diff] [blame] | 283 | callagent_udp_port := -1, |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 284 | mgw_ip := mp_test_ip, |
| 285 | mgw_udp_port := 2427 |
| 286 | }; |
| 287 | |
| 288 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 289 | vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id)); |
| 290 | } |
| 291 | |
Max | 2253c0b | 2018-11-06 19:28:05 +0100 | [diff] [blame] | 292 | function f_init_vty(charstring id := "foo") runs on test_CT { |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 293 | if (BSCVTY.checkstate("Mapped")) { |
| 294 | /* skip initialization if already executed once */ |
| 295 | return; |
| 296 | } |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 297 | map(self:BSCVTY, system:BSCVTY); |
| 298 | f_vty_set_prompts(BSCVTY); |
| 299 | f_vty_transceive(BSCVTY, "enable"); |
| 300 | } |
| 301 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 302 | /* global initialization function |
| 303 | * \param nr_bts Number of BTSs we should start/bring up |
| 304 | * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */ |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 305 | function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false) runs on test_CT { |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 306 | var integer i; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 307 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 308 | if (g_initialized) { |
| 309 | return; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 310 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 311 | g_initialized := true; |
| 312 | |
Daniel Willmann | e68f927 | 2018-11-27 15:15:28 +0100 | [diff] [blame] | 313 | T_guard.start; |
| 314 | activate(as_Tguard()); |
| 315 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 316 | /* Call a function of our 'parent component' RAN_Adapter_CT to start the |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 317 | * MSC-side BSSAP emulation */ |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 318 | if (handler_mode) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 319 | f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_RanOps); |
Harald Welte | 4bcbd17 | 2018-05-27 19:47:44 +0200 | [diff] [blame] | 320 | f_bssap_start(g_bssap); |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 321 | } else { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 322 | f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit); |
| 323 | connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT); |
Harald Welte | 4bcbd17 | 2018-05-27 19:47:44 +0200 | [diff] [blame] | 324 | f_bssap_start(g_bssap); |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 325 | f_legacy_bssap_reset(); |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 326 | } |
Harald Welte | d5833a8 | 2018-05-27 16:52:56 +0200 | [diff] [blame] | 327 | |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 328 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 329 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 330 | f_init_mgcp("VirtMSC"); |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 331 | f_init_vty("VirtMSC"); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 332 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 333 | for (i := 0; i < nr_bts; i := i+1) { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 334 | /* wait until osmo-bts-omldummy has respawned */ |
| 335 | f_wait_oml(i, "degraded", 5.0); |
| 336 | /* start RSL connection */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 337 | f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i, handler_mode); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 338 | /* wait until BSC tells us "connected" */ |
| 339 | f_wait_oml(i, "connected", 5.0); |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 340 | } |
| 341 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 342 | } |
| 343 | |
Max | d4e5696 | 2018-10-31 19:08:25 +0100 | [diff] [blame] | 344 | /* expect to receive a RSL message matching a specified template on a given BTS / stream */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 345 | function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 346 | runs on test_CT return RSL_Message { |
| 347 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 348 | timer T := t_secs; |
| 349 | |
| 350 | T.start; |
| 351 | alt { |
| 352 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud { |
| 353 | T.stop; |
| 354 | } |
| 355 | [] IPA_RSL[bts_nr].receive { repeat; } |
Harald Welte | b291770 | 2017-12-10 15:48:52 +0100 | [diff] [blame] | 356 | [] T.timeout { |
| 357 | setverdict(fail, "Timeout expecting ", t_rx); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 358 | mtc.stop; |
Harald Welte | b291770 | 2017-12-10 15:48:52 +0100 | [diff] [blame] | 359 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 360 | } |
| 361 | return rx_rsl_ud.rsl; |
| 362 | } |
| 363 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 364 | /* helper function to transmit RSL on a given BTS/stream */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 365 | function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 366 | runs on test_CT { |
| 367 | IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx)); |
| 368 | } |
| 369 | |
| 370 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 371 | /* verify we get a CHAN_ACT after CHAN RQD */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 372 | testcase TC_chan_act_noreply() runs on test_CT { |
| 373 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 374 | var RSL_Message rsl_unused; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 375 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 376 | f_init(1); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 377 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 378 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 379 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 380 | setverdict(pass); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 381 | } |
| 382 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 383 | /* verify if the "chreq:total" counter increments as expected */ |
| 384 | testcase TC_chan_act_counter() runs on test_CT { |
| 385 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 386 | var integer chreq_total; |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 387 | var RSL_Message rsl_unused; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 388 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 389 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 390 | |
| 391 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 392 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 393 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 394 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1); |
| 395 | |
| 396 | setverdict(pass); |
| 397 | } |
| 398 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 399 | /* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */ |
| 400 | testcase TC_chan_act_ack_noest() runs on test_CT { |
| 401 | var RSL_Message rx_rsl; |
| 402 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 403 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 404 | |
| 405 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 406 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 407 | |
| 408 | /* expect BSC to disable the channel again if there's no RLL EST IND */ |
| 409 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 410 | |
| 411 | setverdict(pass); |
| 412 | } |
| 413 | |
| 414 | /* Test behavior if MSC never answers to CR */ |
| 415 | testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT { |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 416 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 417 | var IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 418 | var RSL_Message rx_rsl; |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 419 | var ASP_RSL_Unitdata rx_rsl_ud; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 420 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 421 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 422 | |
| 423 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 424 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 425 | |
| 426 | var octetstring l3 := '00010203040506'O |
| 427 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 428 | |
| 429 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))); |
| 430 | |
| 431 | /* expect BSC to disable the channel again if there's no response from MSC */ |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 432 | /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */ |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 433 | f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 434 | setverdict(pass); |
| 435 | } |
| 436 | |
| 437 | /* Test behavior if MSC answers with CREF to CR */ |
| 438 | testcase TC_chan_act_ack_est_ind_refused() runs on test_CT { |
| 439 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 440 | var RSL_Message rx_rsl; |
| 441 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 442 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 443 | |
| 444 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 445 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 446 | |
| 447 | var octetstring l3 := '00010203040506'O |
| 448 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 449 | |
| 450 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 451 | BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0)); |
| 452 | |
| 453 | /* expect BSC to disable the channel */ |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 454 | f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 455 | setverdict(pass); |
| 456 | } |
| 457 | |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 458 | /* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */ |
| 459 | testcase TC_chan_act_nack() runs on test_CT { |
| 460 | var RSL_Message rx_rsl; |
| 461 | var integer chact_nack; |
| 462 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 463 | f_init(1); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 464 | |
| 465 | chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack"); |
| 466 | |
| 467 | f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33)); |
| 468 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 469 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 470 | |
| 471 | f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL)); |
| 472 | |
| 473 | /* wait for some time to hope the NACK arrives before the CTRL GET below */ |
| 474 | f_sleep(0.5); |
| 475 | |
| 476 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1); |
| 477 | |
| 478 | setverdict(pass); |
| 479 | } |
| 480 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 481 | /* Test for channel exhaustion due to RACH overload */ |
| 482 | testcase TC_chan_exhaustion() runs on test_CT { |
| 483 | var ASP_RSL_Unitdata rsl_ud; |
| 484 | var integer i; |
| 485 | var integer chreq_total, chreq_nochan; |
| 486 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 487 | f_init(1); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 488 | |
| 489 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 490 | chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel"); |
| 491 | |
Pau Espin Pedrol | fe200d7 | 2018-12-10 12:41:04 +0100 | [diff] [blame] | 492 | /* GSM 04.08 Table 9.9a: |
| 493 | * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F"). |
| 494 | * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */ |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 495 | for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) { |
Pau Espin Pedrol | fe200d7 | 2018-12-10 12:41:04 +0100 | [diff] [blame] | 496 | var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | IPA_RSL[0].clear; |
| 500 | |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 501 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 502 | chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 503 | |
| 504 | /* now expect additional channel activations to fail */ |
| 505 | f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42)); |
| 506 | |
| 507 | alt { |
| 508 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 509 | tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) { |
| 510 | setverdict(fail, "Received CHAN ACT ACK without resources?!?"); |
| 511 | } |
| 512 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud { |
| 513 | var GsmRrMessage rr; |
| 514 | /* match on IMM ASS REJ */ |
| 515 | rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload); |
| 516 | if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) { |
| 517 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 518 | chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 519 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel", |
| 520 | chreq_nochan+1); |
| 521 | setverdict(pass); |
| 522 | } else { |
| 523 | repeat; |
| 524 | } |
| 525 | } |
| 526 | [] IPA_RSL[0].receive { repeat; } |
| 527 | } |
| 528 | } |
| 529 | |
Vadim Yanitskiy | 1ff1fdf | 2018-11-27 01:32:57 +0700 | [diff] [blame] | 530 | /* Test channel deactivation due to silence from MS */ |
| 531 | testcase TC_chan_deact_silence() runs on test_CT { |
| 532 | var RslChannelNr chan_nr; |
| 533 | |
| 534 | f_init(1); |
| 535 | |
| 536 | /* Request for a dedicated channel */ |
| 537 | chan_nr := f_chreq_act_ack('23'O); |
| 538 | |
| 539 | /* Wait some time until the channel is released */ |
| 540 | f_sleep(2.0); |
| 541 | |
| 542 | /* Expect CHANnel RELease */ |
| 543 | alt { |
| 544 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 545 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 546 | log("Received CHANnel RELease"); |
| 547 | setverdict(pass); |
| 548 | } |
| 549 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 550 | tr_RSL_IMM_ASSIGN(?))) { |
| 551 | /* See OS#3709, OsmoBSC should not send Immediate |
| 552 | * Assignment Reject since a dedicated channel was |
| 553 | * already allocated, and Immediate Assignment was |
| 554 | * already sent. */ |
| 555 | setverdict(fail, "Unexpected Immediate Assignment!"); |
| 556 | } |
| 557 | [] IPA_RSL[0].receive { |
| 558 | setverdict(fail, "Unexpected RSL message!"); |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 563 | /*********************************************************************** |
| 564 | * Assignment Testing |
| 565 | ***********************************************************************/ |
| 566 | |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 567 | /* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction, |
| 568 | * except for the inter-BSC handover, MT side) */ |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 569 | testcase TC_outbound_connect() runs on test_CT { |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 570 | f_init(1); |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 571 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 572 | BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, 2342, ts_BSSMAP_AssignmentReq)); |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 573 | BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?)); |
| 574 | setverdict(pass); |
| 575 | } |
| 576 | |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 577 | /* Test behavior if MSC answers with CREF to CR */ |
| 578 | testcase TC_assignment_cic_only() runs on test_CT { |
| 579 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 580 | var RSL_Message rx_rsl; |
| 581 | var DchanTuple dt; |
| 582 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 583 | f_init(1); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 584 | |
| 585 | dt := f_est_dchan('23'O, 23, '00000000'O); |
Harald Welte | 17b27da | 2018-05-25 20:33:53 +0200 | [diff] [blame] | 586 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 587 | /* send assignment without AoIP IEs */ |
| 588 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1)))); |
| 589 | } else { |
| 590 | /* Send assignmetn without CIC in IPA case */ |
| 591 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 592 | valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 593 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla))); |
| 594 | } |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 595 | alt { |
| 596 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 597 | setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE"); |
| 598 | } |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 599 | /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 600 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 601 | setverdict(pass); |
| 602 | } |
| 603 | [] BSSAP.receive { repeat; } |
| 604 | } |
| 605 | } |
| 606 | |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 607 | /* generate an assignment request for either AoIP or SCCPlite */ |
Harald Welte | e102eae | 2018-05-31 21:03:47 +0200 | [diff] [blame] | 608 | function f_gen_ass_req() return PDU_BSSAP { |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 609 | var PDU_BSSAP ass_cmd; |
| 610 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 611 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 612 | valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 613 | ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 614 | } else { |
| 615 | var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1)); |
| 616 | ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit)); |
| 617 | } |
| 618 | return ass_cmd; |
| 619 | } |
| 620 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 621 | function f_gen_handover_req() return PDU_BSSAP { |
| 622 | var PDU_BSSAP ho_req; |
| 623 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 624 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 625 | valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 626 | ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla)); |
| 627 | } else { |
| 628 | var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1)); |
| 629 | ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit)); |
| 630 | } |
| 631 | return ho_req; |
| 632 | } |
| 633 | |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 634 | /* generate an assignment complete template for either AoIP or SCCPlite */ |
Harald Welte | e102eae | 2018-05-31 21:03:47 +0200 | [diff] [blame] | 635 | function f_gen_exp_compl() return template PDU_BSSAP { |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 636 | var template PDU_BSSAP exp_compl; |
| 637 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 638 | exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 639 | } else { |
| 640 | /* CIC is optional "*" as the MSC allocated it */ |
| 641 | exp_compl := tr_BSSMAP_AssignmentComplete(*, omit); |
| 642 | } |
| 643 | return exp_compl; |
| 644 | } |
| 645 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 646 | /* Run everything required up to sending a caller-specified assignment command and expect response */ |
| 647 | function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text) |
| 648 | runs on test_CT { |
| 649 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 650 | var RSL_Message rx_rsl; |
| 651 | var DchanTuple dt; |
| 652 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 653 | f_init(1); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 654 | |
| 655 | dt := f_est_dchan('23'O, 23, '00000000'O); |
| 656 | /* send assignment without AoIP IEs */ |
| 657 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd)); |
| 658 | alt { |
| 659 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 660 | if (ischosen(exp.pdu.bssmap.assignmentComplete)) { |
| 661 | setverdict(pass); |
| 662 | } else { |
| 663 | setverdict(fail, fail_text); |
| 664 | } |
| 665 | } |
| 666 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 667 | if (ischosen(exp.pdu.bssmap.assignmentFailure)) { |
| 668 | setverdict(pass); |
| 669 | } else { |
| 670 | setverdict(fail, fail_text); |
| 671 | } |
| 672 | } |
| 673 | [] BSSAP.receive { repeat; } |
| 674 | } |
| 675 | } |
| 676 | testcase TC_assignment_csd() runs on test_CT { |
| 677 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 678 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 679 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD); |
| 680 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 681 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD"); |
| 682 | } |
| 683 | |
| 684 | testcase TC_assignment_ctm() runs on test_CT { |
| 685 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 686 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 687 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM); |
| 688 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 689 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM"); |
| 690 | } |
| 691 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 692 | type record DchanTuple { |
| 693 | integer sccp_conn_id, |
| 694 | RslChannelNr rsl_chan_nr |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 695 | } |
| 696 | |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 697 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 698 | private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23) |
| 699 | runs on test_CT return RslChannelNr { |
| 700 | var RSL_Message rx_rsl; |
| 701 | f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn)); |
| 702 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 703 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 704 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10)); |
Daniel Willmann | f4ac4ce | 2018-08-02 14:06:30 +0200 | [diff] [blame] | 705 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0)); |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 706 | return chan_nr; |
| 707 | } |
| 708 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 709 | /* helper function to establish a dedicated channel via BTS and MSC */ |
| 710 | function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3) |
| 711 | runs on test_CT return DchanTuple { |
| 712 | var BSSAP_N_CONNECT_ind rx_c_ind; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 713 | var DchanTuple dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 714 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 715 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 716 | dt.rsl_chan_nr := f_chreq_act_ack(ra, fn); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 717 | |
| 718 | f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 719 | |
| 720 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 721 | dt.sccp_conn_id := rx_c_ind.connectionId; |
| 722 | BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id)); |
| 723 | |
| 724 | return dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 725 | } |
| 726 | |
Harald Welte | 641fcbe | 2018-06-14 10:58:35 +0200 | [diff] [blame] | 727 | /* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */ |
| 728 | private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT { |
| 729 | var RSL_Message rx_rsl; |
| 730 | /* expect BSC to disable the channel */ |
| 731 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 732 | /* respond with CHAN REL ACK */ |
| 733 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 734 | |
| 735 | /* expect Clear Complete from BSC */ |
| 736 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 737 | |
| 738 | /* MSC disconnects as instructed. */ |
| 739 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 740 | } |
| 741 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 742 | /* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */ |
| 743 | testcase TC_chan_rel_rll_rel_ind() runs on test_CT { |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 744 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 745 | var DchanTuple dt; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 746 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 747 | f_init(1); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 748 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 749 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 750 | |
| 751 | /* simulate RLL REL IND */ |
| 752 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 753 | |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 754 | /* expect Clear Request on MSC side */ |
| 755 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 756 | |
| 757 | /* Instruct BSC to clear channel */ |
| 758 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 759 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 760 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 761 | /* expect BSC to disable the channel */ |
Harald Welte | 641fcbe | 2018-06-14 10:58:35 +0200 | [diff] [blame] | 762 | f_exp_chan_rel_and_clear(dt, 0); |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 763 | |
| 764 | /* wait for SCCP emulation to do its job */ |
| 765 | f_sleep(1.0); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 766 | |
| 767 | setverdict(pass); |
| 768 | } |
| 769 | |
| 770 | /* Test behavior of channel release after CONN FAIL IND from BTS */ |
| 771 | testcase TC_chan_rel_conn_fail() runs on test_CT { |
| 772 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 773 | var DchanTuple dt; |
| 774 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 775 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 776 | |
| 777 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 778 | |
| 779 | /* simulate CONN FAIL IND */ |
Harald Welte | a8ed906 | 2017-12-14 09:46:01 +0100 | [diff] [blame] | 780 | f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL)); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 781 | /* TODO: different cause values? */ |
| 782 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 783 | /* expect Clear Request from BSC */ |
| 784 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 785 | |
| 786 | /* Instruct BSC to clear channel */ |
| 787 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 788 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 789 | |
Harald Welte | 6ff76ea | 2018-01-28 13:08:01 +0100 | [diff] [blame] | 790 | /* expect BSC to disable the channel */ |
Harald Welte | 641fcbe | 2018-06-14 10:58:35 +0200 | [diff] [blame] | 791 | f_exp_chan_rel_and_clear(dt, 0); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 792 | |
| 793 | /* wait for SCCP emulation to do its job */ |
| 794 | f_sleep(1.0); |
| 795 | |
| 796 | setverdict(pass); |
| 797 | } |
| 798 | |
Harald Welte | 99f3ca0 | 2018-06-14 13:40:29 +0200 | [diff] [blame] | 799 | /* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */ |
| 800 | /* See also https://www.osmocom.org/issues/3182 */ |
| 801 | testcase TC_early_conn_fail() runs on test_CT { |
| 802 | var RSL_Message rx_rsl; |
| 803 | var DchanTuple dt; |
| 804 | |
| 805 | f_init(1); |
| 806 | |
| 807 | /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */ |
| 808 | dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23); |
| 809 | |
| 810 | /* BTS->BSC: simulate CONN FAIL IND */ |
| 811 | f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL)); |
| 812 | |
| 813 | /* BTS->BSC: Expect RF channel release from BSC on Abis */ |
| 814 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0); |
| 815 | |
| 816 | /* BTS<-BSC: respond with CHAN REL ACK */ |
| 817 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 818 | |
| 819 | setverdict(pass); |
| 820 | } |
| 821 | |
| 822 | /* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */ |
| 823 | /* See also https://www.osmocom.org/issues/3182 */ |
| 824 | testcase TC_late_conn_fail() runs on test_CT { |
| 825 | var RSL_Message rx_rsl; |
| 826 | var DchanTuple dt; |
| 827 | |
| 828 | f_init(1); |
| 829 | |
| 830 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 831 | |
| 832 | /* BSC<-MSC: Instruct BSC to clear connection */ |
| 833 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0))); |
| 834 | |
| 835 | /* BTS->BSC: expect BSC to deactivate SACCH */ |
| 836 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr)); |
| 837 | |
| 838 | /* BTS->BSC: simulate a late CONN FAIL IND from BTS */ |
| 839 | f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL)); |
| 840 | |
| 841 | /* BTS<-BSC: Expect RF channel release from BSC on Abis */ |
| 842 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0); |
| 843 | /* BTS->BSC: respond with CHAN REL ACK */ |
| 844 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 845 | |
| 846 | /* BSC->MSC: expect Clear Complete from BSC */ |
| 847 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 848 | |
| 849 | /* BSC<-MSC: MSC disconnects as requested. */ |
| 850 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 851 | |
| 852 | setverdict(pass); |
| 853 | } |
| 854 | |
Neels Hofmeyr | f44ccd1 | 2018-11-05 19:15:23 +0100 | [diff] [blame] | 855 | function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 856 | boolean expect_deact_sacch := true, |
| 857 | boolean expect_rr_chan_rel := true, |
| 858 | boolean expect_rll_rel_req := true, |
Harald Welte | 9978710 | 2019-02-04 10:41:36 +0100 | [diff] [blame] | 859 | boolean handle_rll_rel := true, |
| 860 | boolean is_csfb := false |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 861 | ) runs on test_CT { |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 862 | |
| 863 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 864 | var boolean got_deact_sacch := false; |
| 865 | var boolean got_rr_chan_rel := false; |
| 866 | var boolean got_rll_rel_req := false; |
| 867 | log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel, |
| 868 | " expect_rll_rel_req=", expect_rll_rel_req); |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 869 | alt { |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 870 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 871 | tr_RSL_DEACT_SACCH(rsl_chan_nr))) { |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 872 | got_deact_sacch := true; |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 873 | repeat; |
| 874 | } |
Harald Welte | 9978710 | 2019-02-04 10:41:36 +0100 | [diff] [blame] | 875 | [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) { |
| 876 | got_rr_chan_rel := true; |
| 877 | repeat; |
| 878 | } |
| 879 | [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) { |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 880 | got_rr_chan_rel := true; |
Neels Hofmeyr | 211169d | 2018-11-07 00:37:29 +0100 | [diff] [blame] | 881 | repeat; |
| 882 | } |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 883 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 884 | tr_RSL_REL_REQ(rsl_chan_nr, ?))) { |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 885 | got_rll_rel_req := true; |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 886 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 887 | if (handle_rll_rel) { |
| 888 | f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch)); |
| 889 | } |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 890 | repeat; |
| 891 | } |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 892 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 893 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 894 | /* respond with CHAN REL ACK */ |
| 895 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr)); |
| 896 | } |
| 897 | /* ignore any user data */ |
| 898 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) { |
| 899 | repeat; |
| 900 | } |
| 901 | } |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 902 | |
| 903 | log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel, |
| 904 | " got_rll_rel_req=", got_rll_rel_req); |
| 905 | |
| 906 | if (expect_deact_sacch != got_deact_sacch) { |
| 907 | setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch); |
| 908 | } |
| 909 | if (expect_rr_chan_rel != got_rr_chan_rel) { |
| 910 | setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel); |
| 911 | } |
| 912 | if (expect_rll_rel_req != got_rll_rel_req) { |
| 913 | setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req); |
| 914 | } |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 915 | } |
| 916 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 917 | /* Test behavior of channel release after hard Clear Command from MSC */ |
| 918 | testcase TC_chan_rel_hard_clear() runs on test_CT { |
| 919 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 920 | var DchanTuple dt; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 921 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 922 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 923 | |
| 924 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 925 | |
| 926 | /* Instruct BSC to clear channel */ |
| 927 | var BssmapCause cause := 0; |
| 928 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 929 | |
| 930 | /* expect Clear Complete from BSC on A */ |
| 931 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) { |
| 932 | /* release the SCCP connection */ |
| 933 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 934 | } |
| 935 | |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 936 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 937 | setverdict(pass); |
| 938 | } |
| 939 | |
Harald Welte | 9978710 | 2019-02-04 10:41:36 +0100 | [diff] [blame] | 940 | /* Test behavior of channel release after Clear Command with CSFB indicator from MSC */ |
| 941 | testcase TC_chan_rel_hard_clear_csfb() runs on test_CT { |
| 942 | var BSSAP_N_DATA_ind rx_di; |
| 943 | var DchanTuple dt; |
| 944 | |
| 945 | f_init(1); |
| 946 | |
| 947 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 948 | |
| 949 | /* Instruct BSC to clear channel */ |
| 950 | var BssmapCause cause := 0; |
| 951 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause))); |
| 952 | |
| 953 | /* expect Clear Complete from BSC on A */ |
| 954 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) { |
| 955 | /* release the SCCP connection */ |
| 956 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 957 | } |
| 958 | |
| 959 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true); |
| 960 | setverdict(pass); |
| 961 | } |
| 962 | |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 963 | /* Test behavior of channel release after hard RLSD from MSC */ |
| 964 | testcase TC_chan_rel_hard_rlsd() runs on test_CT { |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 965 | var DchanTuple dt; |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 966 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 967 | f_init(1); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 968 | |
| 969 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 970 | |
| 971 | /* release the SCCP connection */ |
| 972 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 973 | |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 974 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 975 | setverdict(pass); |
| 976 | } |
| 977 | |
Harald Welte | 550daf9 | 2018-06-11 19:22:13 +0200 | [diff] [blame] | 978 | /* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */ |
| 979 | testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT { |
| 980 | var DchanTuple dt; |
| 981 | |
| 982 | f_init(1); |
| 983 | |
| 984 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 985 | |
| 986 | /* release the SCCP connection */ |
| 987 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 988 | |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 989 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false); |
Harald Welte | 550daf9 | 2018-06-11 19:22:13 +0200 | [diff] [blame] | 990 | setverdict(pass); |
| 991 | } |
| 992 | |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 993 | /* Test behavior of channel release after BSSMAP RESET from MSC */ |
| 994 | testcase TC_chan_rel_a_reset() runs on test_CT { |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 995 | var DchanTuple dt; |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 996 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 997 | f_init(1); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 998 | |
| 999 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 1000 | |
| 1001 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 1002 | IPA_RSL[0].clear; |
| 1003 | |
| 1004 | /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */ |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1005 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0))); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 1006 | interleave { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1007 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { } |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 1008 | [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { } |
| 1009 | } |
| 1010 | |
Neels Hofmeyr | a5302c8 | 2018-11-04 23:09:58 +0100 | [diff] [blame] | 1011 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 1012 | setverdict(pass); |
| 1013 | } |
| 1014 | |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1015 | /* Test behavior if RSL EST IND for non-active channel */ |
| 1016 | testcase TC_rll_est_ind_inact_lchan() runs on test_CT { |
| 1017 | timer T := 2.0; |
| 1018 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1019 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1020 | |
| 1021 | var octetstring l3 := '00010203040506'O; |
| 1022 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6)); |
| 1023 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 1024 | |
| 1025 | T.start; |
| 1026 | alt { |
| 1027 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 1028 | setverdict(fail, "MSC received COMPL L3 for non-active lchan"); |
| 1029 | } |
| 1030 | [] BSSAP.receive {} |
| 1031 | [] IPA_RSL[0].receive {} |
| 1032 | [] T.timeout {} |
| 1033 | } |
| 1034 | |
| 1035 | setverdict(pass); |
| 1036 | } |
| 1037 | |
| 1038 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 1039 | testcase TC_rll_est_ind_inval_sapi1() runs on test_CT { |
| 1040 | var RslChannelNr chan_nr; |
| 1041 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1042 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1043 | |
| 1044 | chan_nr := f_chreq_act_ack() |
| 1045 | |
| 1046 | var octetstring l3 := '00010203040506'O; |
| 1047 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3)); |
| 1048 | |
| 1049 | timer T := 2.0; |
| 1050 | T.start; |
| 1051 | alt { |
| 1052 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 1053 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1"); |
| 1054 | } |
| 1055 | [] BSSAP.receive { repeat; } |
| 1056 | [] IPA_RSL[0].receive { repeat; } |
| 1057 | [] T.timeout {} |
| 1058 | } |
| 1059 | |
| 1060 | setverdict(pass); |
| 1061 | } |
| 1062 | |
| 1063 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 1064 | testcase TC_rll_est_ind_inval_sapi3() runs on test_CT { |
| 1065 | timer T := 2.0; |
| 1066 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1067 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1068 | |
| 1069 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 1070 | |
| 1071 | var octetstring l3 := '00010203040506'O; |
| 1072 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3)); |
| 1073 | |
| 1074 | T.start; |
| 1075 | alt { |
| 1076 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 1077 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3"); |
| 1078 | } |
| 1079 | [] BSSAP.receive { repeat; } |
| 1080 | [] IPA_RSL[0].receive { repeat; } |
| 1081 | [] T.timeout {} |
| 1082 | } |
| 1083 | |
| 1084 | setverdict(pass); |
| 1085 | } |
| 1086 | |
| 1087 | /* Test behavior if RSL EST IND for invalid SACCH */ |
| 1088 | testcase TC_rll_est_ind_inval_sacch() runs on test_CT { |
| 1089 | timer T := 2.0; |
| 1090 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1091 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1092 | |
| 1093 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 1094 | |
| 1095 | var octetstring l3 := '00010203040506'O; |
| 1096 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3)); |
| 1097 | |
| 1098 | T.start; |
| 1099 | alt { |
| 1100 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 1101 | setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH"); |
| 1102 | } |
| 1103 | [] BSSAP.receive { repeat; } |
| 1104 | [] IPA_RSL[0].receive { repeat; } |
| 1105 | [] T.timeout {} |
| 1106 | } |
| 1107 | |
| 1108 | setverdict(pass); |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1113 | |
| 1114 | testcase TC_ctrl_msc_connection_status() runs on test_CT { |
| 1115 | var charstring ctrl_resp; |
| 1116 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1117 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1118 | |
| 1119 | /* See https://osmocom.org/issues/2729 */ |
| 1120 | f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected"); |
| 1121 | setverdict(pass); |
| 1122 | } |
| 1123 | |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 1124 | testcase TC_ctrl_msc0_connection_status() runs on test_CT { |
| 1125 | var charstring ctrl_resp; |
| 1126 | |
| 1127 | f_init(1); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 1128 | |
| 1129 | f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected"); |
| 1130 | setverdict(pass); |
| 1131 | } |
| 1132 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1133 | testcase TC_ctrl() runs on test_CT { |
| 1134 | var charstring ctrl_resp; |
| 1135 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1136 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1137 | |
| 1138 | /* all below values must match the osmo-bsc.cfg config file used */ |
| 1139 | |
Harald Welte | 6a12969 | 2018-03-17 17:30:14 +0100 | [diff] [blame] | 1140 | f_ctrl_get_exp(IPA_CTRL, "mcc", "001"); |
| 1141 | f_ctrl_get_exp(IPA_CTRL, "mnc", "01"); |
Harald Welte | 44bdaa5 | 2017-12-17 17:01:47 +0100 | [diff] [blame] | 1142 | f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3"); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1143 | |
| 1144 | var integer bts_nr := 0; |
| 1145 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1"); |
| 1146 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0"); |
| 1147 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected"); |
| 1148 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs"); |
| 1149 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on"); |
| 1150 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871"); |
| 1151 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20"); |
| 1152 | |
| 1153 | var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")); |
| 1154 | f_sleep(2.0); |
| 1155 | if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) { |
| 1156 | setverdict(fail, "oml-uptime not incrementing as expected"); |
| 1157 | } |
| 1158 | /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */ |
| 1159 | |
| 1160 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0); |
| 1161 | |
| 1162 | setverdict(pass); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 1163 | } |
| 1164 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1165 | function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1166 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, bssap)); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | |
| 1170 | /*********************************************************************** |
| 1171 | * Paging Testing |
| 1172 | ***********************************************************************/ |
| 1173 | |
| 1174 | type record Cell_Identity { |
| 1175 | GsmMcc mcc, |
| 1176 | GsmMnc mnc, |
| 1177 | GsmLac lac, |
| 1178 | GsmCellId ci |
| 1179 | }; |
Harald Welte | 24135bd | 2018-03-17 19:27:53 +0100 | [diff] [blame] | 1180 | private const Cell_Identity cid := { '001'H, '01'H, 1, 0 }; |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 1181 | private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 }; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1182 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1183 | type set of integer BtsIdList; |
| 1184 | |
| 1185 | private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean { |
| 1186 | for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) { |
| 1187 | if (bts_id == bts_ids[j]) { |
| 1188 | return true; |
| 1189 | } |
| 1190 | } |
| 1191 | return false; |
| 1192 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1193 | |
| 1194 | /* core paging test helper function; used by most paging test cases */ |
| 1195 | private function f_pageing_helper(hexstring imsi, |
| 1196 | template BSSMAP_FIELD_CellIdentificationList cid_list, |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1197 | BtsIdList bts_ids := { 0 }, |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1198 | template RSL_ChanNeeded rsl_chneed := omit, |
| 1199 | template OCT4 tmsi := omit) runs on test_CT |
| 1200 | { |
| 1201 | var template BSSMAP_IE_ChannelNeeded bssmap_chneed; |
| 1202 | var MobileIdentity mi; |
| 1203 | var template octetstring id_enc; /* FIXME */ |
| 1204 | var RSL_Message rx_rsl; |
| 1205 | var integer paging_group := hex2int(imsi[lengthof(imsi)-1]); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1206 | var integer i; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1207 | |
| 1208 | f_init(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1209 | |
| 1210 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Harald Welte | c306859 | 2018-03-17 19:55:31 +0100 | [diff] [blame] | 1211 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1212 | IPA_RSL[i].clear; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1213 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1214 | |
| 1215 | if (isvalue(rsl_chneed)) { |
| 1216 | /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */ |
| 1217 | bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2)); |
| 1218 | } else { |
| 1219 | bssmap_chneed := omit; |
| 1220 | } |
| 1221 | |
| 1222 | f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)); |
| 1223 | |
| 1224 | /* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder |
| 1225 | if (isvalue(tmsi)) { |
| 1226 | mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi)))); |
| 1227 | } else { |
| 1228 | mi := valueof(ts_Osmo_MI_IMSI(imsi)); |
| 1229 | } |
| 1230 | id_enc := enc_MobileIdentity(mi); |
| 1231 | */ |
| 1232 | id_enc := ?; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1233 | for (i := 0; i < sizeof(bts_ids); i := i + 1) { |
| 1234 | rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc)); |
| 1235 | /* check channel type, paging group */ |
| 1236 | if (rx_rsl.ies[1].body.paging_group != paging_group) { |
| 1237 | setverdict(fail, "Paging for wrong paging group"); |
| 1238 | } |
| 1239 | if (ispresent(rsl_chneed) and |
| 1240 | rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) { |
| 1241 | setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed"); |
| 1242 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1243 | } |
Harald Welte | 2fccd98 | 2018-01-31 15:48:19 +0100 | [diff] [blame] | 1244 | f_sleep(2.0); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1245 | /* do a quick check on all not-included BTSs if they received paging */ |
| 1246 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1247 | timer T := 0.1; |
| 1248 | if (f_bts_in_list(i, bts_ids)) { |
| 1249 | continue; |
| 1250 | } |
| 1251 | T.start; |
| 1252 | alt { |
| 1253 | [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) { |
| 1254 | setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids); |
| 1255 | } |
| 1256 | [] IPA_RSL[i].receive { repeat; } |
| 1257 | [] T.timeout { } |
| 1258 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | setverdict(pass); |
| 1262 | } |
| 1263 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1264 | const BtsIdList c_BtsId_all := { 0, 1, 2 }; |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1265 | const BtsIdList c_BtsId_none := { }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1266 | const BtsIdList c_BtsId_LAC1 := { 0, 1 }; |
| 1267 | const BtsIdList c_BtsId_LAC2 := { 2 }; |
| 1268 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1269 | /* PAGING by IMSI + TMSI */ |
| 1270 | testcase TC_paging_imsi_nochan() runs on test_CT { |
| 1271 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1272 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Philipp Maier | 8c04b0a | 2018-02-23 13:48:48 +0100 | [diff] [blame] | 1273 | f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1274 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | /* PAGING by IMSI + TMSI */ |
| 1278 | testcase TC_paging_tmsi_nochan() runs on test_CT { |
| 1279 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1280 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1281 | f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1282 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | /* Paging with different "channel needed' values */ |
| 1286 | testcase TC_paging_tmsi_any() runs on test_CT { |
| 1287 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1288 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1289 | f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1290 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1291 | } |
| 1292 | testcase TC_paging_tmsi_sdcch() runs on test_CT { |
| 1293 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1294 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1295 | f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1296 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1297 | } |
| 1298 | testcase TC_paging_tmsi_tch_f() runs on test_CT { |
| 1299 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1300 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1301 | f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1302 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1303 | } |
| 1304 | testcase TC_paging_tmsi_tch_hf() runs on test_CT { |
| 1305 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1306 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1307 | f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1308 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | /* Paging by CGI */ |
| 1312 | testcase TC_paging_imsi_nochan_cgi() runs on test_CT { |
| 1313 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1314 | cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1315 | f_pageing_helper('001010000000006'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1316 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | /* Paging by LAC+CI */ |
| 1320 | testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT { |
| 1321 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1322 | cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1323 | f_pageing_helper('001010000000007'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1324 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | /* Paging by CI */ |
| 1328 | testcase TC_paging_imsi_nochan_ci() runs on test_CT { |
| 1329 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1330 | cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1331 | f_pageing_helper('001010000000008'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1332 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | /* Paging by LAI */ |
| 1336 | testcase TC_paging_imsi_nochan_lai() runs on test_CT { |
| 1337 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1338 | cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1339 | f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1340 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1341 | } |
| 1342 | |
| 1343 | /* Paging by LAC */ |
| 1344 | testcase TC_paging_imsi_nochan_lac() runs on test_CT { |
| 1345 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1346 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1347 | f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1348 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | /* Paging by "all in BSS" */ |
| 1352 | testcase TC_paging_imsi_nochan_all() runs on test_CT { |
| 1353 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1354 | cid_list := { cIl_allInBSS := ''O }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1355 | f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1356 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1357 | } |
| 1358 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1359 | /* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1360 | testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT { |
| 1361 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1362 | cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1363 | f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1364 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1365 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1366 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1367 | /* Paging by RNC; We do not implement this; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1368 | testcase TC_paging_imsi_nochan_rnc() runs on test_CT { |
| 1369 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1370 | cid_list := { cIl_RNC := { int2oct(13, 2) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1371 | f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1372 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1373 | } |
| 1374 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1375 | /* Paging by LAC+RNC; We do not implement; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1376 | testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT { |
| 1377 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1378 | cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1379 | f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1380 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1381 | } |
| 1382 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1383 | /* Paging on multiple cells (multiple entries in list): Verify all of them page */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1384 | testcase TC_paging_imsi_nochan_lacs() runs on test_CT { |
| 1385 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1386 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } }; |
| 1387 | f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1388 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | /* Paging on empty list: Verify none of them page */ |
| 1392 | testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT { |
| 1393 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1394 | cid_list := { cIl_LAC := { } }; |
| 1395 | f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1396 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1397 | } |
| 1398 | |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 1399 | /* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */ |
| 1400 | testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT { |
| 1401 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1402 | cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } }; |
| 1403 | f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none); |
| 1404 | f_shutdown_helper(); |
| 1405 | } |
| 1406 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1407 | /* Verify paging retransmission interval + count */ |
| 1408 | /* Verify paging stops after channel establishment */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1409 | /* Test behavior under paging overload */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1410 | |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1411 | /* Verify PCH load */ |
| 1412 | testcase TC_paging_imsi_load() runs on test_CT { |
| 1413 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1414 | timer T := 4.0; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1415 | timer T_retrans := 1.0; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1416 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1417 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1418 | |
| 1419 | /* tell BSC there is no paging space anymore */ |
| 1420 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
Harald Welte | 3b57ab5 | 2018-03-17 18:01:10 +0100 | [diff] [blame] | 1421 | f_sleep(0.2); |
| 1422 | IPA_RSL[0].clear; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1423 | |
| 1424 | /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally, |
| 1425 | * there would be 8 retransmissions during 4 seconds */ |
| 1426 | T.start; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1427 | T_retrans.start; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1428 | alt { |
| 1429 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1430 | setverdict(fail, "Received PAGING after LOAD_IND(0)"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1431 | mtc.stop; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1432 | } |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1433 | [] T_retrans.timeout { |
| 1434 | /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */ |
| 1435 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
| 1436 | T_retrans.start; |
| 1437 | repeat; |
| 1438 | } |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1439 | [] T.timeout { |
| 1440 | setverdict(pass); |
| 1441 | } |
| 1442 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1443 | |
| 1444 | f_shutdown_helper(); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1445 | } |
| 1446 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1447 | /* Verify Paging Counter */ |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1448 | testcase TC_paging_counter() runs on test_CT { |
| 1449 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1450 | timer T := 4.0; |
| 1451 | var integer i; |
| 1452 | var integer paging_attempted_bsc; |
| 1453 | var integer paging_attempted_bts[NUM_BTS]; |
| 1454 | var integer paging_expired_bts[NUM_BTS]; |
| 1455 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
| 1456 | |
| 1457 | f_init(); |
| 1458 | |
| 1459 | /* read counters before paging */ |
| 1460 | paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted"); |
| 1461 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1462 | paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted"); |
| 1463 | paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired"); |
| 1464 | } |
| 1465 | |
| 1466 | f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all); |
| 1467 | |
| 1468 | /* expect the attempted pages on BSC and each BTSs to have incremented by one */ |
| 1469 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1); |
| 1470 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1471 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted", |
| 1472 | paging_attempted_bts[i]+1); |
| 1473 | } |
| 1474 | |
| 1475 | /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */ |
| 1476 | f_sleep(12.0); |
| 1477 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1478 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired", |
| 1479 | paging_expired_bts[i]+1); |
| 1480 | } |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1481 | |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1482 | f_shutdown_helper(); |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1483 | } |
| 1484 | |
| 1485 | |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1486 | /* Verify paging stops after A-RESET */ |
| 1487 | testcase TC_paging_imsi_a_reset() runs on test_CT { |
| 1488 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1489 | timer T := 3.0; |
| 1490 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1491 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1492 | |
| 1493 | /* Perform a BSSMAP Reset and wait for ACK */ |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1494 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0))); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1495 | alt { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1496 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1497 | [] BSSAP.receive { repeat; } |
| 1498 | } |
| 1499 | |
Daniel Willmann | cbef398 | 2018-07-30 09:22:40 +0200 | [diff] [blame] | 1500 | /* Wait to avoid a possible race condition if a paging message is |
| 1501 | * received right before the reset ACK. */ |
| 1502 | f_sleep(0.2); |
| 1503 | |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1504 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Philipp Maier | 1e6b442 | 2018-02-23 14:02:13 +0100 | [diff] [blame] | 1505 | for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) { |
| 1506 | IPA_RSL[i].clear; |
| 1507 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1508 | |
| 1509 | /* Wait for 3 seconds if any more PAGING CMD are received on RSL */ |
| 1510 | T.start; |
| 1511 | alt { |
| 1512 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1513 | setverdict(fail, "Received PAGING after A-RESET"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1514 | mtc.stop; |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1515 | } |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1516 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1517 | setverdict(fail, "Received PAGING after A-RESET"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1518 | mtc.stop; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1519 | } |
| 1520 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1521 | setverdict(fail, "Received PAGING after A-RESET"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1522 | mtc.stop; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1523 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1524 | [] T.timeout { |
| 1525 | setverdict(pass); |
| 1526 | } |
| 1527 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1528 | |
| 1529 | f_shutdown_helper(); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1530 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1531 | |
Pau Espin Pedrol | 3466cc5 | 2018-11-05 12:41:05 +0100 | [diff] [blame] | 1532 | /* Verify how we handle unsolicited Paging Response, for instance because we |
| 1533 | * receive a Paging Response after T3113 expired (and subscriber information was |
| 1534 | * dropped). See OS#3680. |
| 1535 | */ |
| 1536 | testcase TC_paging_resp_unsol() runs on test_CT { |
| 1537 | |
| 1538 | f_init(1); |
| 1539 | |
| 1540 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 1541 | var DchanTuple dt; |
| 1542 | var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H)))); |
| 1543 | |
| 1544 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 1545 | dt.rsl_chan_nr := f_chreq_act_ack(); |
| 1546 | |
| 1547 | /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */ |
| 1548 | f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3))); |
| 1549 | |
| 1550 | /* expect BSC to disable the channel */ |
Pau Espin Pedrol | 5ee6f6c | 2018-12-07 12:07:43 +0100 | [diff] [blame] | 1551 | f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false); |
Pau Espin Pedrol | 3466cc5 | 2018-11-05 12:41:05 +0100 | [diff] [blame] | 1552 | setverdict(pass); |
| 1553 | |
| 1554 | } |
| 1555 | |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1556 | /* Test RSL link drop causes counter increment */ |
| 1557 | testcase TC_rsl_drop_counter() runs on test_CT { |
| 1558 | var integer rsl_fail; |
| 1559 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1560 | f_init(1); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1561 | |
| 1562 | rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail"); |
| 1563 | |
| 1564 | bts[0].rsl.vc_IPA.stop; |
| 1565 | |
| 1566 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1); |
| 1567 | |
| 1568 | setverdict(pass); |
| 1569 | } |
| 1570 | |
| 1571 | /* TODO: Test OML link drop causes counter increment */ |
| 1572 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1573 | /* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */ |
| 1574 | function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean { |
| 1575 | timer T := 10.0; |
| 1576 | |
| 1577 | bts[0].rsl.id := "IPA-0-RSL"; |
| 1578 | bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA"); |
| 1579 | bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars; |
| 1580 | bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 1581 | bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */ |
| 1582 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1583 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
| 1584 | |
| 1585 | f_init_mgcp("VirtMSC"); |
| 1586 | |
| 1587 | /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */ |
| 1588 | map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA); |
| 1589 | connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]); |
| 1590 | bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars)); |
| 1591 | |
| 1592 | /* wait for IPA OML link to connect and then disconnect */ |
| 1593 | T.start; |
| 1594 | alt { |
| 1595 | [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) { |
| 1596 | T.stop; |
| 1597 | return true; |
| 1598 | } |
| 1599 | [] IPA_RSL[0].receive { repeat } |
| 1600 | [] T.timeout { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1601 | return false; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1602 | } |
| 1603 | } |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1604 | return false; |
| 1605 | } |
| 1606 | |
| 1607 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1608 | testcase TC_rsl_unknown_unit_id() runs on test_CT { |
| 1609 | if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) { |
| 1610 | setverdict(pass); |
| 1611 | } else { |
| 1612 | setverdict(fail, "Timeout RSL waiting for connection to close"); |
| 1613 | } |
| 1614 | } |
| 1615 | |
| 1616 | |
| 1617 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1618 | testcase TC_oml_unknown_unit_id() runs on test_CT { |
| 1619 | if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) { |
| 1620 | setverdict(pass); |
| 1621 | } else { |
| 1622 | setverdict(fail, "Timeout OML waiting for connection to close"); |
| 1623 | } |
| 1624 | } |
| 1625 | |
| 1626 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1627 | /*********************************************************************** |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1628 | * "New world" test cases using RSL_Emulation + RAN_Emulation |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1629 | ***********************************************************************/ |
| 1630 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1631 | import from RAN_Emulation all; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1632 | import from RSL_Emulation all; |
| 1633 | import from MSC_ConnectionHandler all; |
| 1634 | |
| 1635 | type function void_fn(charstring id) runs on MSC_ConnHdlr; |
| 1636 | |
Harald Welte | 336820c | 2018-05-31 20:34:52 +0200 | [diff] [blame] | 1637 | /* helper function to create and connect a MSC_ConnHdlr component */ |
Harald Welte | ff579f9 | 2018-05-31 22:19:39 +0200 | [diff] [blame] | 1638 | private function f_connect_handler(inout MSC_ConnHdlr vc_conn) runs on test_CT { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1639 | connect(vc_conn:RAN, g_bssap.vc_RAN:PROC); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1640 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1641 | connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 1642 | connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC); |
Philipp Maier | 88f4ae8 | 2018-03-01 14:00:58 +0100 | [diff] [blame] | 1643 | if (isvalue(bts[1])) { |
Philipp Maier | 956a92f | 2018-02-16 10:58:07 +0100 | [diff] [blame] | 1644 | connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT); |
| 1645 | connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC); |
| 1646 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1647 | connect(vc_conn:BSSAP, g_bssap.vc_RAN:CLIENT); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1648 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
Harald Welte | 336820c | 2018-05-31 20:34:52 +0200 | [diff] [blame] | 1649 | } |
| 1650 | |
| 1651 | function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit) |
| 1652 | runs on test_CT return MSC_ConnHdlr { |
| 1653 | var charstring id := testcasename(); |
| 1654 | var MSC_ConnHdlr vc_conn; |
| 1655 | vc_conn := MSC_ConnHdlr.create(id); |
| 1656 | f_connect_handler(vc_conn); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1657 | vc_conn.start(f_handler_init(fn, id, pars)); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1658 | return vc_conn; |
| 1659 | } |
| 1660 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1661 | /* first function inside ConnHdlr component; sets g_pars + starts function */ |
| 1662 | private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit) |
| 1663 | runs on MSC_ConnHdlr { |
| 1664 | if (isvalue(pars)) { |
| 1665 | g_pars := valueof(pars); |
| 1666 | } |
| 1667 | fn.apply(id); |
| 1668 | } |
| 1669 | |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1670 | /* Establish signalling channel (non-assignment case) followed by cipher mode */ |
| 1671 | private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 1672 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 1673 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1674 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL); |
Philipp Maier | 2300073 | 2018-05-18 11:25:37 +0200 | [diff] [blame] | 1675 | ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit; |
| 1676 | ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit; |
| 1677 | exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit; |
| 1678 | exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit; |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1679 | |
Philipp Maier | 2300073 | 2018-05-18 11:25:37 +0200 | [diff] [blame] | 1680 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1681 | } |
| 1682 | testcase TC_ciph_mode_a5_0() runs on test_CT { |
| 1683 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1684 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1685 | pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8))); |
| 1686 | |
| 1687 | f_init(1, true); |
| 1688 | f_sleep(1.0); |
| 1689 | vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars); |
| 1690 | vc_conn.done; |
| 1691 | } |
| 1692 | testcase TC_ciph_mode_a5_1() runs on test_CT { |
| 1693 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1694 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1695 | pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8))); |
| 1696 | |
| 1697 | f_init(1, true); |
| 1698 | f_sleep(1.0); |
| 1699 | vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars); |
| 1700 | vc_conn.done; |
| 1701 | } |
| 1702 | testcase TC_ciph_mode_a5_3() runs on test_CT { |
| 1703 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1704 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 1705 | pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8))); |
| 1706 | |
| 1707 | f_init(1, true); |
| 1708 | f_sleep(1.0); |
| 1709 | vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars); |
| 1710 | vc_conn.done; |
| 1711 | } |
| 1712 | |
| 1713 | |
| 1714 | /* establish initial channel, enable ciphering followed by assignment to ciphered channel */ |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1715 | private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 1716 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 1717 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1718 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1719 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1720 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1721 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1722 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1723 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1724 | testcase TC_assignment_fr_a5_0() runs on test_CT { |
| 1725 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1726 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1727 | pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8))); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1728 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1729 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1730 | f_sleep(1.0); |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1731 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1732 | vc_conn.done; |
| 1733 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1734 | testcase TC_assignment_fr_a5_1() runs on test_CT { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1735 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1736 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1737 | pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8))); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1738 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1739 | f_init(1, true); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1740 | f_sleep(1.0); |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1741 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars); |
| 1742 | vc_conn.done; |
| 1743 | } |
| 1744 | testcase TC_assignment_fr_a5_3() runs on test_CT { |
| 1745 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1746 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1747 | pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8))); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1748 | |
Harald Welte | 651fcdc | 2018-05-10 20:23:16 +0200 | [diff] [blame] | 1749 | f_init(1, true); |
| 1750 | f_sleep(1.0); |
| 1751 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1752 | vc_conn.done; |
| 1753 | } |
| 1754 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1755 | /* Expect ASSIGNMENT FAIL if mandatory IE is missing */ |
| 1756 | private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1757 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1758 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 1759 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1760 | const OCT8 kc := '0001020304050607'O; |
| 1761 | |
| 1762 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 1763 | /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */ |
| 1764 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1765 | f_establish_fully(ass_cmd, exp_fail); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1766 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1767 | testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT { |
| 1768 | var MSC_ConnHdlr vc_conn; |
| 1769 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1770 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1771 | f_sleep(1.0); |
| 1772 | |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 1773 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing)); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1774 | vc_conn.done; |
| 1775 | } |
| 1776 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1777 | private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1778 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 1779 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 1780 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1781 | const OCT8 kc := '0001020304050607'O; |
| 1782 | const OCT16 kc128 := kc & kc; |
| 1783 | |
| 1784 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1785 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1786 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1787 | f_cipher_mode('10'O, kc, kc128, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1788 | /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */ |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1789 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1790 | testcase TC_assignment_fr_a5_4() runs on test_CT { |
| 1791 | var MSC_ConnHdlr vc_conn; |
| 1792 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1793 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1794 | f_sleep(1.0); |
| 1795 | |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 1796 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4)); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1797 | vc_conn.done; |
| 1798 | } |
| 1799 | |
| 1800 | |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1801 | private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1802 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1803 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit); |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 1804 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1805 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1806 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1807 | } |
| 1808 | |
| 1809 | testcase TC_assignment_sign() runs on test_CT { |
| 1810 | var MSC_ConnHdlr vc_conn; |
| 1811 | |
| 1812 | f_init(1, true); |
| 1813 | f_sleep(1.0); |
| 1814 | |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 1815 | vc_conn := f_start_handler(refers(f_tc_assignment_sign)); |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1816 | vc_conn.done; |
| 1817 | } |
| 1818 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1819 | /*********************************************************************** |
| 1820 | * Codec (list) testing |
| 1821 | ***********************************************************************/ |
| 1822 | |
| 1823 | /* check if the given rsl_mode is compatible with the a_elem */ |
| 1824 | private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode) |
| 1825 | return boolean { |
| 1826 | select (a_elem.codecType) { |
| 1827 | case (GSM_FR) { |
| 1828 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) { |
| 1829 | return true; |
| 1830 | } |
| 1831 | } |
| 1832 | case (GSM_HR) { |
| 1833 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) { |
| 1834 | return true; |
| 1835 | } |
| 1836 | } |
| 1837 | case (GSM_EFR) { |
| 1838 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) { |
| 1839 | return true; |
| 1840 | } |
| 1841 | } |
| 1842 | case (FR_AMR) { |
| 1843 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) { |
| 1844 | return true; |
| 1845 | } |
| 1846 | } |
| 1847 | case (HR_AMR) { |
| 1848 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) { |
| 1849 | return true; |
| 1850 | } |
| 1851 | } |
| 1852 | case else { } |
| 1853 | } |
| 1854 | return false; |
| 1855 | } |
| 1856 | |
| 1857 | /* check if the given rsl_mode is compatible with the a_list */ |
| 1858 | private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode) |
| 1859 | return boolean { |
| 1860 | for (var integer i := 0; i < sizeof(a_list); i := i+1) { |
| 1861 | if (f_match_codec(a_list.codecElements[i], rsl_mode)) { |
| 1862 | return true; |
| 1863 | } |
| 1864 | } |
| 1865 | return false; |
| 1866 | } |
| 1867 | |
| 1868 | /* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */ |
Philipp Maier | 61f6b57 | 2018-07-06 14:03:38 +0200 | [diff] [blame] | 1869 | function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem) |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1870 | return BSSMAP_IE_ChannelType { |
| 1871 | /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */ |
| 1872 | var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType); |
| 1873 | select (a_elem.codecType) { |
| 1874 | case (GSM_FR) { |
| 1875 | ret.channelRateAndType := ChRate_TCHF; |
| 1876 | ret.speechId_DataIndicator := Spdi_TCHF_FR; |
| 1877 | } |
| 1878 | case (GSM_HR) { |
| 1879 | ret.channelRateAndType := ChRate_TCHH; |
| 1880 | ret.speechId_DataIndicator := Spdi_TCHH_HR; |
| 1881 | } |
| 1882 | case (GSM_EFR) { |
| 1883 | ret.channelRateAndType := ChRate_TCHF; |
| 1884 | ret.speechId_DataIndicator := Spdi_TCHF_EFR; |
| 1885 | } |
| 1886 | case (FR_AMR) { |
| 1887 | ret.channelRateAndType := ChRate_TCHF; |
| 1888 | ret.speechId_DataIndicator := Spdi_TCHF_AMR; |
| 1889 | } |
| 1890 | case (HR_AMR) { |
| 1891 | ret.channelRateAndType := ChRate_TCHH; |
| 1892 | ret.speechId_DataIndicator := Spdi_TCHH_AMR; |
| 1893 | } |
| 1894 | case else { |
| 1895 | setverdict(fail, "Unsupported codec ", a_elem); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1896 | mtc.stop; |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1897 | } |
| 1898 | } |
| 1899 | return ret; |
| 1900 | } |
| 1901 | |
Harald Welte | a63b910 | 2018-03-22 20:36:16 +0100 | [diff] [blame] | 1902 | private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem) |
| 1903 | return template RSL_IE_Body { |
| 1904 | var template RSL_IE_Body mode_ie := { |
| 1905 | chan_mode := { |
| 1906 | len := ?, |
| 1907 | reserved := ?, |
| 1908 | dtx_d := ?, |
| 1909 | dtx_u := ?, |
| 1910 | spd_ind := RSL_SPDI_SPEECH, |
| 1911 | ch_rate_type := -, |
| 1912 | coding_alg_rate := - |
| 1913 | } |
| 1914 | } |
| 1915 | |
| 1916 | select (a_elem.codecType) { |
| 1917 | case (GSM_FR) { |
| 1918 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1919 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1; |
| 1920 | } |
| 1921 | case (GSM_HR) { |
| 1922 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H; |
| 1923 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1; |
| 1924 | } |
| 1925 | case (GSM_EFR) { |
| 1926 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1927 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2; |
| 1928 | } |
| 1929 | case (FR_AMR) { |
| 1930 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1931 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3; |
| 1932 | } |
| 1933 | case (HR_AMR) { |
| 1934 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H; |
| 1935 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3; |
| 1936 | } |
| 1937 | } |
| 1938 | return mode_ie; |
| 1939 | } |
| 1940 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1941 | type record CodecListTest { |
| 1942 | BSSMAP_IE_SpeechCodecList codec_list, |
| 1943 | charstring id |
| 1944 | } |
| 1945 | type record of CodecListTest CodecListTests |
| 1946 | |
| 1947 | private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 1948 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 1949 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1950 | |
| 1951 | /* puzzle together the ASSIGNMENT REQ for given codec[s] */ |
Harald Welte | 79f3f54 | 2018-05-25 20:02:37 +0200 | [diff] [blame] | 1952 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 1953 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list; |
| 1954 | exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] := |
| 1955 | g_pars.ass_codec_list.codecElements[0]; |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 1956 | if (isvalue(g_pars.expect_mr_s0_s7)) { |
| 1957 | exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 := |
| 1958 | g_pars.expect_mr_s0_s7; |
| 1959 | } |
Harald Welte | 79f3f54 | 2018-05-25 20:02:37 +0200 | [diff] [blame] | 1960 | } |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1961 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := |
| 1962 | f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1963 | log("expecting ASS COMPL like this: ", exp_compl); |
| 1964 | |
| 1965 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | a63b910 | 2018-03-22 20:36:16 +0100 | [diff] [blame] | 1966 | |
| 1967 | /* Verify that the RSL-side activation actually matches our expectations */ |
| 1968 | var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr); |
| 1969 | |
| 1970 | var RSL_IE_Body mode_ie; |
| 1971 | if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) { |
| 1972 | setverdict(fail, "Couldn't find CHAN_MODE IE"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1973 | mtc.stop; |
Harald Welte | a63b910 | 2018-03-22 20:36:16 +0100 | [diff] [blame] | 1974 | } |
| 1975 | var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]); |
| 1976 | if (not match(mode_ie, t_mode_ie)) { |
| 1977 | setverdict(fail, "RSL Channel Mode IE doesn't match expectation"); |
| 1978 | } |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 1979 | |
| 1980 | var RSL_IE_Body mr_conf; |
| 1981 | if (g_pars.expect_mr_conf_ie != omit) { |
| 1982 | if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) { |
| 1983 | setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1984 | mtc.stop; |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 1985 | } |
| 1986 | log("found RSL MR CONFIG IE: ", mr_conf); |
| 1987 | |
| 1988 | if (not match(mr_conf, g_pars.expect_mr_conf_ie)) { |
| 1989 | setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ", |
| 1990 | g_pars.expect_mr_conf_ie); |
| 1991 | } |
| 1992 | } else { |
| 1993 | if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) { |
| 1994 | log("found RSL MR CONFIG IE: ", mr_conf); |
| 1995 | setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1996 | mtc.stop; |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 1997 | } |
| 1998 | } |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1999 | } |
| 2000 | |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 2001 | private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr { |
| 2002 | |
| 2003 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2004 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 2005 | |
| 2006 | /* puzzle together the ASSIGNMENT REQ for given codec[s] */ |
| 2007 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 2008 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list; |
| 2009 | } |
| 2010 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := |
| 2011 | f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]); |
| 2012 | log("expecting ASS FAIL like this: ", exp_fail); |
| 2013 | |
| 2014 | f_establish_fully(ass_cmd, exp_fail); |
| 2015 | } |
| 2016 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2017 | testcase TC_assignment_codec_fr() runs on test_CT { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2018 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2019 | var MSC_ConnHdlr vc_conn; |
| 2020 | |
| 2021 | f_init(1, true); |
| 2022 | f_sleep(1.0); |
| 2023 | |
| 2024 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2025 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2026 | vc_conn.done; |
| 2027 | } |
| 2028 | |
| 2029 | testcase TC_assignment_codec_hr() runs on test_CT { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2030 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2031 | var MSC_ConnHdlr vc_conn; |
| 2032 | |
| 2033 | f_init(1, true); |
| 2034 | f_sleep(1.0); |
| 2035 | |
| 2036 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR})); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2037 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2038 | vc_conn.done; |
| 2039 | } |
| 2040 | |
| 2041 | testcase TC_assignment_codec_efr() runs on test_CT { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2042 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2043 | var MSC_ConnHdlr vc_conn; |
| 2044 | |
| 2045 | f_init(1, true); |
| 2046 | f_sleep(1.0); |
| 2047 | |
| 2048 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR})); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2049 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2050 | vc_conn.done; |
| 2051 | } |
| 2052 | |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 2053 | /* Allow 5,90k only (current default config) */ |
| 2054 | private function f_allow_amr_rate_5_90k() runs on test_CT { |
| 2055 | f_vty_enter_cfg_msc(BSCVTY, 0); |
| 2056 | f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden"); |
| 2057 | f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden"); |
| 2058 | f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden"); |
| 2059 | f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden"); |
| 2060 | f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden"); |
| 2061 | f_vty_transceive(BSCVTY, "amr-config 5_90k allowed"); |
| 2062 | f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden"); |
| 2063 | f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden"); |
| 2064 | f_vty_transceive(BSCVTY, "exit"); |
| 2065 | f_vty_transceive(BSCVTY, "exit"); |
| 2066 | } |
| 2067 | |
| 2068 | /* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates |
| 2069 | * ("Config-NB-Code = 1") */ |
| 2070 | private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT { |
| 2071 | f_vty_enter_cfg_msc(BSCVTY, 0); |
| 2072 | f_vty_transceive(BSCVTY, "amr-config 12_2k allowed"); |
| 2073 | f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden"); |
| 2074 | f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden"); |
| 2075 | f_vty_transceive(BSCVTY, "amr-config 7_40k allowed"); |
| 2076 | f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden"); |
| 2077 | f_vty_transceive(BSCVTY, "amr-config 5_90k allowed"); |
| 2078 | f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden"); |
| 2079 | f_vty_transceive(BSCVTY, "amr-config 4_75k allowed"); |
| 2080 | f_vty_transceive(BSCVTY, "exit"); |
| 2081 | f_vty_transceive(BSCVTY, "exit"); |
| 2082 | } |
| 2083 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2084 | testcase TC_assignment_codec_amr_f() runs on test_CT { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2085 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2086 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2087 | |
| 2088 | /* Note: This setups the codec configuration. The parameter payload in |
| 2089 | * mr_conf must be consistant with the parameter codecElements in pars |
| 2090 | * and also must match the amr-config in osmo-bsc.cfg! */ |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 2091 | var RSL_IE_Body mr_conf := { |
| 2092 | other := { |
| 2093 | len := 2, |
| 2094 | payload := '2804'O |
| 2095 | } |
| 2096 | }; |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2097 | |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2098 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F})); |
Philipp Maier | 806f8f1 | 2019-03-12 12:13:41 +0100 | [diff] [blame] | 2099 | pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */ |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2100 | pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B; |
| 2101 | pars.expect_mr_conf_ie := mr_conf; |
| 2102 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2103 | f_init(1, true); |
| 2104 | f_sleep(1.0); |
| 2105 | |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2106 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2107 | vc_conn.done; |
| 2108 | } |
| 2109 | |
| 2110 | testcase TC_assignment_codec_amr_h() runs on test_CT { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2111 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2112 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2113 | |
| 2114 | /* See note above */ |
Neels Hofmeyr | bcf62bc | 2018-07-04 00:24:33 +0200 | [diff] [blame] | 2115 | var RSL_IE_Body mr_conf := { |
| 2116 | other := { |
| 2117 | len := 2, |
| 2118 | payload := '2804'O |
| 2119 | } |
| 2120 | }; |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2121 | |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2122 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H})); |
Philipp Maier | 806f8f1 | 2019-03-12 12:13:41 +0100 | [diff] [blame] | 2123 | pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */ |
Philipp Maier | 7695a0d | 2018-09-27 17:52:14 +0200 | [diff] [blame] | 2124 | pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B; |
| 2125 | pars.expect_mr_conf_ie := mr_conf; |
| 2126 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2127 | f_init(1, true); |
| 2128 | f_sleep(1.0); |
| 2129 | |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2130 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2131 | vc_conn.done; |
| 2132 | } |
| 2133 | |
Philipp Maier | d0e64b0 | 2019-03-13 14:15:23 +0100 | [diff] [blame] | 2134 | function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0) |
| 2135 | runs on test_CT { |
| 2136 | |
| 2137 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 2138 | var MSC_ConnHdlr vc_conn; |
| 2139 | |
| 2140 | /* See note above */ |
| 2141 | var RSL_IE_Body mr_conf := { |
| 2142 | other := { |
| 2143 | len := lengthof(mrconf), |
| 2144 | payload := mrconf |
| 2145 | } |
| 2146 | }; |
| 2147 | |
| 2148 | if (fr) { |
| 2149 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F})); |
| 2150 | } else { |
| 2151 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H})); |
| 2152 | } |
| 2153 | pars.ass_codec_list.codecElements[0].s0_7 := s8_s0; |
| 2154 | pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B; |
| 2155 | pars.expect_mr_conf_ie := mr_conf; |
| 2156 | pars.expect_mr_s0_s7 := exp_s8_s0; |
| 2157 | |
| 2158 | f_init(1, true); |
| 2159 | f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k(); |
| 2160 | f_sleep(1.0); |
| 2161 | |
| 2162 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars); |
| 2163 | vc_conn.done; |
| 2164 | f_allow_amr_rate_5_90k(); |
| 2165 | } |
| 2166 | |
| 2167 | function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0) |
| 2168 | runs on test_CT { |
| 2169 | |
| 2170 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 2171 | var MSC_ConnHdlr vc_conn; |
| 2172 | |
| 2173 | if (fr) { |
| 2174 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F})); |
| 2175 | } else { |
| 2176 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H})); |
| 2177 | } |
| 2178 | pars.ass_codec_list.codecElements[0].s0_7 := s8_s0; |
| 2179 | pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B; |
| 2180 | |
| 2181 | f_init(1, true); |
| 2182 | f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k(); |
| 2183 | f_sleep(1.0); |
| 2184 | |
| 2185 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars); |
| 2186 | vc_conn.done; |
| 2187 | f_allow_amr_rate_5_90k(); |
| 2188 | } |
| 2189 | |
| 2190 | |
| 2191 | /* Set S1, we expect an AMR multirate configuration IE with all four rates |
| 2192 | * set. */ |
| 2193 | testcase TC_assignment_codec_amr_f_S1() runs on test_CT { |
| 2194 | f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B); |
| 2195 | } |
| 2196 | |
| 2197 | /* Set S1, we expect an AMR multirate configuration IE with the lower three |
| 2198 | * rates set. */ |
| 2199 | testcase TC_assignment_codec_amr_h_S1() runs on test_CT { |
| 2200 | f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B); |
| 2201 | } |
| 2202 | |
| 2203 | /* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with |
| 2204 | * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */ |
| 2205 | testcase TC_assignment_codec_amr_f_S124() runs on test_CT { |
| 2206 | f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B); |
| 2207 | } |
| 2208 | |
| 2209 | /* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with |
| 2210 | * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */ |
| 2211 | testcase TC_assignment_codec_amr_h_S124() runs on test_CT { |
| 2212 | f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B); |
| 2213 | } |
| 2214 | |
| 2215 | /* The following block of tests selects more and more rates until all four |
| 2216 | * possible rates are in the active set (full rate) */ |
| 2217 | testcase TC_assignment_codec_amr_f_S0() runs on test_CT { |
| 2218 | f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B); |
| 2219 | } |
| 2220 | |
| 2221 | testcase TC_assignment_codec_amr_f_S02() runs on test_CT { |
| 2222 | f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B); |
| 2223 | } |
| 2224 | |
| 2225 | testcase TC_assignment_codec_amr_f_S024() runs on test_CT { |
| 2226 | f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B); |
| 2227 | } |
| 2228 | |
| 2229 | testcase TC_assignment_codec_amr_f_S0247() runs on test_CT { |
| 2230 | f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B); |
| 2231 | } |
| 2232 | |
| 2233 | /* The following block of tests selects more and more rates until all three |
| 2234 | * possible rates are in the active set (half rate) */ |
| 2235 | testcase TC_assignment_codec_amr_h_S0() runs on test_CT { |
| 2236 | f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B); |
| 2237 | } |
| 2238 | |
| 2239 | testcase TC_assignment_codec_amr_h_S02() runs on test_CT { |
| 2240 | f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B); |
| 2241 | } |
| 2242 | |
| 2243 | testcase TC_assignment_codec_amr_h_S024() runs on test_CT { |
| 2244 | f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B); |
| 2245 | } |
| 2246 | |
| 2247 | /* The following block tests what happens when the MSC does offer rate |
| 2248 | * configurations that are not supported by the BSC. Normally such situations |
| 2249 | * should not happen because the MSC gets informed by the BSC in advance via |
| 2250 | * the L3 COMPLETE message which rates are applicable. The MSC should not try |
| 2251 | * to offer rates that are not applicable anyway. */ |
| 2252 | |
| 2253 | testcase TC_assignment_codec_amr_h_S0247() runs on test_CT { |
| 2254 | /* Try to include 12,2k in into the active set even though the channel |
| 2255 | * is half rate only. The BSC is expected to remove the 12,0k */ |
| 2256 | f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B); |
| 2257 | } |
| 2258 | |
| 2259 | testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT { |
| 2260 | /* See what happens when all rates are selected at once. Since then |
| 2261 | * Also S1 is selected, this setting will be prefered and we should |
| 2262 | * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */ |
| 2263 | f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B); |
| 2264 | } |
| 2265 | |
| 2266 | testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT { |
| 2267 | /* Same as above, but with S1 missing, the MSC is then expected to |
| 2268 | * select the currently supported rates, which are also 12.2k, 7,40k, |
| 2269 | * 5,90k, and 4,75k, into the active set. */ |
| 2270 | f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B); |
| 2271 | } |
| 2272 | |
| 2273 | testcase TC_assignment_codec_amr_f_zero() runs on test_CT { |
| 2274 | /* Try to select no rates at all */ |
| 2275 | f_TC_assignment_codec_amr_fail(true, '00000000'B); |
| 2276 | } |
| 2277 | |
| 2278 | testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT { |
| 2279 | /* Try to select only unsupported rates */ |
| 2280 | f_TC_assignment_codec_amr_fail(true, '01101000'B); |
| 2281 | } |
| 2282 | |
| 2283 | testcase TC_assignment_codec_amr_h_S7() runs on test_CT { |
| 2284 | /* Try to select 12,2k for half rate */ |
| 2285 | f_TC_assignment_codec_amr_fail(false, '10000000'B); |
| 2286 | } |
| 2287 | |
Philipp Maier | ac09bfc | 2019-01-08 13:41:39 +0100 | [diff] [blame] | 2288 | private function f_disable_all_tch_f() runs on test_CT { |
Philipp Maier | c704a88 | 2019-01-29 15:58:52 +0100 | [diff] [blame] | 2289 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken"); |
| 2290 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken"); |
| 2291 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken"); |
| 2292 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken"); |
Philipp Maier | ac09bfc | 2019-01-08 13:41:39 +0100 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | private function f_disable_all_tch_h() runs on test_CT { |
Philipp Maier | c704a88 | 2019-01-29 15:58:52 +0100 | [diff] [blame] | 2296 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken"); |
| 2297 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken"); |
Philipp Maier | ac09bfc | 2019-01-08 13:41:39 +0100 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | private function f_enable_all_tch() runs on test_CT { |
Philipp Maier | c704a88 | 2019-01-29 15:58:52 +0100 | [diff] [blame] | 2301 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused"); |
| 2302 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused"); |
| 2303 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused"); |
| 2304 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused"); |
| 2305 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused"); |
| 2306 | f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused"); |
Philipp Maier | ac09bfc | 2019-01-08 13:41:39 +0100 | [diff] [blame] | 2307 | } |
| 2308 | |
| 2309 | /* Allow HR only */ |
| 2310 | private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr { |
| 2311 | g_pars := f_gen_test_hdlr_pars(); |
| 2312 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2313 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2314 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2315 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O; |
| 2316 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O; |
| 2317 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR})); |
| 2318 | f_establish_fully(ass_cmd, exp_compl); |
| 2319 | } |
| 2320 | |
| 2321 | /* Allow FR only */ |
| 2322 | private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr { |
| 2323 | g_pars := f_gen_test_hdlr_pars(); |
| 2324 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2325 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2326 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2327 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O; |
| 2328 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O; |
| 2329 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2330 | f_establish_fully(ass_cmd, exp_compl); |
| 2331 | } |
| 2332 | |
| 2333 | /* Allow HR only (expect assignment failure) */ |
| 2334 | private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr { |
| 2335 | g_pars := f_gen_test_hdlr_pars(); |
| 2336 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2337 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 2338 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2339 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O; |
| 2340 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O; |
| 2341 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR})); |
| 2342 | f_establish_fully(ass_cmd, exp_fail); |
| 2343 | } |
| 2344 | |
| 2345 | /* Allow FR only (expect assignment failure) */ |
| 2346 | private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr { |
| 2347 | g_pars := f_gen_test_hdlr_pars(); |
| 2348 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2349 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 2350 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2351 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O; |
| 2352 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O; |
| 2353 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2354 | f_establish_fully(ass_cmd, exp_fail); |
| 2355 | } |
| 2356 | |
| 2357 | /* Allow FR and HR, but prefer FR */ |
| 2358 | private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr { |
| 2359 | g_pars := f_gen_test_hdlr_pars(); |
| 2360 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2361 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2362 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2363 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */ |
| 2364 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O; |
| 2365 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR})); |
| 2366 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */ |
| 2367 | f_establish_fully(ass_cmd, exp_compl); |
| 2368 | } |
| 2369 | |
| 2370 | /* Allow FR and HR, but prefer HR */ |
| 2371 | private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr { |
| 2372 | g_pars := f_gen_test_hdlr_pars(); |
| 2373 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2374 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2375 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2376 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */ |
| 2377 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O; |
| 2378 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR})); |
| 2379 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */ |
| 2380 | f_establish_fully(ass_cmd, exp_compl); |
| 2381 | } |
| 2382 | |
| 2383 | /* Allow FR and HR, but prefer FR */ |
| 2384 | private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr { |
| 2385 | g_pars := f_gen_test_hdlr_pars(); |
| 2386 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2387 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2388 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2389 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */ |
| 2390 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O; |
| 2391 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR})); |
| 2392 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */ |
| 2393 | f_establish_fully(ass_cmd, exp_compl); |
| 2394 | } |
| 2395 | |
| 2396 | /* Allow FR and HR, but prefer HR */ |
| 2397 | private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr { |
| 2398 | g_pars := f_gen_test_hdlr_pars(); |
| 2399 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2400 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2401 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2402 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */ |
| 2403 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O; |
| 2404 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR})); |
| 2405 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */ |
| 2406 | f_establish_fully(ass_cmd, exp_compl); |
| 2407 | } |
| 2408 | |
| 2409 | /* Request a HR channel while all FR channels are exhausted, this is expected |
| 2410 | * to work without conflicts */ |
| 2411 | testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT { |
| 2412 | var MSC_ConnHdlr vc_conn; |
| 2413 | f_init(1, true); |
| 2414 | f_sleep(1.0); |
| 2415 | f_enable_all_tch(); |
| 2416 | f_disable_all_tch_f(); |
| 2417 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr)); |
| 2418 | vc_conn.done; |
| 2419 | f_enable_all_tch(); |
| 2420 | setverdict(pass); |
| 2421 | } |
| 2422 | |
| 2423 | /* Request a FR channel while all FR channels are exhausted, this is expected |
| 2424 | * to fail. */ |
| 2425 | testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT { |
| 2426 | var MSC_ConnHdlr vc_conn; |
| 2427 | f_init(1, true); |
| 2428 | f_sleep(1.0); |
| 2429 | f_enable_all_tch(); |
| 2430 | f_disable_all_tch_f(); |
| 2431 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail)); |
| 2432 | vc_conn.done; |
| 2433 | f_enable_all_tch(); |
| 2434 | setverdict(pass); |
| 2435 | } |
| 2436 | |
| 2437 | /* Request a FR (prefered) or alternatively a HR channel while all FR channels |
| 2438 | * are exhausted, this is expected to be resolved by selecting a HR channel. */ |
| 2439 | testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT { |
| 2440 | var MSC_ConnHdlr vc_conn; |
| 2441 | f_init(1, true); |
| 2442 | f_sleep(1.0); |
| 2443 | f_enable_all_tch(); |
| 2444 | f_disable_all_tch_f(); |
| 2445 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr)); |
| 2446 | vc_conn.done; |
| 2447 | f_enable_all_tch(); |
| 2448 | setverdict(pass); |
| 2449 | } |
| 2450 | |
| 2451 | /* Request a HR (prefered) or alternatively a FR channel while all FR channels |
| 2452 | * are exhausted, this is expected to work without conflicts. */ |
| 2453 | testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT { |
| 2454 | var MSC_ConnHdlr vc_conn; |
| 2455 | f_init(1, true); |
| 2456 | f_sleep(1.0); |
| 2457 | f_enable_all_tch(); |
| 2458 | f_disable_all_tch_f(); |
| 2459 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr)); |
| 2460 | vc_conn.done; |
| 2461 | f_enable_all_tch(); |
| 2462 | setverdict(pass); |
| 2463 | } |
| 2464 | |
| 2465 | /* Request a FR channel while all HR channels are exhausted, this is expected |
| 2466 | * to work without conflicts */ |
| 2467 | testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT { |
| 2468 | var MSC_ConnHdlr vc_conn; |
| 2469 | f_init(1, true); |
| 2470 | f_sleep(1.0); |
| 2471 | f_enable_all_tch(); |
| 2472 | f_disable_all_tch_h(); |
| 2473 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr)); |
| 2474 | vc_conn.done; |
| 2475 | f_enable_all_tch(); |
| 2476 | setverdict(pass); |
| 2477 | } |
| 2478 | |
| 2479 | /* Request a HR channel while all HR channels are exhausted, this is expected |
| 2480 | * to fail. */ |
| 2481 | testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT { |
| 2482 | var MSC_ConnHdlr vc_conn; |
| 2483 | f_init(1, true); |
| 2484 | f_sleep(1.0); |
| 2485 | f_enable_all_tch(); |
| 2486 | f_disable_all_tch_h(); |
| 2487 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail)); |
| 2488 | vc_conn.done; |
| 2489 | f_enable_all_tch(); |
| 2490 | setverdict(pass); |
| 2491 | } |
| 2492 | |
| 2493 | /* Request a HR (prefered) or alternatively a FR channel while all HR channels |
| 2494 | * are exhausted, this is expected to be resolved by selecting a FR channel. */ |
| 2495 | testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT { |
| 2496 | var MSC_ConnHdlr vc_conn; |
| 2497 | f_init(1, true); |
| 2498 | f_sleep(1.0); |
| 2499 | f_enable_all_tch(); |
| 2500 | f_disable_all_tch_h(); |
| 2501 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr)); |
| 2502 | vc_conn.done; |
| 2503 | f_enable_all_tch(); |
| 2504 | setverdict(pass); |
| 2505 | } |
| 2506 | |
| 2507 | /* Request a FR (prefered) or alternatively a HR channel while all HR channels |
| 2508 | * are exhausted, this is expected to work without conflicts. */ |
| 2509 | testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT { |
| 2510 | var MSC_ConnHdlr vc_conn; |
| 2511 | f_init(1, true); |
| 2512 | f_sleep(1.0); |
| 2513 | f_enable_all_tch(); |
| 2514 | f_disable_all_tch_h(); |
| 2515 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr)); |
| 2516 | vc_conn.done; |
| 2517 | f_enable_all_tch(); |
| 2518 | setverdict(pass); |
| 2519 | } |
| 2520 | |
| 2521 | /* Allow FR and HR, but prefer HR */ |
| 2522 | private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr { |
| 2523 | g_pars := f_gen_test_hdlr_pars(); |
| 2524 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2525 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2526 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2527 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */ |
| 2528 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O; |
| 2529 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR})); |
| 2530 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */ |
| 2531 | f_establish_fully(ass_cmd, exp_compl); |
| 2532 | } |
| 2533 | |
| 2534 | /* Allow FR and HR, but prefer FR */ |
| 2535 | private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr { |
| 2536 | g_pars := f_gen_test_hdlr_pars(); |
| 2537 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
| 2538 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2539 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2540 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */ |
| 2541 | ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O; |
| 2542 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR})); |
| 2543 | exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */ |
| 2544 | f_establish_fully(ass_cmd, exp_compl); |
| 2545 | } |
| 2546 | |
| 2547 | /* Request a HR (prefered) or alternatively a FR channel, it is expected that |
| 2548 | * HR, which is the prefered type, is selected. */ |
| 2549 | testcase TC_assignment_codec_req_hr_fr() runs on test_CT { |
| 2550 | var MSC_ConnHdlr vc_conn; |
| 2551 | f_init(1, true); |
| 2552 | f_sleep(1.0); |
| 2553 | f_enable_all_tch(); |
| 2554 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr)); |
| 2555 | vc_conn.done; |
| 2556 | setverdict(pass); |
| 2557 | } |
| 2558 | |
| 2559 | /* Request a FR (prefered) or alternatively a HR channel, it is expected that |
| 2560 | * FR, which is the prefered type, is selected. */ |
| 2561 | testcase TC_assignment_codec_req_fr_hr() runs on test_CT { |
| 2562 | var MSC_ConnHdlr vc_conn; |
| 2563 | f_init(1, true); |
| 2564 | f_sleep(1.0); |
| 2565 | f_enable_all_tch(); |
| 2566 | vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr)); |
| 2567 | vc_conn.done; |
| 2568 | setverdict(pass); |
| 2569 | } |
| 2570 | |
Neels Hofmeyr | 92b12b7 | 2018-09-18 14:30:23 +0200 | [diff] [blame] | 2571 | /* test the procedure of the MSC requesting a Classmark Update: |
| 2572 | * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY, |
| 2573 | * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */ |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2574 | private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2575 | g_pars := f_gen_test_hdlr_pars(); |
| 2576 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 2577 | f_create_chan_and_exp(); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2578 | /* we should now have a COMPL_L3 at the MSC */ |
| 2579 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 2580 | |
Neels Hofmeyr | 92b12b7 | 2018-09-18 14:30:23 +0200 | [diff] [blame] | 2581 | BSSAP.send(ts_BSSMAP_ClassmarkRequest); |
| 2582 | RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY)); |
| 2583 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2584 | f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2))); |
| 2585 | BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit)); |
| 2586 | setverdict(pass); |
| 2587 | } |
| 2588 | testcase TC_classmark() runs on test_CT { |
| 2589 | var MSC_ConnHdlr vc_conn; |
| 2590 | f_init(1, true); |
| 2591 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2592 | vc_conn := f_start_handler(refers(f_tc_classmark)); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2593 | vc_conn.done; |
| 2594 | } |
| 2595 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2596 | private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2597 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 2598 | f_create_chan_and_exp(); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2599 | /* we should now have a COMPL_L3 at the MSC */ |
| 2600 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 2601 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2602 | /* send the single message we want to send */ |
| 2603 | f_rsl_send_l3(l3); |
| 2604 | } |
| 2605 | |
| 2606 | private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr { |
| 2607 | timer T := sec; |
| 2608 | var PDU_BSSAP bssap; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2609 | T.start; |
| 2610 | alt { |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2611 | [] BSSAP.receive(PDU_BSSAP:?) -> value bssap { |
| 2612 | setverdict(fail, "Unexpected BSSMAP ", bssap); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2613 | mtc.stop; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2614 | } |
| 2615 | [] T.timeout { |
| 2616 | setverdict(pass); |
| 2617 | } |
| 2618 | } |
| 2619 | } |
| 2620 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2621 | /* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 2622 | private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr { |
| 2623 | f_est_single_l3(ts_RRM_AssignmentFailure('00'O)); |
| 2624 | f_bssap_expect_nothing(); |
| 2625 | } |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2626 | testcase TC_unsol_ass_fail() runs on test_CT { |
| 2627 | var MSC_ConnHdlr vc_conn; |
| 2628 | f_init(1, true); |
| 2629 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2630 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail)); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2631 | vc_conn.done; |
| 2632 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 2633 | |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 2634 | |
| 2635 | /* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */ |
| 2636 | private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2637 | f_est_single_l3(ts_RRM_AssignmentComplete('00'O)); |
| 2638 | f_bssap_expect_nothing(); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 2639 | } |
| 2640 | testcase TC_unsol_ass_compl() runs on test_CT { |
| 2641 | var MSC_ConnHdlr vc_conn; |
| 2642 | f_init(1, true); |
| 2643 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2644 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl)); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 2645 | vc_conn.done; |
| 2646 | } |
| 2647 | |
| 2648 | |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 2649 | /* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 2650 | private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2651 | f_est_single_l3(ts_RRM_HandoverFailure('00'O)); |
| 2652 | f_bssap_expect_nothing(); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 2653 | } |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 2654 | testcase TC_unsol_ho_fail() runs on test_CT { |
| 2655 | var MSC_ConnHdlr vc_conn; |
| 2656 | f_init(1, true); |
| 2657 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2658 | vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail)); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 2659 | vc_conn.done; |
| 2660 | } |
| 2661 | |
| 2662 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2663 | /* short message from MS should be ignored */ |
| 2664 | private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2665 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 2666 | f_create_chan_and_exp(); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2667 | /* we should now have a COMPL_L3 at the MSC */ |
| 2668 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 2669 | |
| 2670 | /* send short message */ |
| 2671 | RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O)); |
| 2672 | f_bssap_expect_nothing(); |
| 2673 | } |
| 2674 | testcase TC_err_82_short_msg() runs on test_CT { |
| 2675 | var MSC_ConnHdlr vc_conn; |
| 2676 | f_init(1, true); |
| 2677 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2678 | vc_conn := f_start_handler(refers(f_tc_err_82_short_msg)); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2679 | vc_conn.done; |
| 2680 | } |
| 2681 | |
| 2682 | |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 2683 | /* 24.008 8.4 Unknown message must trigger RR STATUS */ |
| 2684 | private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr { |
| 2685 | f_est_single_l3(ts_RRM_UL_REL('00'O)); |
| 2686 | timer T := 3.0 |
| 2687 | alt { |
| 2688 | [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) { |
| 2689 | setverdict(pass); |
| 2690 | } |
| 2691 | [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); } |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 2692 | [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); } |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 2693 | } |
| 2694 | } |
| 2695 | testcase TC_err_84_unknown_msg() runs on test_CT { |
| 2696 | var MSC_ConnHdlr vc_conn; |
| 2697 | f_init(1, true); |
| 2698 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2699 | vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg)); |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 2700 | vc_conn.done; |
| 2701 | } |
| 2702 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 2703 | /*********************************************************************** |
| 2704 | * Handover |
| 2705 | ***********************************************************************/ |
| 2706 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 2707 | /* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */ |
| 2708 | private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr) |
| 2709 | runs on test_CT { |
| 2710 | var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)& |
| 2711 | " timeslot "&int2str(ts_nr)&" "; |
| 2712 | f_vty_transceive(BSCVTY, cmd & suffix); |
| 2713 | } |
| 2714 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2715 | /* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */ |
| 2716 | private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr) |
| 2717 | runs on MSC_ConnHdlr { |
| 2718 | /* FIXME: resolve those from component-global state */ |
| 2719 | var integer ts_nr := chan_nr.tn; |
| 2720 | var integer ss_nr; |
| 2721 | if (ischosen(chan_nr.u.ch0)) { |
| 2722 | ss_nr := 0; |
| 2723 | } else if (ischosen(chan_nr.u.lm)) { |
| 2724 | ss_nr := chan_nr.u.lm.sub_chan; |
| 2725 | } else if (ischosen(chan_nr.u.sdcch4)) { |
| 2726 | ss_nr := chan_nr.u.sdcch4.sub_chan; |
| 2727 | } else if (ischosen(chan_nr.u.sdcch8)) { |
| 2728 | ss_nr := chan_nr.u.sdcch8.sub_chan; |
| 2729 | } else { |
| 2730 | setverdict(fail, "Invalid ChanNr ", chan_nr); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2731 | mtc.stop; |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)& |
| 2735 | " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" "; |
| 2736 | f_vty_transceive(BSCVTY, cmd & suffix); |
| 2737 | } |
| 2738 | |
| 2739 | private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr, |
| 2740 | integer new_bts_nr) |
| 2741 | runs on MSC_ConnHdlr { |
| 2742 | f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr); |
| 2743 | } |
| 2744 | |
| 2745 | /* intra-BSC hand-over between BTS0 and BTS1 */ |
| 2746 | private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2747 | g_pars := f_gen_test_hdlr_pars(); |
Harald Welte | ed84851 | 2018-05-24 22:27:58 +0200 | [diff] [blame] | 2748 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2749 | var PDU_BSSAP ass_cmd := f_gen_ass_req(); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2750 | const OCT8 kc := '0001020304050607'O; |
| 2751 | |
| 2752 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2753 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2754 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 2755 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2756 | |
| 2757 | var HandoverState hs := { |
| 2758 | rr_ho_cmpl_seen := false, |
| 2759 | handover_done := false, |
| 2760 | old_chan_nr := - |
| 2761 | }; |
| 2762 | /* issue hand-over command on VTY */ |
| 2763 | f_vty_handover(0, 0, g_chan_nr, 1); |
| 2764 | /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */ |
| 2765 | f_rslem_suspend(RSL1_PROC); |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 2766 | |
| 2767 | /* From the MGW perspective, a handover is is characterized by |
| 2768 | * performing one MDCX operation with the MGW. So we expect to see |
| 2769 | * one more MDCX during handover. */ |
| 2770 | g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1; |
| 2771 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2772 | alt { |
| 2773 | [] as_handover(hs); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2774 | } |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 2775 | |
Philipp Maier | 4dae065 | 2018-11-12 12:03:26 +0100 | [diff] [blame] | 2776 | /* Since this is an internal handover we expect the BSC to inform the |
| 2777 | * MSC about the event */ |
| 2778 | BSSAP.receive(tr_BSSMAP_HandoverPerformed); |
| 2779 | |
Philipp Maier | 3e2af5d | 2018-07-11 17:01:05 +0200 | [diff] [blame] | 2780 | /* Check the amount of MGCP transactions is still consistant with the |
| 2781 | * test expectation */ |
| 2782 | f_check_mgcp_expectations() |
Neels Hofmeyr | 861a4c1 | 2018-11-07 01:23:17 +0100 | [diff] [blame] | 2783 | f_sleep(0.5); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | testcase TC_ho_int() runs on test_CT { |
| 2787 | var MSC_ConnHdlr vc_conn; |
| 2788 | f_init(2, true); |
| 2789 | f_sleep(1.0); |
Harald Welte | 8863fa1 | 2018-05-10 20:15:27 +0200 | [diff] [blame] | 2790 | vc_conn := f_start_handler(refers(f_tc_ho_int)); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2791 | vc_conn.done; |
| 2792 | } |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 2793 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 2794 | private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr { |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 2795 | g_pars := f_gen_test_hdlr_pars(); |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 2796 | |
| 2797 | var PDU_BSSAP ass_req := f_gen_ass_req(); |
| 2798 | ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2799 | ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2800 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2801 | f_establish_fully(ass_req, exp_compl); |
| 2802 | |
| 2803 | f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any"); |
| 2804 | |
| 2805 | BSSAP.receive(tr_BSSMAP_HandoverRequired); |
| 2806 | |
| 2807 | f_sleep(0.5); |
| 2808 | /* The MSC negotiates Handover Request and Handover Request Ack with |
| 2809 | * the other BSS and comes back with a BSSMAP Handover Command |
| 2810 | * containing an RR Handover Command coming from the target BSS... */ |
| 2811 | |
| 2812 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 2813 | log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd); |
| 2814 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 2815 | log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc); |
| 2816 | BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc)); |
| 2817 | |
| 2818 | /* expect the Handover Command to go out on RR */ |
| 2819 | var RSL_Message rsl_ho_cmd |
| 2820 | RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd; |
| 2821 | log("RSL Data Req went out to first BTS: ", rsl_ho_cmd); |
| 2822 | var RSL_IE_Body rsl_ho_cmd_l3; |
| 2823 | if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) { |
| 2824 | log("RSL message contains no L3 Info IE, expected RR Handover Command"); |
| 2825 | setverdict(fail); |
| 2826 | } else { |
| 2827 | log("Found L3 Info: ", rsl_ho_cmd_l3); |
| 2828 | if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) { |
| 2829 | log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded."); |
| 2830 | setverdict(fail); |
| 2831 | } else { |
| 2832 | log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded."); |
| 2833 | setverdict(pass); |
| 2834 | } |
| 2835 | } |
| 2836 | |
| 2837 | /* When the other BSS has reported a completed handover, this side is |
| 2838 | * torn down. */ |
| 2839 | |
| 2840 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL; |
| 2841 | var BssmapCause cause := enum2int(cause_val); |
| 2842 | BSSAP.send(ts_BSSMAP_ClearCommand(cause)); |
| 2843 | |
| 2844 | /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */ |
| 2845 | var MgcpCommand mgcp; |
| 2846 | interleave { |
| 2847 | [] BSSAP.receive(tr_BSSMAP_ClearComplete); |
| 2848 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 2849 | log("Got first DLCX: ", mgcp); |
| 2850 | } |
| 2851 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 2852 | log("Got second DLCX: ", mgcp); |
| 2853 | } |
| 2854 | } |
| 2855 | setverdict(pass); |
| 2856 | f_sleep(1.0); |
| 2857 | } |
| 2858 | testcase TC_ho_out_of_this_bsc() runs on test_CT { |
| 2859 | var MSC_ConnHdlr vc_conn; |
| 2860 | |
| 2861 | f_init(1, true); |
| 2862 | f_sleep(1.0); |
| 2863 | |
| 2864 | vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc)); |
| 2865 | vc_conn.done; |
| 2866 | } |
| 2867 | |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 2868 | /* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and |
| 2869 | * simply never sends a BSSMAP Handover Command. */ |
| 2870 | private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr { |
Daniel Willmann | 3b59eb5 | 2018-10-29 15:40:55 +0100 | [diff] [blame] | 2871 | g_pars := f_gen_test_hdlr_pars(); |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 2872 | |
| 2873 | var PDU_BSSAP ass_req := f_gen_ass_req(); |
| 2874 | ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2875 | ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2876 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2877 | f_establish_fully(ass_req, exp_compl); |
| 2878 | |
| 2879 | f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any"); |
| 2880 | |
| 2881 | BSSAP.receive(tr_BSSMAP_HandoverRequired); |
| 2882 | |
| 2883 | /* osmo-bsc should time out 10 seconds after the handover started. |
| 2884 | * Let's give it a bit extra. */ |
| 2885 | f_sleep(15.0); |
| 2886 | |
| 2887 | /* The old lchan and conn should still be active. See that arbitrary L3 |
| 2888 | * is still going through. */ |
| 2889 | var octetstring l3 := '0123456789'O; |
| 2890 | RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 2891 | var template PDU_BSSAP exp_data := { |
| 2892 | discriminator := '1'B, |
| 2893 | spare := '0000000'B, |
| 2894 | dlci := '00'O, |
| 2895 | lengthIndicator := 5, |
| 2896 | pdu := { |
| 2897 | dtap := l3 |
| 2898 | } |
| 2899 | }; |
| 2900 | BSSAP.receive(exp_data); |
| 2901 | setverdict(pass); |
| 2902 | f_sleep(1.0); |
| 2903 | } |
| 2904 | testcase TC_ho_out_fail_no_msc_response() runs on test_CT { |
| 2905 | var MSC_ConnHdlr vc_conn; |
| 2906 | |
| 2907 | f_init(1, true); |
| 2908 | f_sleep(1.0); |
| 2909 | |
| 2910 | vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response)); |
| 2911 | vc_conn.done; |
| 2912 | } |
| 2913 | |
| 2914 | /* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports |
| 2915 | * RR Handover Failure. */ |
| 2916 | private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr { |
Daniel Willmann | 3b59eb5 | 2018-10-29 15:40:55 +0100 | [diff] [blame] | 2917 | g_pars := f_gen_test_hdlr_pars(); |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 2918 | |
| 2919 | var PDU_BSSAP ass_req := f_gen_ass_req(); |
| 2920 | ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 2921 | ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 2922 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 2923 | f_establish_fully(ass_req, exp_compl); |
| 2924 | |
| 2925 | f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any"); |
| 2926 | |
| 2927 | BSSAP.receive(tr_BSSMAP_HandoverRequired); |
| 2928 | |
| 2929 | f_sleep(0.5); |
| 2930 | /* The MSC negotiates Handover Request and Handover Request Ack with |
| 2931 | * the other BSS and comes back with a BSSMAP Handover Command |
| 2932 | * containing an RR Handover Command coming from the target BSS... */ |
| 2933 | |
| 2934 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 2935 | log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd); |
| 2936 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 2937 | log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc); |
| 2938 | BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc)); |
| 2939 | |
| 2940 | /* expect the Handover Command to go out on RR */ |
| 2941 | var RSL_Message rsl_ho_cmd |
| 2942 | RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd; |
| 2943 | log("RSL Data Req went out to first BTS: ", rsl_ho_cmd); |
| 2944 | var RSL_IE_Body rsl_ho_cmd_l3; |
| 2945 | if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) { |
| 2946 | log("RSL message contains no L3 Info IE, expected RR Handover Command"); |
| 2947 | setverdict(fail); |
| 2948 | } else { |
| 2949 | log("Found L3 Info: ", rsl_ho_cmd_l3); |
| 2950 | if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) { |
| 2951 | log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded."); |
| 2952 | setverdict(fail); |
| 2953 | } else { |
| 2954 | log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded."); |
| 2955 | setverdict(pass); |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | f_sleep(0.2); |
| 2960 | f_rsl_send_l3(ts_RRM_HandoverFailure('00'O)); |
| 2961 | |
| 2962 | /* Should tell the MSC about the failure */ |
| 2963 | BSSAP.receive(tr_BSSMAP_HandoverFailure); |
| 2964 | |
| 2965 | f_sleep(1.0); |
| 2966 | |
| 2967 | /* The old lchan and conn should still be active. See that arbitrary L3 |
| 2968 | * is still going through. */ |
| 2969 | var octetstring l3 := '0123456789'O; |
| 2970 | RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 2971 | var template PDU_BSSAP exp_data := { |
| 2972 | discriminator := '1'B, |
| 2973 | spare := '0000000'B, |
| 2974 | dlci := '00'O, |
| 2975 | lengthIndicator := 5, |
| 2976 | pdu := { |
| 2977 | dtap := l3 |
| 2978 | } |
| 2979 | }; |
| 2980 | BSSAP.receive(exp_data); |
| 2981 | setverdict(pass); |
| 2982 | f_sleep(1.0); |
| 2983 | |
| 2984 | setverdict(pass); |
| 2985 | f_sleep(1.0); |
| 2986 | } |
| 2987 | testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT { |
| 2988 | var MSC_ConnHdlr vc_conn; |
| 2989 | |
| 2990 | f_init(1, true); |
| 2991 | f_sleep(1.0); |
| 2992 | |
| 2993 | vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure)); |
| 2994 | vc_conn.done; |
| 2995 | } |
| 2996 | |
| 2997 | /* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports |
| 2998 | * RR Handover Failure. */ |
| 2999 | private function f_tc_ho_out_fail_no_ho_detect(charstring id) runs on MSC_ConnHdlr { |
Daniel Willmann | 3b59eb5 | 2018-10-29 15:40:55 +0100 | [diff] [blame] | 3000 | g_pars := f_gen_test_hdlr_pars(); |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 3001 | |
| 3002 | var PDU_BSSAP ass_req := f_gen_ass_req(); |
| 3003 | ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 3004 | ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 3005 | var template PDU_BSSAP exp_compl := f_gen_exp_compl(); |
| 3006 | f_establish_fully(ass_req, exp_compl); |
| 3007 | |
| 3008 | f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any"); |
| 3009 | |
| 3010 | BSSAP.receive(tr_BSSMAP_HandoverRequired); |
| 3011 | |
| 3012 | f_sleep(0.5); |
| 3013 | /* The MSC negotiates Handover Request and Handover Request Ack with |
| 3014 | * the other BSS and comes back with a BSSMAP Handover Command |
| 3015 | * containing an RR Handover Command coming from the target BSS... */ |
| 3016 | |
| 3017 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 3018 | log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd); |
| 3019 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 3020 | log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc); |
| 3021 | BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc)); |
| 3022 | |
| 3023 | /* expect the Handover Command to go out on RR */ |
| 3024 | var RSL_Message rsl_ho_cmd |
| 3025 | RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd; |
| 3026 | log("RSL Data Req went out to first BTS: ", rsl_ho_cmd); |
| 3027 | var RSL_IE_Body rsl_ho_cmd_l3; |
| 3028 | if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) { |
| 3029 | log("RSL message contains no L3 Info IE, expected RR Handover Command"); |
| 3030 | setverdict(fail); |
| 3031 | } else { |
| 3032 | log("Found L3 Info: ", rsl_ho_cmd_l3); |
| 3033 | if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) { |
| 3034 | log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded."); |
| 3035 | setverdict(fail); |
| 3036 | } else { |
| 3037 | log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded."); |
| 3038 | setverdict(pass); |
| 3039 | } |
| 3040 | } |
| 3041 | |
| 3042 | /* The MS never shows up on the remote BSS. Eventually the BSC times |
| 3043 | * out and we run into 3GPP TS 48.008 3.1.5.3.3 "Abnormal Conditions": |
| 3044 | * RR should be released and Clear Request should go to the MSC. */ |
| 3045 | |
| 3046 | var MgcpCommand mgcp; |
| 3047 | interleave { |
Neels Hofmeyr | 861a4c1 | 2018-11-07 01:23:17 +0100 | [diff] [blame] | 3048 | [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) { |
| 3049 | log("Got Deact SACCH"); |
| 3050 | } |
Harald Welte | 924b6ea | 2019-02-04 01:05:34 +0100 | [diff] [blame] | 3051 | [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) { |
Neels Hofmeyr | 211169d | 2018-11-07 00:37:29 +0100 | [diff] [blame] | 3052 | log("Got RR Release"); |
| 3053 | } |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 3054 | [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) { |
| 3055 | log("Got RF Chan Rel"); |
| 3056 | RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
| 3057 | } |
| 3058 | [] BSSAP.receive(tr_BSSMAP_ClearRequest) { |
| 3059 | log("Got BSSMAP Clear Request"); |
| 3060 | } |
| 3061 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3062 | log("Got first DLCX: ", mgcp); |
| 3063 | } |
| 3064 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3065 | log("Got second DLCX: ", mgcp); |
| 3066 | } |
| 3067 | } |
| 3068 | |
| 3069 | setverdict(pass); |
| 3070 | f_sleep(1.0); |
| 3071 | } |
| 3072 | testcase TC_ho_out_fail_no_ho_detect() runs on test_CT { |
| 3073 | var MSC_ConnHdlr vc_conn; |
| 3074 | |
| 3075 | f_init(1, true); |
| 3076 | f_sleep(1.0); |
| 3077 | |
| 3078 | vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_ho_detect)); |
| 3079 | vc_conn.done; |
| 3080 | } |
| 3081 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 3082 | private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr { |
| 3083 | /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the |
| 3084 | * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting |
| 3085 | * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we |
| 3086 | * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation |
| 3087 | * before we get started. */ |
| 3088 | var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH)); |
| 3089 | f_rslem_register(0, new_chan_nr); |
| 3090 | g_chan_nr := new_chan_nr; |
| 3091 | f_sleep(1.0); |
| 3092 | |
| 3093 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3094 | f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR); |
| 3095 | activate(as_Media()); |
| 3096 | |
| 3097 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc, |
| 3098 | f_gen_handover_req())); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3099 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND); |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 3100 | |
| 3101 | /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */ |
| 3102 | |
| 3103 | var PDU_BSSAP rx_bssap; |
| 3104 | var octetstring ho_command_str; |
| 3105 | |
| 3106 | BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap; |
| 3107 | |
| 3108 | ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info; |
| 3109 | log("Received L3 Info in HO Request Ack: ", ho_command_str); |
| 3110 | var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str); |
| 3111 | log("L3 Info in HO Request Ack is ", ho_command); |
| 3112 | |
| 3113 | var GsmArfcn arfcn; |
| 3114 | var RslChannelNr actual_new_chan_nr; |
| 3115 | f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2, |
| 3116 | actual_new_chan_nr, arfcn); |
| 3117 | |
| 3118 | if (actual_new_chan_nr != new_chan_nr) { |
| 3119 | log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.", |
| 3120 | " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr); |
| 3121 | setverdict(fail); |
| 3122 | return; |
| 3123 | } |
| 3124 | log("Handover Command chan_nr is", actual_new_chan_nr); |
| 3125 | |
| 3126 | /* Now the MSC forwards the RR Handover Command to the other BSC, which |
| 3127 | * tells the MS to handover to the new lchan. Here comes the new MS on |
| 3128 | * the new lchan with a Handover RACH: */ |
| 3129 | |
| 3130 | /* send handover detect */ |
| 3131 | |
| 3132 | RSL.send(ts_RSL_HANDO_DET(new_chan_nr)); |
| 3133 | |
| 3134 | BSSAP.receive(tr_BSSMAP_HandoverDetect); |
| 3135 | |
| 3136 | /* send handover complete over the new channel */ |
| 3137 | |
| 3138 | var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O)); |
| 3139 | RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)), |
| 3140 | enc_PDU_ML3_MS_NW(l3_tx))); |
| 3141 | |
| 3142 | BSSAP.receive(tr_BSSMAP_HandoverComplete); |
| 3143 | setverdict(pass); |
| 3144 | } |
| 3145 | testcase TC_ho_into_this_bsc() runs on test_CT { |
| 3146 | var MSC_ConnHdlr vc_conn; |
Philipp Maier | 4860473 | 2018-10-09 15:00:37 +0200 | [diff] [blame] | 3147 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 3148 | |
| 3149 | f_init(1, true); |
| 3150 | f_sleep(1.0); |
| 3151 | |
| 3152 | pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own; |
| 3153 | pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer; |
| 3154 | |
| 3155 | vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars); |
| 3156 | vc_conn.done; |
| 3157 | } |
| 3158 | |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 3159 | private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr { |
| 3160 | var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH)); |
| 3161 | f_rslem_register(0, new_chan_nr); |
| 3162 | g_chan_nr := new_chan_nr; |
| 3163 | f_sleep(1.0); |
| 3164 | |
| 3165 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3166 | f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR); |
| 3167 | activate(as_Media()); |
| 3168 | |
| 3169 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc, |
| 3170 | f_gen_handover_req())); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3171 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 3172 | |
| 3173 | /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */ |
| 3174 | |
| 3175 | var PDU_BSSAP rx_bssap; |
| 3176 | var octetstring ho_command_str; |
| 3177 | |
| 3178 | BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap; |
| 3179 | |
| 3180 | ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info; |
| 3181 | log("Received L3 Info in HO Request Ack: ", ho_command_str); |
| 3182 | var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str); |
| 3183 | log("L3 Info in HO Request Ack is ", ho_command); |
| 3184 | |
| 3185 | var GsmArfcn arfcn; |
| 3186 | var RslChannelNr actual_new_chan_nr; |
| 3187 | f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2, |
| 3188 | actual_new_chan_nr, arfcn); |
| 3189 | |
| 3190 | if (actual_new_chan_nr != new_chan_nr) { |
| 3191 | log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.", |
| 3192 | " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr); |
| 3193 | setverdict(fail); |
| 3194 | return; |
| 3195 | } |
| 3196 | log("Handover Command chan_nr is", actual_new_chan_nr); |
| 3197 | |
| 3198 | /* Now the MSC forwards the RR Handover Command to the other BSC, which |
| 3199 | * tells the MS to handover to the new lchan. In this case, the MS |
| 3200 | * reports a Handover Failure to the old BSS, which forwards a BSSMAP |
| 3201 | * Handover Failure to the MSC. The procedure according to 3GPP TS |
| 3202 | * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a |
| 3203 | * BSSMAP Clear Command: */ |
| 3204 | |
| 3205 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION; |
| 3206 | var BssmapCause cause := enum2int(cause_val); |
| 3207 | BSSAP.send(ts_BSSMAP_ClearCommand(cause)); |
| 3208 | |
| 3209 | /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */ |
| 3210 | var MgcpCommand mgcp; |
| 3211 | interleave { |
| 3212 | [] BSSAP.receive(tr_BSSMAP_ClearComplete); |
| 3213 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3214 | log("Got first DLCX: ", mgcp); |
| 3215 | } |
| 3216 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3217 | log("Got second DLCX: ", mgcp); |
| 3218 | } |
| 3219 | } |
| 3220 | setverdict(pass); |
| 3221 | f_sleep(1.0); |
| 3222 | |
| 3223 | setverdict(pass); |
| 3224 | } |
| 3225 | testcase TC_ho_in_fail_msc_clears() runs on test_CT { |
| 3226 | var MSC_ConnHdlr vc_conn; |
| 3227 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 3228 | |
| 3229 | f_init(1, true); |
| 3230 | f_sleep(1.0); |
| 3231 | |
| 3232 | pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own; |
| 3233 | pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer; |
| 3234 | |
| 3235 | vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars); |
| 3236 | vc_conn.done; |
| 3237 | } |
| 3238 | |
| 3239 | private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr { |
| 3240 | /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the |
| 3241 | * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting |
| 3242 | * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we |
| 3243 | * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation |
| 3244 | * before we get started. */ |
| 3245 | var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH)); |
| 3246 | f_rslem_register(0, new_chan_nr); |
| 3247 | g_chan_nr := new_chan_nr; |
| 3248 | f_sleep(1.0); |
| 3249 | |
| 3250 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3251 | f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR); |
| 3252 | activate(as_Media()); |
| 3253 | |
| 3254 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc, |
| 3255 | f_gen_handover_req())); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3256 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 3257 | |
| 3258 | /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */ |
| 3259 | |
| 3260 | var PDU_BSSAP rx_bssap; |
| 3261 | var octetstring ho_command_str; |
| 3262 | |
| 3263 | BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap; |
| 3264 | |
| 3265 | ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info; |
| 3266 | log("Received L3 Info in HO Request Ack: ", ho_command_str); |
| 3267 | var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str); |
| 3268 | log("L3 Info in HO Request Ack is ", ho_command); |
| 3269 | |
| 3270 | var GsmArfcn arfcn; |
| 3271 | var RslChannelNr actual_new_chan_nr; |
| 3272 | f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2, |
| 3273 | actual_new_chan_nr, arfcn); |
| 3274 | |
| 3275 | if (actual_new_chan_nr != new_chan_nr) { |
| 3276 | log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.", |
| 3277 | " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr); |
| 3278 | setverdict(fail); |
| 3279 | return; |
| 3280 | } |
| 3281 | log("Handover Command chan_nr is", actual_new_chan_nr); |
| 3282 | |
| 3283 | /* Now the MSC forwards the RR Handover Command to the other BSC, which |
| 3284 | * tells the MS to handover to the new lchan. Here comes the new MS on |
| 3285 | * the new lchan with a Handover RACH: */ |
| 3286 | |
| 3287 | /* send handover detect */ |
| 3288 | |
| 3289 | RSL.send(ts_RSL_HANDO_DET(new_chan_nr)); |
| 3290 | |
| 3291 | BSSAP.receive(tr_BSSMAP_HandoverDetect); |
| 3292 | |
| 3293 | /* The MSC chooses to clear the connection now, maybe we got the |
| 3294 | * Handover RACH on the new cell but the MS still signaled Handover |
| 3295 | * Failure to the old BSS? */ |
| 3296 | |
| 3297 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION; |
| 3298 | var BssmapCause cause := enum2int(cause_val); |
| 3299 | BSSAP.send(ts_BSSMAP_ClearCommand(cause)); |
| 3300 | |
| 3301 | /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */ |
| 3302 | var MgcpCommand mgcp; |
| 3303 | interleave { |
| 3304 | [] BSSAP.receive(tr_BSSMAP_ClearComplete); |
| 3305 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3306 | log("Got first DLCX: ", mgcp); |
| 3307 | } |
| 3308 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3309 | log("Got second DLCX: ", mgcp); |
| 3310 | } |
| 3311 | } |
| 3312 | setverdict(pass); |
| 3313 | f_sleep(1.0); |
| 3314 | } |
| 3315 | testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT { |
| 3316 | var MSC_ConnHdlr vc_conn; |
| 3317 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 3318 | |
| 3319 | f_init(1, true); |
| 3320 | f_sleep(1.0); |
| 3321 | |
| 3322 | pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own; |
| 3323 | pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer; |
| 3324 | |
| 3325 | vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars); |
| 3326 | vc_conn.done; |
| 3327 | } |
| 3328 | |
| 3329 | /* The new BSS's lchan times out before the MSC decides that handover failed. */ |
| 3330 | private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr { |
| 3331 | var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH)); |
| 3332 | f_rslem_register(0, new_chan_nr); |
| 3333 | g_chan_nr := new_chan_nr; |
| 3334 | f_sleep(1.0); |
| 3335 | |
| 3336 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3337 | f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR); |
| 3338 | activate(as_Media()); |
| 3339 | |
| 3340 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc, |
| 3341 | f_gen_handover_req())); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3342 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 3343 | |
| 3344 | /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */ |
| 3345 | |
| 3346 | var PDU_BSSAP rx_bssap; |
| 3347 | var octetstring ho_command_str; |
| 3348 | |
| 3349 | BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap; |
| 3350 | |
| 3351 | ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info; |
| 3352 | log("Received L3 Info in HO Request Ack: ", ho_command_str); |
| 3353 | var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str); |
| 3354 | log("L3 Info in HO Request Ack is ", ho_command); |
| 3355 | |
| 3356 | var GsmArfcn arfcn; |
| 3357 | var RslChannelNr actual_new_chan_nr; |
| 3358 | f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2, |
| 3359 | actual_new_chan_nr, arfcn); |
| 3360 | |
| 3361 | if (actual_new_chan_nr != new_chan_nr) { |
| 3362 | log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.", |
| 3363 | " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr); |
| 3364 | setverdict(fail); |
| 3365 | return; |
| 3366 | } |
| 3367 | log("Handover Command chan_nr is", actual_new_chan_nr); |
| 3368 | |
| 3369 | /* Now the MSC forwards the RR Handover Command to the other BSC, which |
| 3370 | * tells the MS to handover to the new lchan. But the MS never shows up |
| 3371 | * on the new lchan. */ |
| 3372 | |
| 3373 | BSSAP.receive(tr_BSSMAP_HandoverFailure); |
| 3374 | |
| 3375 | /* Did osmo-bsc also send a Clear Request? */ |
| 3376 | timer T := 0.5; |
| 3377 | T.start; |
| 3378 | alt { |
| 3379 | [] BSSAP.receive(tr_BSSMAP_ClearRequest); |
| 3380 | [] T.timeout { } |
| 3381 | } |
| 3382 | |
| 3383 | /* MSC plays along with a Clear Command (no matter whether osmo-bsc |
| 3384 | * asked for it, this is a Handover Failure after all). */ |
| 3385 | |
| 3386 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION; |
| 3387 | var BssmapCause cause := enum2int(cause_val); |
| 3388 | BSSAP.send(ts_BSSMAP_ClearCommand(cause)); |
| 3389 | |
| 3390 | /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */ |
| 3391 | var MgcpCommand mgcp; |
| 3392 | interleave { |
| 3393 | [] BSSAP.receive(tr_BSSMAP_ClearComplete); |
| 3394 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3395 | log("Got first DLCX: ", mgcp); |
| 3396 | } |
| 3397 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3398 | log("Got second DLCX: ", mgcp); |
| 3399 | } |
| 3400 | } |
| 3401 | setverdict(pass); |
| 3402 | f_sleep(1.0); |
| 3403 | |
| 3404 | setverdict(pass); |
| 3405 | } |
| 3406 | testcase TC_ho_in_fail_no_detect() runs on test_CT { |
| 3407 | var MSC_ConnHdlr vc_conn; |
| 3408 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 3409 | |
| 3410 | f_init(1, true); |
| 3411 | f_sleep(1.0); |
| 3412 | |
| 3413 | pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own; |
| 3414 | pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer; |
| 3415 | |
| 3416 | vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars); |
| 3417 | vc_conn.done; |
| 3418 | } |
| 3419 | |
| 3420 | /* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */ |
| 3421 | private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr { |
| 3422 | var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH)); |
| 3423 | f_rslem_register(0, new_chan_nr); |
| 3424 | g_chan_nr := new_chan_nr; |
| 3425 | f_sleep(1.0); |
| 3426 | |
| 3427 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3428 | f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR); |
| 3429 | activate(as_Media()); |
| 3430 | |
| 3431 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.handover.sccp_addr_bsc, g_pars.handover.sccp_addr_msc, |
| 3432 | f_gen_handover_req())); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3433 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 3434 | |
| 3435 | /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */ |
| 3436 | |
| 3437 | var PDU_BSSAP rx_bssap; |
| 3438 | var octetstring ho_command_str; |
| 3439 | |
| 3440 | BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap; |
| 3441 | |
| 3442 | ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info; |
| 3443 | log("Received L3 Info in HO Request Ack: ", ho_command_str); |
| 3444 | var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str); |
| 3445 | log("L3 Info in HO Request Ack is ", ho_command); |
| 3446 | |
| 3447 | var GsmArfcn arfcn; |
| 3448 | var RslChannelNr actual_new_chan_nr; |
| 3449 | f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2, |
| 3450 | actual_new_chan_nr, arfcn); |
| 3451 | |
| 3452 | if (actual_new_chan_nr != new_chan_nr) { |
| 3453 | log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.", |
| 3454 | " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr); |
| 3455 | setverdict(fail); |
| 3456 | return; |
| 3457 | } |
| 3458 | log("Handover Command chan_nr is", actual_new_chan_nr); |
| 3459 | |
| 3460 | /* Now the MSC forwards the RR Handover Command to the other BSC, which |
| 3461 | * tells the MS to handover to the new lchan. But the MS never shows up |
| 3462 | * on the new lchan. */ |
| 3463 | |
| 3464 | BSSAP.receive(tr_BSSMAP_HandoverFailure); |
| 3465 | |
| 3466 | /* MSC plays dumb and sends no Clear Command */ |
| 3467 | |
| 3468 | /* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */ |
| 3469 | var PDU_BSSAP rx_clear_request; |
| 3470 | var MgcpCommand mgcp; |
| 3471 | interleave { |
| 3472 | [] BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request { |
| 3473 | var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue); |
| 3474 | BSSAP.send(ts_BSSMAP_ClearCommand(cause)); |
| 3475 | }; |
| 3476 | [] BSSAP.receive(tr_BSSMAP_ClearComplete); |
| 3477 | |
| 3478 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3479 | log("Got first DLCX: ", mgcp); |
| 3480 | } |
| 3481 | [] MGCP.receive(tr_DLCX()) -> value mgcp { |
| 3482 | log("Got second DLCX: ", mgcp); |
| 3483 | } |
| 3484 | } |
| 3485 | setverdict(pass); |
| 3486 | f_sleep(1.0); |
| 3487 | } |
| 3488 | testcase TC_ho_in_fail_no_detect2() runs on test_CT { |
| 3489 | var MSC_ConnHdlr vc_conn; |
| 3490 | var TestHdlrParams pars := f_gen_test_hdlr_pars(); |
| 3491 | |
| 3492 | f_init(1, true); |
| 3493 | f_sleep(1.0); |
| 3494 | |
| 3495 | pars.handover.sccp_addr_msc := g_bssap.sccp_addr_own; |
| 3496 | pars.handover.sccp_addr_bsc := g_bssap.sccp_addr_peer; |
| 3497 | |
| 3498 | vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars); |
| 3499 | vc_conn.done; |
| 3500 | } |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 3501 | |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 3502 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 3503 | * BSSMAP Reset just because of that. */ |
| 3504 | testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT { |
| 3505 | var default d; |
| 3506 | var integer i; |
| 3507 | var DchanTuple dt; |
| 3508 | |
| 3509 | f_init(); |
| 3510 | |
| 3511 | /* Wait for initial BSSMAP Reset to pass */ |
| 3512 | f_sleep(4.0); |
| 3513 | |
| 3514 | d := activate(no_bssmap_reset()); |
| 3515 | |
| 3516 | /* Setup up a number of connections and RLSD them again from the MSC |
| 3517 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 3518 | * Let's do it some more times for good measure. */ |
Harald Welte | c3260d9 | 2018-06-11 17:48:16 +0200 | [diff] [blame] | 3519 | for (i := 0; i < 4; i := i+1) { |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 3520 | /* Since we're doing a lot of runs, give each one a fresh |
| 3521 | * T_guard from the top. */ |
| 3522 | T_guard.start; |
| 3523 | |
| 3524 | /* Setup a BSSAP connection and clear it right away. This is |
| 3525 | * the MSC telling the BSC about a planned release, it's not an |
| 3526 | * erratic loss of a connection. */ |
Harald Welte | a189718 | 2018-06-11 13:53:09 +0200 | [diff] [blame] | 3527 | dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O); |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 3528 | |
| 3529 | /* MSC disconnects (RLSD). */ |
| 3530 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 3531 | } |
| 3532 | |
| 3533 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 3534 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 3535 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 3536 | f_sleep(4.0); |
| 3537 | |
| 3538 | deactivate(d); |
| 3539 | f_shutdown_helper(); |
| 3540 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 3541 | |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 3542 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 3543 | * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from |
| 3544 | * the MSC. */ |
| 3545 | testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT { |
| 3546 | var default d; |
| 3547 | var integer i; |
| 3548 | var DchanTuple dt; |
| 3549 | var BSSAP_N_DATA_ind rx_di; |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 3550 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL; |
| 3551 | var BssmapCause cause := enum2int(cause_val); |
| 3552 | |
| 3553 | f_init(); |
| 3554 | |
| 3555 | /* Wait for initial BSSMAP Reset to pass */ |
| 3556 | f_sleep(4.0); |
| 3557 | |
| 3558 | d := activate(no_bssmap_reset()); |
| 3559 | |
| 3560 | /* Setup up a number of connections and RLSD them again from the MSC |
| 3561 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 3562 | * Let's do it some more times for good measure. */ |
| 3563 | for (i := 0; i < 8; i := i+1) { |
| 3564 | /* Since we're doing a lot of runs, give each one a fresh |
| 3565 | * T_guard from the top. */ |
| 3566 | T_guard.start; |
| 3567 | |
| 3568 | /* Setup a BSSAP connection and clear it right away. This is |
| 3569 | * the MSC telling the BSC about a planned release, it's not an |
| 3570 | * erratic loss of a connection. */ |
Harald Welte | a189718 | 2018-06-11 13:53:09 +0200 | [diff] [blame] | 3571 | dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O); |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 3572 | |
| 3573 | /* Instruct BSC to clear channel */ |
| 3574 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 3575 | |
| 3576 | /* expect BSC to disable the channel */ |
Harald Welte | 641fcbe | 2018-06-14 10:58:35 +0200 | [diff] [blame] | 3577 | f_exp_chan_rel_and_clear(dt, 0); |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 3578 | } |
| 3579 | |
| 3580 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 3581 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 3582 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 3583 | f_sleep(4.0); |
| 3584 | |
| 3585 | deactivate(d); |
| 3586 | f_shutdown_helper(); |
| 3587 | } |
| 3588 | |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 3589 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 3590 | * BSSMAP Reset just because of that. Close connections from the MS side with a |
| 3591 | * Release Ind on RSL. */ |
| 3592 | testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT { |
| 3593 | var default d; |
| 3594 | var integer i; |
| 3595 | var DchanTuple dt; |
| 3596 | var BSSAP_N_DATA_ind rx_di; |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 3597 | var integer j; |
| 3598 | |
| 3599 | f_init(); |
| 3600 | |
| 3601 | /* Wait for initial BSSMAP Reset to pass */ |
| 3602 | f_sleep(4.0); |
| 3603 | |
| 3604 | d := activate(no_bssmap_reset()); |
| 3605 | |
| 3606 | /* Setup up a number of connections and RLSD them again from the MSC |
| 3607 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 3608 | * Let's do it some more times for good measure. */ |
| 3609 | for (i := 0; i < 8; i := i+1) { |
| 3610 | /* Since we're doing a lot of runs, give each one a fresh |
| 3611 | * T_guard from the top. */ |
| 3612 | T_guard.start; |
| 3613 | |
| 3614 | /* Setup a BSSAP connection and clear it right away. This is |
| 3615 | * the MSC telling the BSC about a planned release, it's not an |
| 3616 | * erratic loss of a connection. */ |
| 3617 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 3618 | |
| 3619 | /* simulate RLL REL IND */ |
| 3620 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 3621 | |
| 3622 | /* expect Clear Request on MSC side */ |
| 3623 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 3624 | |
| 3625 | /* Instruct BSC to clear channel */ |
| 3626 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 3627 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 3628 | |
| 3629 | /* expect BSC to disable the channel */ |
Harald Welte | 641fcbe | 2018-06-14 10:58:35 +0200 | [diff] [blame] | 3630 | f_exp_chan_rel_and_clear(dt, 0); |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 3631 | } |
| 3632 | |
| 3633 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 3634 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 3635 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 3636 | f_sleep(4.0); |
| 3637 | |
| 3638 | deactivate(d); |
| 3639 | f_shutdown_helper(); |
| 3640 | } |
| 3641 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3642 | /*********************************************************************** |
| 3643 | * IPA style dynamic PDCH |
| 3644 | ***********************************************************************/ |
| 3645 | |
| 3646 | private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr, |
| 3647 | template (omit) RSL_Cause nack := omit) |
| 3648 | runs on test_CT { |
| 3649 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr)); |
| 3650 | var RSL_Message rsl_unused; |
| 3651 | /* ask BSC via VTY to activate a given IPA style chan as PDCH */ |
| 3652 | f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr); |
| 3653 | /* expect the BSC to issue the related RSL command */ |
| 3654 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr)); |
| 3655 | if (istemplatekind(nack, "omit")) { |
| 3656 | /* respond with a related acknowledgement */ |
| 3657 | f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342))); |
| 3658 | } else { |
| 3659 | f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack))); |
| 3660 | } |
| 3661 | } |
| 3662 | |
| 3663 | private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr, |
| 3664 | template (omit) RSL_Cause nack := omit) |
| 3665 | runs on test_CT { |
| 3666 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr)); |
| 3667 | var RSL_Message rsl_unused; |
| 3668 | /* ask BSC via VTY to activate a given IPA style chan as PDCH */ |
| 3669 | f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr); |
| 3670 | /* expect the BSC to issue the related RSL command */ |
| 3671 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr)); |
| 3672 | if (istemplatekind(nack, "omit")) { |
| 3673 | /* respond with a related acknowledgement */ |
| 3674 | f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr)); |
| 3675 | } else { |
| 3676 | f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack))); |
| 3677 | } |
| 3678 | } |
| 3679 | |
| 3680 | private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr) |
| 3681 | runs on test_CT return charstring { |
| 3682 | var charstring cmd, resp; |
| 3683 | cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr); |
Stefan Sperling | cff1356 | 2018-11-13 15:24:06 +0100 | [diff] [blame] | 3684 | return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr, |
| 3688 | template charstring exp) |
| 3689 | runs on test_CT { |
| 3690 | var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr); |
| 3691 | if (not match(mode, exp)) { |
| 3692 | setverdict(fail, "Unexpected TS Mode: ", mode); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3693 | mtc.stop; |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3694 | } |
| 3695 | } |
| 3696 | |
| 3697 | private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb) |
| 3698 | runs on test_CT { |
| 3699 | f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr); |
| 3700 | f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb); |
| 3701 | f_vty_transceive(BSCVTY, "end"); |
| 3702 | } |
| 3703 | |
| 3704 | private const charstring TCHF_MODE := "TCH/F mode"; |
| 3705 | private const charstring TCHH_MODE := "TCH/H mode"; |
| 3706 | private const charstring PDCH_MODE := "PDCH mode"; |
| 3707 | private const charstring NONE_MODE := "NONE mode"; |
| 3708 | |
| 3709 | /* Test IPA PDCH activation / deactivation triggered by VTY */ |
| 3710 | testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT { |
| 3711 | var RSL_Message rsl_unused; |
| 3712 | |
| 3713 | /* change Timeslot 6 before f_init() starts RSL */ |
| 3714 | f_init_vty(); |
| 3715 | f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH"); |
| 3716 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 3717 | |
| 3718 | f_init(1, false); |
| 3719 | f_sleep(1.0); |
| 3720 | |
| 3721 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6)); |
| 3722 | |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3723 | log("TCH/F_PDCH pchan starts out in TCH/F mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3724 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3725 | /* The BSC will activate the dynamic PDCH by default, so confirm that */ |
| 3726 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr)); |
| 3727 | f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342))); |
| 3728 | f_sleep(1.0); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3729 | log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3730 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE); |
| 3731 | |
| 3732 | /* De-activate it via VTY */ |
| 3733 | f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn); |
| 3734 | f_sleep(1.0); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3735 | log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3736 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3737 | |
| 3738 | /* re-activate it via VTY */ |
| 3739 | f_dyn_ipa_pdch_act(0, 0, chan_nr.tn); |
| 3740 | f_sleep(1.0); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3741 | log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3742 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE); |
| 3743 | |
| 3744 | /* and finally de-activate it again */ |
| 3745 | f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn); |
| 3746 | f_sleep(1.0); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3747 | log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3748 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3749 | |
Neels Hofmeyr | 887e8f1 | 2018-06-27 01:01:55 +0200 | [diff] [blame] | 3750 | /* clean up config */ |
| 3751 | f_ts_set_chcomb(0, 0, 6, "PDCH"); |
| 3752 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3753 | setverdict(pass); |
| 3754 | } |
| 3755 | |
| 3756 | /* Test IPA PDCH activation NACK */ |
| 3757 | testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT { |
| 3758 | var RSL_Message rsl_unused; |
| 3759 | |
| 3760 | /* change Timeslot 6 before f_init() starts RSL */ |
| 3761 | f_init_vty(); |
| 3762 | f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH"); |
| 3763 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 3764 | |
| 3765 | f_init(1, false); |
| 3766 | f_sleep(1.0); |
| 3767 | |
| 3768 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6)); |
| 3769 | |
| 3770 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3771 | /* The BSC will activate the dynamic PDCH by default, so confirm that */ |
| 3772 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr)); |
| 3773 | f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342))); |
| 3774 | f_sleep(1.0); |
| 3775 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE); |
| 3776 | |
| 3777 | /* De-activate it via VTY */ |
| 3778 | f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn); |
| 3779 | f_sleep(1.0); |
| 3780 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3781 | |
| 3782 | /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */ |
| 3783 | f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL); |
| 3784 | f_sleep(1.0); |
| 3785 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE); |
| 3786 | |
Neels Hofmeyr | 887e8f1 | 2018-06-27 01:01:55 +0200 | [diff] [blame] | 3787 | /* clean up config */ |
| 3788 | f_ts_set_chcomb(0, 0, 6, "PDCH"); |
| 3789 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3790 | setverdict(pass); |
| 3791 | } |
| 3792 | |
| 3793 | |
| 3794 | /*********************************************************************** |
| 3795 | * Osmocom style dynamic PDCH |
| 3796 | ***********************************************************************/ |
| 3797 | |
| 3798 | private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr, |
| 3799 | template (omit) RSL_Cause nack := omit) |
| 3800 | runs on test_CT { |
| 3801 | var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr)); |
| 3802 | var RSL_Message rsl_unused; |
| 3803 | /* ask BSC via VTY to activate a given IPA style chan as PDCH */ |
| 3804 | /* FIXME: no VTY command to activate Osmocom PDCH !! */ |
| 3805 | /* expect the BSC to issue the related RSL command */ |
| 3806 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?)); |
| 3807 | if (istemplatekind(nack, "omit")) { |
| 3808 | /* respond with a related acknowledgement */ |
| 3809 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342)); |
| 3810 | } else { |
| 3811 | f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack))); |
| 3812 | } |
| 3813 | } |
| 3814 | |
| 3815 | private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr, |
| 3816 | template (omit) RSL_Cause nack := omit) |
| 3817 | runs on test_CT { |
| 3818 | var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr)); |
| 3819 | var RSL_Message rsl_unused; |
| 3820 | /* ask BSC via VTY to activate a given IPA style chan as PDCH */ |
| 3821 | /* FIXME: no VTY command to activate Osmocom PDCH !! */ |
| 3822 | /* expect the BSC to issue the related RSL command */ |
| 3823 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr)); |
| 3824 | if (istemplatekind(nack, "omit")) { |
| 3825 | /* respond with a related acknowledgement */ |
| 3826 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr)); |
| 3827 | } else { |
| 3828 | //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack))); |
| 3829 | } |
| 3830 | } |
| 3831 | |
| 3832 | /* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */ |
| 3833 | testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT { |
| 3834 | var RSL_Message rsl_unused; |
| 3835 | |
| 3836 | /* change Timeslot 6 before f_init() starts RSL */ |
| 3837 | f_init_vty(); |
| 3838 | f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH"); |
| 3839 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 3840 | |
| 3841 | f_init(1, false); |
| 3842 | f_sleep(1.0); |
| 3843 | |
| 3844 | var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6)); |
| 3845 | |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3846 | log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3847 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE); |
| 3848 | /* The BSC will activate the dynamic PDCH by default, so confirm that */ |
| 3849 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?)); |
| 3850 | |
| 3851 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342)); |
| 3852 | f_sleep(1.0); |
Neels Hofmeyr | da4a695 | 2018-06-14 04:02:49 +0200 | [diff] [blame] | 3853 | log("TCH/F_TCH/H_PDCH requested to PDCH ACT on startup, which was ACKed, so now in PDCH:"); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3854 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE); |
| 3855 | |
Neels Hofmeyr | 887e8f1 | 2018-06-27 01:01:55 +0200 | [diff] [blame] | 3856 | /* clean up config */ |
| 3857 | f_ts_set_chcomb(0, 0, 6, "PDCH"); |
| 3858 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3859 | setverdict(pass); |
| 3860 | } |
| 3861 | |
| 3862 | /* Test Osmocom dyn PDCH activation NACK behavior */ |
| 3863 | testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT { |
| 3864 | var RSL_Message rsl_unused; |
| 3865 | |
| 3866 | /* change Timeslot 6 before f_init() starts RSL */ |
| 3867 | f_init_vty(); |
| 3868 | f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH"); |
| 3869 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 3870 | |
| 3871 | f_init(1, false); |
| 3872 | f_sleep(1.0); |
| 3873 | |
| 3874 | var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6)); |
| 3875 | |
| 3876 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE); |
| 3877 | /* The BSC will activate the dynamic PDCH by default, so confirm that */ |
| 3878 | rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?)); |
| 3879 | |
| 3880 | /* NACK this activation and expect the "show timeslot" mode still to be NONE */ |
| 3881 | f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL)); |
| 3882 | f_sleep(1.0); |
| 3883 | f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE); |
| 3884 | |
Neels Hofmeyr | 887e8f1 | 2018-06-27 01:01:55 +0200 | [diff] [blame] | 3885 | /* clean up config */ |
| 3886 | f_ts_set_chcomb(0, 0, 6, "PDCH"); |
| 3887 | |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3888 | setverdict(pass); |
| 3889 | } |
| 3890 | |
Stefan Sperling | 0796a82 | 2018-10-05 13:01:39 +0200 | [diff] [blame] | 3891 | testcase TC_chopped_ipa_ping() runs on test_CT { |
Stefan Sperling | 554123f | 2018-10-09 14:12:30 +0200 | [diff] [blame] | 3892 | const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port}; |
Stefan Sperling | 0796a82 | 2018-10-05 13:01:39 +0200 | [diff] [blame] | 3893 | for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) { |
| 3894 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER); |
| 3895 | } |
| 3896 | } |
| 3897 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 3898 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 3899 | const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port |
| 3900 | /* TODO: mp_bsc_ctrl_port does not work yet */}; |
| 3901 | for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) { |
| 3902 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER); |
| 3903 | } |
| 3904 | } |
| 3905 | |
| 3906 | |
Harald Welte | 0ea2d5e | 2018-04-07 21:40:29 +0200 | [diff] [blame] | 3907 | /* Dyn PDCH todo: |
| 3908 | * activate OSMO as TCH/F |
| 3909 | * activate OSMO as TCH/H |
| 3910 | * does the BSC-located PCU socket get the updated INFO? |
| 3911 | * what if no PCU is connected at the time? |
| 3912 | * is the info correct on delayed PCU (re)connect? |
| 3913 | */ |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 3914 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 3915 | control { |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 3916 | /* CTRL interface testing */ |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 3917 | execute( TC_ctrl_msc_connection_status() ); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 3918 | execute( TC_ctrl_msc0_connection_status() ); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 3919 | execute( TC_ctrl() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 3920 | |
| 3921 | /* RSL DCHAN Channel ACtivation / Deactivation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 3922 | execute( TC_chan_act_noreply() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 3923 | execute( TC_chan_act_counter() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 3924 | execute( TC_chan_act_ack_noest() ); |
| 3925 | execute( TC_chan_act_ack_est_ind_noreply() ); |
| 3926 | execute( TC_chan_act_ack_est_ind_refused() ); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 3927 | execute( TC_chan_act_nack() ); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 3928 | execute( TC_chan_exhaustion() ); |
Vadim Yanitskiy | 1ff1fdf | 2018-11-27 01:32:57 +0700 | [diff] [blame] | 3929 | execute( TC_chan_deact_silence() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 3930 | execute( TC_chan_rel_rll_rel_ind() ); |
| 3931 | execute( TC_chan_rel_conn_fail() ); |
| 3932 | execute( TC_chan_rel_hard_clear() ); |
Harald Welte | 9978710 | 2019-02-04 10:41:36 +0100 | [diff] [blame] | 3933 | execute( TC_chan_rel_hard_clear_csfb() ); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 3934 | execute( TC_chan_rel_hard_rlsd() ); |
Harald Welte | 550daf9 | 2018-06-11 19:22:13 +0200 | [diff] [blame] | 3935 | execute( TC_chan_rel_hard_rlsd_ms_dead() ); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 3936 | execute( TC_chan_rel_a_reset() ); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 3937 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 3938 | execute( TC_outbound_connect() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 3939 | |
| 3940 | /* Assignment related */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 3941 | execute( TC_assignment_cic_only() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 3942 | execute( TC_assignment_csd() ); |
| 3943 | execute( TC_assignment_ctm() ); |
| 3944 | execute( TC_assignment_sign() ); |
| 3945 | execute( TC_assignment_fr_a5_0() ); |
| 3946 | execute( TC_assignment_fr_a5_1() ); |
Harald Welte | 8f67d1d | 2018-05-25 20:38:42 +0200 | [diff] [blame] | 3947 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 3948 | execute( TC_assignment_fr_a5_1_codec_missing() ); |
| 3949 | } |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 3950 | execute( TC_assignment_fr_a5_3() ); |
| 3951 | execute( TC_assignment_fr_a5_4() ); |
Harald Welte | 3c86ea0 | 2018-05-10 22:28:05 +0200 | [diff] [blame] | 3952 | execute( TC_ciph_mode_a5_0() ); |
| 3953 | execute( TC_ciph_mode_a5_1() ); |
| 3954 | execute( TC_ciph_mode_a5_3() ); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 3955 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 3956 | execute( TC_assignment_codec_fr() ); |
| 3957 | execute( TC_assignment_codec_hr() ); |
| 3958 | execute( TC_assignment_codec_efr() ); |
| 3959 | execute( TC_assignment_codec_amr_f() ); |
| 3960 | execute( TC_assignment_codec_amr_h() ); |
Philipp Maier | 8a581d2 | 2019-03-26 18:32:48 +0100 | [diff] [blame] | 3961 | |
| 3962 | if (mp_bssap_cfg.transport == BSSAP_TRANSPORT_AoIP) { |
| 3963 | execute( TC_assignment_codec_amr_f_S1() ); |
| 3964 | execute( TC_assignment_codec_amr_h_S1() ); |
| 3965 | execute( TC_assignment_codec_amr_f_S124() ); |
| 3966 | execute( TC_assignment_codec_amr_h_S124() ); |
| 3967 | execute( TC_assignment_codec_amr_f_S0() ); |
| 3968 | execute( TC_assignment_codec_amr_f_S02() ); |
| 3969 | execute( TC_assignment_codec_amr_f_S024() ); |
| 3970 | execute( TC_assignment_codec_amr_f_S0247() ); |
| 3971 | execute( TC_assignment_codec_amr_h_S0() ); |
| 3972 | execute( TC_assignment_codec_amr_h_S02() ); |
| 3973 | execute( TC_assignment_codec_amr_h_S024() ); |
| 3974 | execute( TC_assignment_codec_amr_h_S0247() ); |
| 3975 | execute( TC_assignment_codec_amr_f_S01234567() ); |
| 3976 | execute( TC_assignment_codec_amr_f_S0234567() ); |
| 3977 | execute( TC_assignment_codec_amr_f_zero() ); |
| 3978 | execute( TC_assignment_codec_amr_f_unsupp() ); |
| 3979 | execute( TC_assignment_codec_amr_h_S7() ); |
| 3980 | } |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 3981 | |
Philipp Maier | ac09bfc | 2019-01-08 13:41:39 +0100 | [diff] [blame] | 3982 | execute( TC_assignment_codec_fr_exhausted_req_hr() ); |
| 3983 | execute( TC_assignment_codec_fr_exhausted_req_fr() ); |
| 3984 | execute( TC_assignment_codec_fr_exhausted_req_fr_hr() ); |
| 3985 | execute( TC_assignment_codec_fr_exhausted_req_hr_fr() ); |
| 3986 | execute( TC_assignment_codec_hr_exhausted_req_fr() ); |
| 3987 | execute( TC_assignment_codec_hr_exhausted_req_hr() ); |
| 3988 | execute( TC_assignment_codec_hr_exhausted_req_hr_fr() ); |
| 3989 | execute( TC_assignment_codec_hr_exhausted_req_fr_hr() ); |
| 3990 | execute( TC_assignment_codec_req_hr_fr() ); |
| 3991 | execute( TC_assignment_codec_req_fr_hr() ); |
| 3992 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 3993 | /* RLL Establish Indication on inactive DCHAN / SAPI */ |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 3994 | execute( TC_rll_est_ind_inact_lchan() ); |
| 3995 | execute( TC_rll_est_ind_inval_sapi1() ); |
| 3996 | execute( TC_rll_est_ind_inval_sapi3() ); |
| 3997 | execute( TC_rll_est_ind_inval_sacch() ); |
| 3998 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 3999 | /* Paging related tests */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 4000 | execute( TC_paging_imsi_nochan() ); |
| 4001 | execute( TC_paging_tmsi_nochan() ); |
| 4002 | execute( TC_paging_tmsi_any() ); |
| 4003 | execute( TC_paging_tmsi_sdcch() ); |
| 4004 | execute( TC_paging_tmsi_tch_f() ); |
| 4005 | execute( TC_paging_tmsi_tch_hf() ); |
| 4006 | execute( TC_paging_imsi_nochan_cgi() ); |
| 4007 | execute( TC_paging_imsi_nochan_lac_ci() ); |
| 4008 | execute( TC_paging_imsi_nochan_ci() ); |
| 4009 | execute( TC_paging_imsi_nochan_lai() ); |
| 4010 | execute( TC_paging_imsi_nochan_lac() ); |
| 4011 | execute( TC_paging_imsi_nochan_all() ); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 4012 | execute( TC_paging_imsi_nochan_plmn_lac_rnc() ); |
| 4013 | execute( TC_paging_imsi_nochan_rnc() ); |
| 4014 | execute( TC_paging_imsi_nochan_lac_rnc() ); |
| 4015 | execute( TC_paging_imsi_nochan_lacs() ); |
| 4016 | execute( TC_paging_imsi_nochan_lacs_empty() ); |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 4017 | execute( TC_paging_imsi_nochan_cgi_unknown_cid() ); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 4018 | execute( TC_paging_imsi_a_reset() ); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 4019 | execute( TC_paging_imsi_load() ); |
Philipp Maier | 779a792 | 2018-02-16 11:00:37 +0100 | [diff] [blame] | 4020 | execute( TC_paging_counter() ); |
Pau Espin Pedrol | 3466cc5 | 2018-11-05 12:41:05 +0100 | [diff] [blame] | 4021 | execute( TC_paging_resp_unsol() ); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 4022 | |
| 4023 | execute( TC_rsl_drop_counter() ); |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 4024 | execute( TC_rsl_unknown_unit_id() ); |
| 4025 | |
| 4026 | execute( TC_oml_unknown_unit_id() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 4027 | |
| 4028 | execute( TC_classmark() ); |
| 4029 | execute( TC_unsol_ass_fail() ); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 4030 | execute( TC_unsol_ass_compl() ); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 4031 | execute( TC_unsol_ho_fail() ); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 4032 | execute( TC_err_82_short_msg() ); |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 4033 | execute( TC_err_84_unknown_msg() ); |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 4034 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 4035 | execute( TC_ho_int() ); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 4036 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 4037 | execute( TC_ho_out_of_this_bsc() ); |
Neels Hofmeyr | 61ebb8b | 2018-10-09 18:28:06 +0200 | [diff] [blame] | 4038 | execute( TC_ho_out_fail_no_msc_response() ); |
| 4039 | execute( TC_ho_out_fail_rr_ho_failure() ); |
| 4040 | execute( TC_ho_out_fail_no_ho_detect() ); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 4041 | |
Neels Hofmeyr | bd0ef93 | 2018-03-19 14:58:46 +0100 | [diff] [blame] | 4042 | execute( TC_ho_into_this_bsc() ); |
Neels Hofmeyr | 20bc3e2 | 2018-11-09 01:40:16 +0100 | [diff] [blame] | 4043 | execute( TC_ho_in_fail_msc_clears() ); |
| 4044 | execute( TC_ho_in_fail_msc_clears_after_ho_detect() ); |
| 4045 | execute( TC_ho_in_fail_no_detect() ); |
| 4046 | execute( TC_ho_in_fail_no_detect2() ); |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 4047 | |
| 4048 | execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 4049 | execute( TC_bssmap_clear_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 4050 | execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() ); |
Harald Welte | 94e0c34 | 2018-04-07 11:33:23 +0200 | [diff] [blame] | 4051 | |
| 4052 | execute( TC_dyn_pdch_ipa_act_deact() ); |
| 4053 | execute( TC_dyn_pdch_ipa_act_nack() ); |
| 4054 | execute( TC_dyn_pdch_osmo_act_deact() ); |
| 4055 | execute( TC_dyn_pdch_osmo_act_nack() ); |
Harald Welte | 99f3ca0 | 2018-06-14 13:40:29 +0200 | [diff] [blame] | 4056 | |
Stefan Sperling | 0796a82 | 2018-10-05 13:01:39 +0200 | [diff] [blame] | 4057 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 4058 | execute( TC_chopped_ipa_payload() ); |
Stefan Sperling | 0796a82 | 2018-10-05 13:01:39 +0200 | [diff] [blame] | 4059 | |
Harald Welte | 99f3ca0 | 2018-06-14 13:40:29 +0200 | [diff] [blame] | 4060 | /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */ |
| 4061 | execute( TC_early_conn_fail() ); |
| 4062 | execute( TC_late_conn_fail() ); |
| 4063 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 4064 | } |
| 4065 | |
| 4066 | } |