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 | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 27 | import from BSSAP_Adapter all; |
| 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; |
| 33 | import from RSL_Types all; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 34 | import from RSL_Emulation all; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 35 | import from MGCP_Emulation all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 36 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 37 | import from Osmocom_CTRL_Functions all; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 38 | import from Osmocom_CTRL_Types all; |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 39 | import from Osmocom_CTRL_Adapter all; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 40 | |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 41 | import from Osmocom_VTY_Functions all; |
| 42 | import from TELNETasp_PortType all; |
| 43 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 44 | import from MobileL3_CommonIE_Types all; |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 45 | import from MobileL3_Types all; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 46 | import from L3_Templates all; |
| 47 | import from GSM_RR_Types all; |
| 48 | |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 49 | import from BSSMAP_Templates all; |
| 50 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 51 | const integer NUM_BTS := 3; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 52 | const float T3101_MAX := 12.0; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 53 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 54 | /* 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] | 55 | const integer NUM_TCHH_PER_BTS := 2; |
| 56 | const integer NUM_TCHF_PER_BTS := 4; |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 57 | const integer NUM_SDCCH_PER_BTS := 4; |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 58 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 59 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 60 | /* per-BTS state which we keep */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 61 | type record BTS_State { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 62 | /* component reference to the IPA_Client component used for RSL */ |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 63 | IPA_Client rsl |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 66 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 67 | /* Array of per-BTS state */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 68 | var BTS_State bts[NUM_BTS]; |
Harald Welte | 89ab191 | 2018-02-23 18:56:29 +0100 | [diff] [blame] | 69 | /* RSL common Channel Port (for RSL_Emulation) */ |
| 70 | port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS]; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 71 | /* array of per-BTS RSL test ports */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 72 | port IPA_RSL_PT IPA_RSL[NUM_BTS]; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 73 | 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] | 74 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 75 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 76 | port TELNETasp_PT BSCVTY; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 77 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 78 | var BSSAP_Adapter g_bssap; |
| 79 | /* for old legacy-tests only */ |
| 80 | port BSSAP_CODEC_PT BSSAP; |
| 81 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 82 | /* are we initialized yet */ |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 83 | var boolean g_initialized := false; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 84 | |
| 85 | /* global test case guard timer */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 86 | timer T_guard := 30.0; |
| 87 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | modulepar { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 91 | /* IP address at which the BSC can be reached */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 92 | charstring mp_bsc_ip := "127.0.0.1"; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 93 | /* port number to which to establish the IPA OML connections */ |
| 94 | integer mp_bsc_oml_port := 3002; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 95 | /* port number to which to establish the IPA RSL connections */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 96 | integer mp_bsc_rsl_port := 3003; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 97 | /* port number to which to establish the IPA CTRL connection */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 98 | integer mp_bsc_ctrl_port := 4249; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 99 | /* IP address at which the test binds */ |
| 100 | charstring mp_test_ip := "127.0.0.1"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 101 | |
| 102 | BSSAP_Configuration mp_bssap_cfg := { |
| 103 | sccp_service_type := "mtp3_itu", |
| 104 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 105 | own_pc := 185, |
| 106 | own_ssn := 254, |
| 107 | peer_pc := 187, |
| 108 | peer_ssn := 254, |
Philipp Maier | 38d6894 | 2018-03-29 15:38:09 +0200 | [diff] [blame] | 109 | sio := '83'O, |
| 110 | rctx := 0 |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 111 | }; |
| 112 | } |
| 113 | |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 114 | private function f_shutdown_helper() runs on test_CT { |
Harald Welte | 1205547 | 2018-03-17 20:10:08 +0100 | [diff] [blame] | 115 | for (var integer i := 0; i < NUM_BTS; i := i+1) { |
| 116 | if (isbound(bts[i]) and isbound(bts[i].rsl)) { |
| 117 | f_ipa_rsl_stop(bts[i].rsl); |
| 118 | } |
| 119 | } |
| 120 | f_ipa_ctrl_stop(); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 121 | all port.stop; |
| 122 | setverdict(pass); |
| 123 | } |
| 124 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 125 | private function f_legacy_bssap_reset() runs on test_CT { |
| 126 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 127 | timer T := 5.0; |
| 128 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap.sccp_addr_peer, g_bssap.sccp_addr_own, ts_BSSMAP_Reset(0))); |
| 129 | T.start; |
| 130 | alt { |
| 131 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap.sccp_addr_own, g_bssap.sccp_addr_peer, tr_BSSMAP_ResetAck)) { |
| 132 | log("Received RESET-ACK in response to RESET, we're ready to go!"); |
| 133 | } |
| 134 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 135 | log("Respoding to inbound RESET with RESET-ACK"); |
| 136 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 137 | ts_BSSMAP_ResetAck)); |
| 138 | repeat; |
| 139 | } |
| 140 | [] BSSAP.receive { repeat; } |
| 141 | [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); } |
| 142 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 145 | type record IPA_Client { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 146 | /* IPA Emulation component reference */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 147 | IPA_Emulation_CT vc_IPA, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 148 | /* Unit-ID and other CCM parameters to use for IPA client emulation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 149 | IPA_CCM_Parameters ccm_pars, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 150 | /* String identifier for this IPA Client */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 151 | charstring id, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 152 | /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 153 | RSL_Emulation_CT vc_RSL optional |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 156 | /*! Start the IPA/RSL related bits for one IPA_Client. |
| 157 | * \param clnt IPA_Client for which to establish |
| 158 | * \param bsc_host IP address / hostname of the BSC |
| 159 | * \param bsc_port TCP port number of the BSC |
| 160 | * \param i number identifying this BTS |
| 161 | * \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] | 162 | function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i, |
| 163 | boolean handler_mode := false) |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 164 | runs on test_CT { |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 165 | timer T := 10.0; |
| 166 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 167 | clnt.id := "IPA" & int2str(i) & "-RSL"; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 168 | clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA"); |
| 169 | clnt.ccm_pars := c_IPA_default_ccm_pars; |
| 170 | clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 171 | clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0"; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 172 | if (handler_mode) { |
| 173 | clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL"); |
Harald Welte | 89ab191 | 2018-02-23 18:56:29 +0100 | [diff] [blame] | 174 | connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 175 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 176 | |
| 177 | map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 178 | if (handler_mode) { |
| 179 | connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT); |
| 180 | } else { |
| 181 | connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]); |
| 182 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 183 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 184 | 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] | 185 | if (handler_mode) { |
| 186 | clnt.vc_RSL.start(RSL_Emulation.main()); |
| 187 | return; |
| 188 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 189 | |
| 190 | /* wait for IPA RSL link to connect and send ID ACK */ |
| 191 | T.start; |
| 192 | alt { |
| 193 | [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) { |
| 194 | T.stop; |
| 195 | IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23))); |
| 196 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 197 | [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 198 | [] IPA_RSL[i].receive { repeat } |
| 199 | [] T.timeout { |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 200 | setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK"); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 201 | self.stop; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
Harald Welte | 1205547 | 2018-03-17 20:10:08 +0100 | [diff] [blame] | 206 | function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT { |
| 207 | if (not isbound(clnt) or not isbound(clnt.vc_IPA)) { |
| 208 | return; |
| 209 | } |
| 210 | clnt.vc_IPA.stop; |
| 211 | if (isbound(clnt.vc_RSL)) { |
| 212 | clnt.vc_RSL.stop; |
| 213 | } |
| 214 | } |
| 215 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 216 | /* 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] | 217 | function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT { |
| 218 | timer T := secs_max; |
| 219 | T.start; |
| 220 | while (true) { |
| 221 | if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) { |
| 222 | T.stop; |
Harald Welte | bd868bd | 2017-12-10 18:28:40 +0100 | [diff] [blame] | 223 | /* the 'degraded' state exists from OML connection time, and we have to wait |
| 224 | * until all MO's are initialized */ |
| 225 | T.start(1.0); |
| 226 | T.timeout; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 227 | return; |
| 228 | } |
Harald Welte | f0d6ac6 | 2017-12-17 17:02:21 +0100 | [diff] [blame] | 229 | f_sleep(0.1); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 230 | if (not T.running) { |
| 231 | setverdict(fail, "Timeout waiting for oml-connection-state ", status); |
| 232 | self.stop; |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 237 | /* sleep for given number of (fractional) seconds */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 238 | function f_sleep(float seconds) { |
| 239 | timer T := seconds; |
| 240 | T.start; |
| 241 | T.timeout; |
| 242 | } |
| 243 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 244 | /* 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] | 245 | altstep as_Tguard() runs on test_CT { |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 246 | var BSSAP_N_UNITDATA_ind ud_ind; |
Neels Hofmeyr | cc3f76a | 2018-03-12 01:43:25 +0100 | [diff] [blame] | 247 | [] T_guard.timeout { |
| 248 | setverdict(fail, "Timeout of T_guard"); |
| 249 | self.stop; |
| 250 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 251 | /* always respond with RESET ACK to RESET */ |
| 252 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 253 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 254 | ts_BSSMAP_ResetAck)); |
Harald Welte | 69c1c26 | 2017-12-13 21:02:08 +0100 | [diff] [blame] | 255 | repeat; |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 256 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 259 | altstep no_bssmap_reset() runs on test_CT { |
| 260 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
| 261 | setverdict(fail, "unexpected BSSMAP Reset"); |
| 262 | self.stop; |
| 263 | } |
| 264 | } |
| 265 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 266 | function f_init_mgcp(charstring id) runs on test_CT { |
| 267 | id := id & "-MGCP"; |
| 268 | |
| 269 | var MGCPOps ops := { |
| 270 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 271 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 272 | }; |
| 273 | var MGCP_conn_parameters mgcp_pars := { |
| 274 | callagent_ip := mp_bsc_ip, |
Harald Welte | 9e4273e | 2018-01-29 22:01:22 +0100 | [diff] [blame] | 275 | callagent_udp_port := -1, |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 276 | mgw_ip := mp_test_ip, |
| 277 | mgw_udp_port := 2427 |
| 278 | }; |
| 279 | |
| 280 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 281 | vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id)); |
| 282 | } |
| 283 | |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 284 | private function f_init_vty(charstring id) runs on test_CT { |
| 285 | map(self:BSCVTY, system:BSCVTY); |
| 286 | f_vty_set_prompts(BSCVTY); |
| 287 | f_vty_transceive(BSCVTY, "enable"); |
| 288 | } |
| 289 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 290 | /* global initialization function |
| 291 | * \param nr_bts Number of BTSs we should start/bring up |
| 292 | * \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] | 293 | 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] | 294 | var integer i; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 295 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 296 | if (g_initialized) { |
| 297 | return; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 298 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 299 | g_initialized := true; |
| 300 | |
| 301 | /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the |
| 302 | * MSC-side BSSAP emulation */ |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 303 | if (handler_mode) { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 304 | f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", MSC_BssmapOps); |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 305 | } else { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 306 | f_bssap_init(g_bssap, mp_bssap_cfg, "VirtMSC", omit); |
| 307 | connect(self:BSSAP, g_bssap.vc_SCCP:SCCP_SP_PORT); |
| 308 | f_legacy_bssap_reset(); |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 309 | } |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 310 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 311 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 312 | f_init_mgcp("VirtMSC"); |
Harald Welte | bc03c76 | 2018-02-12 18:09:38 +0100 | [diff] [blame] | 313 | f_init_vty("VirtMSC"); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 314 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 315 | for (i := 0; i < nr_bts; i := i+1) { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 316 | /* wait until osmo-bts-omldummy has respawned */ |
| 317 | f_wait_oml(i, "degraded", 5.0); |
| 318 | /* start RSL connection */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 319 | 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] | 320 | /* wait until BSC tells us "connected" */ |
| 321 | f_wait_oml(i, "connected", 5.0); |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 324 | T_guard.start; |
| 325 | activate(as_Tguard()); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 328 | /* expect to receive a RSL message matching a specified templaten on a given BTS / stream */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 329 | function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 330 | runs on test_CT return RSL_Message { |
| 331 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 332 | timer T := t_secs; |
| 333 | |
| 334 | T.start; |
| 335 | alt { |
| 336 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud { |
| 337 | T.stop; |
| 338 | } |
| 339 | [] IPA_RSL[bts_nr].receive { repeat; } |
Harald Welte | b291770 | 2017-12-10 15:48:52 +0100 | [diff] [blame] | 340 | [] T.timeout { |
| 341 | setverdict(fail, "Timeout expecting ", t_rx); |
| 342 | self.stop; |
| 343 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 344 | } |
| 345 | return rx_rsl_ud.rsl; |
| 346 | } |
| 347 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 348 | /* helper function to transmit RSL on a given BTS/stream */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 349 | function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 350 | runs on test_CT { |
| 351 | IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx)); |
| 352 | } |
| 353 | |
| 354 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 355 | /* verify we get a CHAN_ACT after CHAN RQD */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 356 | testcase TC_chan_act_noreply() runs on test_CT { |
| 357 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 358 | var RSL_Message rsl_unused; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 359 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 360 | f_init(1); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 361 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 362 | 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] | 363 | 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] | 364 | setverdict(pass); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 365 | } |
| 366 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 367 | /* verify if the "chreq:total" counter increments as expected */ |
| 368 | testcase TC_chan_act_counter() runs on test_CT { |
| 369 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 370 | var integer chreq_total; |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 371 | var RSL_Message rsl_unused; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 372 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 373 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 374 | |
| 375 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 376 | 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] | 377 | 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] | 378 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1); |
| 379 | |
| 380 | setverdict(pass); |
| 381 | } |
| 382 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 383 | /* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */ |
| 384 | testcase TC_chan_act_ack_noest() runs on test_CT { |
| 385 | var RSL_Message rx_rsl; |
| 386 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 387 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 388 | |
| 389 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 390 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 391 | |
| 392 | /* expect BSC to disable the channel again if there's no RLL EST IND */ |
| 393 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 394 | |
| 395 | setverdict(pass); |
| 396 | } |
| 397 | |
| 398 | /* Test behavior if MSC never answers to CR */ |
| 399 | testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT { |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 400 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 401 | var IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 402 | var RSL_Message rx_rsl; |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 403 | var ASP_RSL_Unitdata rx_rsl_ud; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 404 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 405 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 406 | |
| 407 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 408 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 409 | |
| 410 | var octetstring l3 := '00010203040506'O |
| 411 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 412 | |
| 413 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))); |
| 414 | |
| 415 | /* 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] | 416 | /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */ |
| 417 | IPA_RSL[0].clear; |
| 418 | alt { |
| 419 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { } |
| 420 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud { |
| 421 | f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch)); |
| 422 | repeat; |
| 423 | } |
| 424 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 425 | |
| 426 | setverdict(pass); |
| 427 | } |
| 428 | |
| 429 | /* Test behavior if MSC answers with CREF to CR */ |
| 430 | testcase TC_chan_act_ack_est_ind_refused() runs on test_CT { |
| 431 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 432 | var RSL_Message rx_rsl; |
| 433 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 434 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 435 | |
| 436 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 437 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 438 | |
| 439 | var octetstring l3 := '00010203040506'O |
| 440 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 441 | |
| 442 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 443 | BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0)); |
| 444 | |
| 445 | /* expect BSC to disable the channel */ |
Harald Welte | 725844b | 2018-01-28 16:18:32 +0100 | [diff] [blame] | 446 | f_expect_chan_rel(0, chan_nr); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 447 | setverdict(pass); |
| 448 | } |
| 449 | |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 450 | /* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */ |
| 451 | testcase TC_chan_act_nack() runs on test_CT { |
| 452 | var RSL_Message rx_rsl; |
| 453 | var integer chact_nack; |
| 454 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 455 | f_init(1); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 456 | |
| 457 | chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack"); |
| 458 | |
| 459 | f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33)); |
| 460 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 461 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 462 | |
| 463 | f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL)); |
| 464 | |
| 465 | /* wait for some time to hope the NACK arrives before the CTRL GET below */ |
| 466 | f_sleep(0.5); |
| 467 | |
| 468 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1); |
| 469 | |
| 470 | setverdict(pass); |
| 471 | } |
| 472 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 473 | /* Test for channel exhaustion due to RACH overload */ |
| 474 | testcase TC_chan_exhaustion() runs on test_CT { |
| 475 | var ASP_RSL_Unitdata rsl_ud; |
| 476 | var integer i; |
| 477 | var integer chreq_total, chreq_nochan; |
| 478 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 479 | f_init(1); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 480 | |
| 481 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 482 | chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel"); |
| 483 | |
| 484 | /* expect 5xTCH/F to succeed */ |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 485 | for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) { |
Harald Welte | 930d0a7 | 2018-03-22 22:08:40 +0100 | [diff] [blame] | 486 | var RslChannelNr chan_nr := f_chreq_act_ack('23'O, i); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | IPA_RSL[0].clear; |
| 490 | |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 491 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 492 | 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] | 493 | |
| 494 | /* now expect additional channel activations to fail */ |
| 495 | f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42)); |
| 496 | |
| 497 | alt { |
| 498 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 499 | tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) { |
| 500 | setverdict(fail, "Received CHAN ACT ACK without resources?!?"); |
| 501 | } |
| 502 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud { |
| 503 | var GsmRrMessage rr; |
| 504 | /* match on IMM ASS REJ */ |
| 505 | rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload); |
| 506 | if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) { |
| 507 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
Philipp Maier | cb6cc48 | 2018-03-26 13:08:00 +0200 | [diff] [blame] | 508 | 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] | 509 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel", |
| 510 | chreq_nochan+1); |
| 511 | setverdict(pass); |
| 512 | } else { |
| 513 | repeat; |
| 514 | } |
| 515 | } |
| 516 | [] IPA_RSL[0].receive { repeat; } |
| 517 | } |
| 518 | } |
| 519 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 520 | /*********************************************************************** |
| 521 | * Assignment Testing |
| 522 | ***********************************************************************/ |
| 523 | |
| 524 | /* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */ |
| 525 | testcase TC_outbound_connect() runs on test_CT { |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 526 | f_init(1); |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 527 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 528 | 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] | 529 | BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?)); |
| 530 | setverdict(pass); |
| 531 | } |
| 532 | |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 533 | /* Test behavior if MSC answers with CREF to CR */ |
| 534 | testcase TC_assignment_cic_only() runs on test_CT { |
| 535 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 536 | var RSL_Message rx_rsl; |
| 537 | var DchanTuple dt; |
| 538 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 539 | f_init(1); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 540 | |
| 541 | dt := f_est_dchan('23'O, 23, '00000000'O); |
| 542 | /* send assignment without AoIP IEs */ |
Harald Welte | cc7e4dc | 2017-12-14 21:55:10 +0100 | [diff] [blame] | 543 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1)))); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 544 | alt { |
| 545 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 546 | setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE"); |
| 547 | } |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 548 | /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 549 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 550 | setverdict(pass); |
| 551 | } |
| 552 | [] BSSAP.receive { repeat; } |
| 553 | } |
| 554 | } |
| 555 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 556 | /* Run everything required up to sending a caller-specified assignment command and expect response */ |
| 557 | function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text) |
| 558 | runs on test_CT { |
| 559 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 560 | var RSL_Message rx_rsl; |
| 561 | var DchanTuple dt; |
| 562 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 563 | f_init(1); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 564 | |
| 565 | dt := f_est_dchan('23'O, 23, '00000000'O); |
| 566 | /* send assignment without AoIP IEs */ |
| 567 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd)); |
| 568 | alt { |
| 569 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 570 | if (ischosen(exp.pdu.bssmap.assignmentComplete)) { |
| 571 | setverdict(pass); |
| 572 | } else { |
| 573 | setverdict(fail, fail_text); |
| 574 | } |
| 575 | } |
| 576 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 577 | if (ischosen(exp.pdu.bssmap.assignmentFailure)) { |
| 578 | setverdict(pass); |
| 579 | } else { |
| 580 | setverdict(fail, fail_text); |
| 581 | } |
| 582 | } |
| 583 | [] BSSAP.receive { repeat; } |
| 584 | } |
| 585 | } |
| 586 | testcase TC_assignment_csd() runs on test_CT { |
| 587 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 588 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 589 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 590 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD); |
| 591 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 592 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD"); |
| 593 | } |
| 594 | |
| 595 | testcase TC_assignment_ctm() runs on test_CT { |
| 596 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 597 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 598 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 599 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM); |
| 600 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 601 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM"); |
| 602 | } |
| 603 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 604 | type record DchanTuple { |
| 605 | integer sccp_conn_id, |
| 606 | RslChannelNr rsl_chan_nr |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 607 | } |
| 608 | |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 609 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 610 | private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23) |
| 611 | runs on test_CT return RslChannelNr { |
| 612 | var RSL_Message rx_rsl; |
| 613 | f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn)); |
| 614 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 615 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 616 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10)); |
| 617 | return chan_nr; |
| 618 | } |
| 619 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 620 | /* helper function to establish a dedicated channel via BTS and MSC */ |
| 621 | function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3) |
| 622 | runs on test_CT return DchanTuple { |
| 623 | var BSSAP_N_CONNECT_ind rx_c_ind; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 624 | var DchanTuple dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 625 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 626 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 627 | dt.rsl_chan_nr := f_chreq_act_ack(ra, fn); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 628 | |
| 629 | f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 630 | |
| 631 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 632 | dt.sccp_conn_id := rx_c_ind.connectionId; |
| 633 | BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id)); |
| 634 | |
| 635 | return dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 636 | } |
| 637 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 638 | /* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */ |
| 639 | testcase TC_chan_rel_rll_rel_ind() runs on test_CT { |
| 640 | var RSL_Message rx_rsl; |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 641 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 642 | var DchanTuple dt; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 643 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 644 | f_init(1); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 645 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 646 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 647 | |
| 648 | /* simulate RLL REL IND */ |
| 649 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 650 | |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 651 | /* expect Clear Request on MSC side */ |
| 652 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 653 | |
| 654 | /* Instruct BSC to clear channel */ |
| 655 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 656 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 657 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 658 | /* expect BSC to disable the channel */ |
| 659 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 660 | /* respond with CHAN REL ACK */ |
| 661 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 662 | |
Neels Hofmeyr | 27f6436 | 2018-03-12 01:44:00 +0100 | [diff] [blame] | 663 | /* expect Clear Complete from BSC */ |
| 664 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 665 | |
| 666 | /* release the SCCP connection */ |
| 667 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 668 | |
| 669 | /* wait for SCCP emulation to do its job */ |
| 670 | f_sleep(1.0); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 671 | |
| 672 | setverdict(pass); |
| 673 | } |
| 674 | |
| 675 | /* Test behavior of channel release after CONN FAIL IND from BTS */ |
| 676 | testcase TC_chan_rel_conn_fail() runs on test_CT { |
| 677 | var BSSAP_N_DATA_ind rx_di; |
| 678 | var RSL_Message rx_rsl; |
| 679 | var DchanTuple dt; |
| 680 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 681 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 682 | |
| 683 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 684 | |
| 685 | /* simulate CONN FAIL IND */ |
Harald Welte | a8ed906 | 2017-12-14 09:46:01 +0100 | [diff] [blame] | 686 | 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] | 687 | /* TODO: different cause values? */ |
| 688 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 689 | /* expect Clear Request from BSC */ |
| 690 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 691 | |
| 692 | /* Instruct BSC to clear channel */ |
| 693 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 694 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 695 | |
Harald Welte | 6ff76ea | 2018-01-28 13:08:01 +0100 | [diff] [blame] | 696 | /* expect BSC to disable the channel */ |
| 697 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 698 | /* respond with CHAN REL ACK */ |
| 699 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 700 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 701 | /* expect Clear Complete from BSC */ |
| 702 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 703 | |
| 704 | /* release the SCCP connection */ |
| 705 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 706 | |
| 707 | /* wait for SCCP emulation to do its job */ |
| 708 | f_sleep(1.0); |
| 709 | |
| 710 | setverdict(pass); |
| 711 | } |
| 712 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 713 | function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true, |
| 714 | boolean handle_rll_rel := true) runs on test_CT { |
| 715 | |
| 716 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 717 | if (flush) { |
| 718 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 719 | IPA_RSL[bts_nr].clear; |
| 720 | } |
| 721 | alt { |
| 722 | /* ignore DEACTIVATE SACCH (if any) */ |
| 723 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 724 | tr_RSL_DEACT_SACCH(rsl_chan_nr))) { |
| 725 | repeat; |
| 726 | } |
| 727 | /* acknowledge RLL release (if any)*/ |
| 728 | [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 729 | tr_RSL_REL_REQ(rsl_chan_nr, ?))) { |
| 730 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
| 731 | f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch)); |
| 732 | repeat; |
| 733 | } |
| 734 | /* Expect RF channel release from BSC on Abis */ |
| 735 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 736 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 737 | /* respond with CHAN REL ACK */ |
| 738 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr)); |
| 739 | } |
| 740 | /* ignore any user data */ |
| 741 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) { |
| 742 | repeat; |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 747 | /* Test behavior of channel release after hard Clear Command from MSC */ |
| 748 | testcase TC_chan_rel_hard_clear() runs on test_CT { |
| 749 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 750 | var DchanTuple dt; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 751 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 752 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 753 | |
| 754 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 755 | |
| 756 | /* Instruct BSC to clear channel */ |
| 757 | var BssmapCause cause := 0; |
| 758 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 759 | |
| 760 | /* expect Clear Complete from BSC on A */ |
| 761 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) { |
| 762 | /* release the SCCP connection */ |
| 763 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 764 | } |
| 765 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 766 | f_expect_chan_rel(0, dt.rsl_chan_nr); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 767 | setverdict(pass); |
| 768 | } |
| 769 | |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 770 | /* Test behavior of channel release after hard RLSD from MSC */ |
| 771 | testcase TC_chan_rel_hard_rlsd() runs on test_CT { |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 772 | var DchanTuple dt; |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 773 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 774 | f_init(1); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 775 | |
| 776 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 777 | |
| 778 | /* release the SCCP connection */ |
| 779 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 780 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 781 | f_expect_chan_rel(0, dt.rsl_chan_nr); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 782 | setverdict(pass); |
| 783 | } |
| 784 | |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 785 | /* Test behavior of channel release after BSSMAP RESET from MSC */ |
| 786 | testcase TC_chan_rel_a_reset() runs on test_CT { |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 787 | var DchanTuple dt; |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 788 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 789 | f_init(1); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 790 | |
| 791 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 792 | |
| 793 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 794 | IPA_RSL[0].clear; |
| 795 | |
| 796 | /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */ |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 797 | 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] | 798 | interleave { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 799 | [] 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] | 800 | [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { } |
| 801 | } |
| 802 | |
Philipp Maier | e8f38ed | 2018-02-09 10:30:31 +0100 | [diff] [blame] | 803 | f_expect_chan_rel(0, dt.rsl_chan_nr, false); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 804 | setverdict(pass); |
| 805 | } |
| 806 | |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 807 | /* Test behavior if RSL EST IND for non-active channel */ |
| 808 | testcase TC_rll_est_ind_inact_lchan() runs on test_CT { |
| 809 | timer T := 2.0; |
| 810 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 811 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 812 | |
| 813 | var octetstring l3 := '00010203040506'O; |
| 814 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6)); |
| 815 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 816 | |
| 817 | T.start; |
| 818 | alt { |
| 819 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 820 | setverdict(fail, "MSC received COMPL L3 for non-active lchan"); |
| 821 | } |
| 822 | [] BSSAP.receive {} |
| 823 | [] IPA_RSL[0].receive {} |
| 824 | [] T.timeout {} |
| 825 | } |
| 826 | |
| 827 | setverdict(pass); |
| 828 | } |
| 829 | |
| 830 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 831 | testcase TC_rll_est_ind_inval_sapi1() runs on test_CT { |
| 832 | var RslChannelNr chan_nr; |
| 833 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 834 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 835 | |
| 836 | chan_nr := f_chreq_act_ack() |
| 837 | |
| 838 | var octetstring l3 := '00010203040506'O; |
| 839 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3)); |
| 840 | |
| 841 | timer T := 2.0; |
| 842 | T.start; |
| 843 | alt { |
| 844 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 845 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1"); |
| 846 | } |
| 847 | [] BSSAP.receive { repeat; } |
| 848 | [] IPA_RSL[0].receive { repeat; } |
| 849 | [] T.timeout {} |
| 850 | } |
| 851 | |
| 852 | setverdict(pass); |
| 853 | } |
| 854 | |
| 855 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 856 | testcase TC_rll_est_ind_inval_sapi3() runs on test_CT { |
| 857 | timer T := 2.0; |
| 858 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 859 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 860 | |
| 861 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 862 | |
| 863 | var octetstring l3 := '00010203040506'O; |
| 864 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3)); |
| 865 | |
| 866 | T.start; |
| 867 | alt { |
| 868 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 869 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3"); |
| 870 | } |
| 871 | [] BSSAP.receive { repeat; } |
| 872 | [] IPA_RSL[0].receive { repeat; } |
| 873 | [] T.timeout {} |
| 874 | } |
| 875 | |
| 876 | setverdict(pass); |
| 877 | } |
| 878 | |
| 879 | /* Test behavior if RSL EST IND for invalid SACCH */ |
| 880 | testcase TC_rll_est_ind_inval_sacch() runs on test_CT { |
| 881 | timer T := 2.0; |
| 882 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 883 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 884 | |
| 885 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 886 | |
| 887 | var octetstring l3 := '00010203040506'O; |
| 888 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3)); |
| 889 | |
| 890 | T.start; |
| 891 | alt { |
| 892 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 893 | setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH"); |
| 894 | } |
| 895 | [] BSSAP.receive { repeat; } |
| 896 | [] IPA_RSL[0].receive { repeat; } |
| 897 | [] T.timeout {} |
| 898 | } |
| 899 | |
| 900 | setverdict(pass); |
| 901 | } |
| 902 | |
| 903 | |
| 904 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 905 | |
| 906 | testcase TC_ctrl_msc_connection_status() runs on test_CT { |
| 907 | var charstring ctrl_resp; |
| 908 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 909 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 910 | |
| 911 | /* See https://osmocom.org/issues/2729 */ |
| 912 | f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected"); |
| 913 | setverdict(pass); |
| 914 | } |
| 915 | |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 916 | testcase TC_ctrl_msc0_connection_status() runs on test_CT { |
| 917 | var charstring ctrl_resp; |
| 918 | |
| 919 | f_init(1); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 920 | |
| 921 | f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected"); |
| 922 | setverdict(pass); |
| 923 | } |
| 924 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 925 | testcase TC_ctrl() runs on test_CT { |
| 926 | var charstring ctrl_resp; |
| 927 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 928 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 929 | |
| 930 | /* all below values must match the osmo-bsc.cfg config file used */ |
| 931 | |
Harald Welte | 6a12969 | 2018-03-17 17:30:14 +0100 | [diff] [blame] | 932 | f_ctrl_get_exp(IPA_CTRL, "mcc", "001"); |
| 933 | f_ctrl_get_exp(IPA_CTRL, "mnc", "01"); |
Harald Welte | 44bdaa5 | 2017-12-17 17:01:47 +0100 | [diff] [blame] | 934 | f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3"); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 935 | |
| 936 | var integer bts_nr := 0; |
| 937 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1"); |
| 938 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0"); |
| 939 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected"); |
| 940 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs"); |
| 941 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on"); |
| 942 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871"); |
| 943 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20"); |
| 944 | |
| 945 | var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")); |
| 946 | f_sleep(2.0); |
| 947 | if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) { |
| 948 | setverdict(fail, "oml-uptime not incrementing as expected"); |
| 949 | } |
| 950 | /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */ |
| 951 | |
| 952 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0); |
| 953 | |
| 954 | setverdict(pass); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 955 | } |
| 956 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 957 | 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] | 958 | 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] | 959 | } |
| 960 | |
| 961 | |
| 962 | /*********************************************************************** |
| 963 | * Paging Testing |
| 964 | ***********************************************************************/ |
| 965 | |
| 966 | type record Cell_Identity { |
| 967 | GsmMcc mcc, |
| 968 | GsmMnc mnc, |
| 969 | GsmLac lac, |
| 970 | GsmCellId ci |
| 971 | }; |
Harald Welte | 24135bd | 2018-03-17 19:27:53 +0100 | [diff] [blame] | 972 | private const Cell_Identity cid := { '001'H, '01'H, 1, 0 }; |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 973 | private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 }; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 974 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 975 | type set of integer BtsIdList; |
| 976 | |
| 977 | private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean { |
| 978 | for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) { |
| 979 | if (bts_id == bts_ids[j]) { |
| 980 | return true; |
| 981 | } |
| 982 | } |
| 983 | return false; |
| 984 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 985 | |
| 986 | /* core paging test helper function; used by most paging test cases */ |
| 987 | private function f_pageing_helper(hexstring imsi, |
| 988 | template BSSMAP_FIELD_CellIdentificationList cid_list, |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 989 | BtsIdList bts_ids := { 0 }, |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 990 | template RSL_ChanNeeded rsl_chneed := omit, |
| 991 | template OCT4 tmsi := omit) runs on test_CT |
| 992 | { |
| 993 | var template BSSMAP_IE_ChannelNeeded bssmap_chneed; |
| 994 | var MobileIdentity mi; |
| 995 | var template octetstring id_enc; /* FIXME */ |
| 996 | var RSL_Message rx_rsl; |
| 997 | var integer paging_group := hex2int(imsi[lengthof(imsi)-1]); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 998 | var integer i; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 999 | |
| 1000 | f_init(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1001 | |
| 1002 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Harald Welte | c306859 | 2018-03-17 19:55:31 +0100 | [diff] [blame] | 1003 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1004 | IPA_RSL[i].clear; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1005 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1006 | |
| 1007 | if (isvalue(rsl_chneed)) { |
| 1008 | /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */ |
| 1009 | bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2)); |
| 1010 | } else { |
| 1011 | bssmap_chneed := omit; |
| 1012 | } |
| 1013 | |
| 1014 | f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)); |
| 1015 | |
| 1016 | /* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder |
| 1017 | if (isvalue(tmsi)) { |
| 1018 | mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi)))); |
| 1019 | } else { |
| 1020 | mi := valueof(ts_Osmo_MI_IMSI(imsi)); |
| 1021 | } |
| 1022 | id_enc := enc_MobileIdentity(mi); |
| 1023 | */ |
| 1024 | id_enc := ?; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1025 | for (i := 0; i < sizeof(bts_ids); i := i + 1) { |
| 1026 | rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc)); |
| 1027 | /* check channel type, paging group */ |
| 1028 | if (rx_rsl.ies[1].body.paging_group != paging_group) { |
| 1029 | setverdict(fail, "Paging for wrong paging group"); |
| 1030 | } |
| 1031 | if (ispresent(rsl_chneed) and |
| 1032 | rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) { |
| 1033 | setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed"); |
| 1034 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1035 | } |
Harald Welte | 2fccd98 | 2018-01-31 15:48:19 +0100 | [diff] [blame] | 1036 | f_sleep(2.0); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1037 | /* do a quick check on all not-included BTSs if they received paging */ |
| 1038 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1039 | timer T := 0.1; |
| 1040 | if (f_bts_in_list(i, bts_ids)) { |
| 1041 | continue; |
| 1042 | } |
| 1043 | T.start; |
| 1044 | alt { |
| 1045 | [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) { |
| 1046 | setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids); |
| 1047 | } |
| 1048 | [] IPA_RSL[i].receive { repeat; } |
| 1049 | [] T.timeout { } |
| 1050 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | setverdict(pass); |
| 1054 | } |
| 1055 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1056 | const BtsIdList c_BtsId_all := { 0, 1, 2 }; |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1057 | const BtsIdList c_BtsId_none := { }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1058 | const BtsIdList c_BtsId_LAC1 := { 0, 1 }; |
| 1059 | const BtsIdList c_BtsId_LAC2 := { 2 }; |
| 1060 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1061 | /* PAGING by IMSI + TMSI */ |
| 1062 | testcase TC_paging_imsi_nochan() runs on test_CT { |
| 1063 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1064 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Philipp Maier | 8c04b0a | 2018-02-23 13:48:48 +0100 | [diff] [blame] | 1065 | f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1066 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | /* PAGING by IMSI + TMSI */ |
| 1070 | testcase TC_paging_tmsi_nochan() runs on test_CT { |
| 1071 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1072 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1073 | 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] | 1074 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | /* Paging with different "channel needed' values */ |
| 1078 | testcase TC_paging_tmsi_any() runs on test_CT { |
| 1079 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1080 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1081 | 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] | 1082 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1083 | } |
| 1084 | testcase TC_paging_tmsi_sdcch() runs on test_CT { |
| 1085 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1086 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1087 | 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] | 1088 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1089 | } |
| 1090 | testcase TC_paging_tmsi_tch_f() runs on test_CT { |
| 1091 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1092 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1093 | 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] | 1094 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1095 | } |
| 1096 | testcase TC_paging_tmsi_tch_hf() runs on test_CT { |
| 1097 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1098 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1099 | 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] | 1100 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | /* Paging by CGI */ |
| 1104 | testcase TC_paging_imsi_nochan_cgi() runs on test_CT { |
| 1105 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1106 | 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] | 1107 | f_pageing_helper('001010000000006'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1108 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | /* Paging by LAC+CI */ |
| 1112 | testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT { |
| 1113 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1114 | 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] | 1115 | f_pageing_helper('001010000000007'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1116 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | /* Paging by CI */ |
| 1120 | testcase TC_paging_imsi_nochan_ci() runs on test_CT { |
| 1121 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1122 | cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1123 | f_pageing_helper('001010000000008'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1124 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | /* Paging by LAI */ |
| 1128 | testcase TC_paging_imsi_nochan_lai() runs on test_CT { |
| 1129 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1130 | 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] | 1131 | f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1132 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | /* Paging by LAC */ |
| 1136 | testcase TC_paging_imsi_nochan_lac() runs on test_CT { |
| 1137 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1138 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1139 | f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1140 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /* Paging by "all in BSS" */ |
| 1144 | testcase TC_paging_imsi_nochan_all() runs on test_CT { |
| 1145 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1146 | cid_list := { cIl_allInBSS := ''O }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1147 | f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1148 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1149 | } |
| 1150 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1151 | /* 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] | 1152 | testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT { |
| 1153 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1154 | 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] | 1155 | f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1156 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1157 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1158 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1159 | /* Paging by RNC; We do not implement this; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1160 | testcase TC_paging_imsi_nochan_rnc() runs on test_CT { |
| 1161 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1162 | cid_list := { cIl_RNC := { int2oct(13, 2) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1163 | f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1164 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1165 | } |
| 1166 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame] | 1167 | /* Paging by LAC+RNC; We do not implement; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1168 | testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT { |
| 1169 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1170 | 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] | 1171 | f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1172 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1173 | } |
| 1174 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1175 | /* 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] | 1176 | testcase TC_paging_imsi_nochan_lacs() runs on test_CT { |
| 1177 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1178 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } }; |
| 1179 | f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1180 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1181 | } |
| 1182 | |
| 1183 | /* Paging on empty list: Verify none of them page */ |
| 1184 | testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT { |
| 1185 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1186 | cid_list := { cIl_LAC := { } }; |
| 1187 | f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1188 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1189 | } |
| 1190 | |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 1191 | /* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */ |
| 1192 | testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT { |
| 1193 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1194 | cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } }; |
| 1195 | f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none); |
| 1196 | f_shutdown_helper(); |
| 1197 | } |
| 1198 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1199 | /* Verify paging retransmission interval + count */ |
| 1200 | /* Verify paging stops after channel establishment */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1201 | /* Test behavior under paging overload */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1202 | |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1203 | /* Verify PCH load */ |
| 1204 | testcase TC_paging_imsi_load() runs on test_CT { |
| 1205 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1206 | timer T := 4.0; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1207 | timer T_retrans := 1.0; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1208 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1209 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1210 | |
| 1211 | /* tell BSC there is no paging space anymore */ |
| 1212 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
Harald Welte | 3b57ab5 | 2018-03-17 18:01:10 +0100 | [diff] [blame] | 1213 | f_sleep(0.2); |
| 1214 | IPA_RSL[0].clear; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1215 | |
| 1216 | /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally, |
| 1217 | * there would be 8 retransmissions during 4 seconds */ |
| 1218 | T.start; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1219 | T_retrans.start; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1220 | alt { |
| 1221 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1222 | setverdict(fail, "Received PAGING after LOAD_IND(0)"); |
| 1223 | self.stop; |
| 1224 | } |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1225 | [] T_retrans.timeout { |
| 1226 | /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */ |
| 1227 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
| 1228 | T_retrans.start; |
| 1229 | repeat; |
| 1230 | } |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1231 | [] T.timeout { |
| 1232 | setverdict(pass); |
| 1233 | } |
| 1234 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1235 | |
| 1236 | f_shutdown_helper(); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1237 | } |
| 1238 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1239 | /* Verify Paging Counter */ |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1240 | testcase TC_paging_counter() runs on test_CT { |
| 1241 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1242 | timer T := 4.0; |
| 1243 | var integer i; |
| 1244 | var integer paging_attempted_bsc; |
| 1245 | var integer paging_attempted_bts[NUM_BTS]; |
| 1246 | var integer paging_expired_bts[NUM_BTS]; |
| 1247 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
| 1248 | |
| 1249 | f_init(); |
| 1250 | |
| 1251 | /* read counters before paging */ |
| 1252 | paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted"); |
| 1253 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1254 | paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted"); |
| 1255 | paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired"); |
| 1256 | } |
| 1257 | |
| 1258 | f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all); |
| 1259 | |
| 1260 | /* expect the attempted pages on BSC and each BTSs to have incremented by one */ |
| 1261 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1); |
| 1262 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1263 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted", |
| 1264 | paging_attempted_bts[i]+1); |
| 1265 | } |
| 1266 | |
| 1267 | /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */ |
| 1268 | f_sleep(12.0); |
| 1269 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1270 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired", |
| 1271 | paging_expired_bts[i]+1); |
| 1272 | } |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1273 | |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1274 | f_shutdown_helper(); |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1278 | /* Verify paging stops after A-RESET */ |
| 1279 | testcase TC_paging_imsi_a_reset() runs on test_CT { |
| 1280 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1281 | timer T := 3.0; |
| 1282 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1283 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1284 | |
| 1285 | /* Perform a BSSMAP Reset and wait for ACK */ |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1286 | 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] | 1287 | alt { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1288 | [] 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] | 1289 | [] BSSAP.receive { repeat; } |
| 1290 | } |
| 1291 | |
| 1292 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Philipp Maier | 1e6b442 | 2018-02-23 14:02:13 +0100 | [diff] [blame] | 1293 | for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) { |
| 1294 | IPA_RSL[i].clear; |
| 1295 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1296 | |
| 1297 | /* Wait for 3 seconds if any more PAGING CMD are received on RSL */ |
| 1298 | T.start; |
| 1299 | alt { |
| 1300 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1301 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1302 | self.stop; |
| 1303 | } |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1304 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1305 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1306 | self.stop; |
| 1307 | } |
| 1308 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1309 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1310 | self.stop; |
| 1311 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1312 | [] T.timeout { |
| 1313 | setverdict(pass); |
| 1314 | } |
| 1315 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1316 | |
| 1317 | f_shutdown_helper(); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1318 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1319 | |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1320 | /* Test RSL link drop causes counter increment */ |
| 1321 | testcase TC_rsl_drop_counter() runs on test_CT { |
| 1322 | var integer rsl_fail; |
| 1323 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1324 | f_init(1); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1325 | |
| 1326 | rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail"); |
| 1327 | |
| 1328 | bts[0].rsl.vc_IPA.stop; |
| 1329 | |
| 1330 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1); |
| 1331 | |
| 1332 | setverdict(pass); |
| 1333 | } |
| 1334 | |
| 1335 | /* TODO: Test OML link drop causes counter increment */ |
| 1336 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1337 | /* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */ |
| 1338 | function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean { |
| 1339 | timer T := 10.0; |
| 1340 | |
| 1341 | bts[0].rsl.id := "IPA-0-RSL"; |
| 1342 | bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA"); |
| 1343 | bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars; |
| 1344 | bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 1345 | bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */ |
| 1346 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1347 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
| 1348 | |
| 1349 | f_init_mgcp("VirtMSC"); |
| 1350 | |
| 1351 | /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */ |
| 1352 | map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA); |
| 1353 | connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]); |
| 1354 | bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars)); |
| 1355 | |
| 1356 | /* wait for IPA OML link to connect and then disconnect */ |
| 1357 | T.start; |
| 1358 | alt { |
| 1359 | [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) { |
| 1360 | T.stop; |
| 1361 | return true; |
| 1362 | } |
| 1363 | [] IPA_RSL[0].receive { repeat } |
| 1364 | [] T.timeout { |
| 1365 | self.stop; |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | return false; |
| 1370 | } |
| 1371 | |
| 1372 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1373 | testcase TC_rsl_unknown_unit_id() runs on test_CT { |
| 1374 | if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) { |
| 1375 | setverdict(pass); |
| 1376 | } else { |
| 1377 | setverdict(fail, "Timeout RSL waiting for connection to close"); |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | |
| 1382 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1383 | testcase TC_oml_unknown_unit_id() runs on test_CT { |
| 1384 | if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) { |
| 1385 | setverdict(pass); |
| 1386 | } else { |
| 1387 | setverdict(fail, "Timeout OML waiting for connection to close"); |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1392 | /*********************************************************************** |
| 1393 | * "New world" test cases using RSL_Emulation + BSSMAP_Emulation |
| 1394 | ***********************************************************************/ |
| 1395 | |
| 1396 | import from BSSMAP_Emulation all; |
| 1397 | import from RSL_Emulation all; |
| 1398 | import from MSC_ConnectionHandler all; |
| 1399 | |
| 1400 | type function void_fn(charstring id) runs on MSC_ConnHdlr; |
| 1401 | |
| 1402 | /* helper function to create, connect and start a MSC_ConnHdlr component */ |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1403 | function f_start_handler(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit) |
| 1404 | runs on test_CT return MSC_ConnHdlr { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1405 | var MSC_ConnHdlr vc_conn; |
| 1406 | |
| 1407 | vc_conn := MSC_ConnHdlr.create(id); |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1408 | connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1409 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1410 | connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 1411 | connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC); |
Philipp Maier | 88f4ae8 | 2018-03-01 14:00:58 +0100 | [diff] [blame] | 1412 | if (isvalue(bts[1])) { |
Philipp Maier | 956a92f | 2018-02-16 10:58:07 +0100 | [diff] [blame] | 1413 | connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT); |
| 1414 | connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC); |
| 1415 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1416 | connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1417 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1418 | vc_conn.start(f_handler_init(fn, id, pars)); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1419 | return vc_conn; |
| 1420 | } |
| 1421 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1422 | /* first function inside ConnHdlr component; sets g_pars + starts function */ |
| 1423 | private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit) |
| 1424 | runs on MSC_ConnHdlr { |
| 1425 | if (isvalue(pars)) { |
| 1426 | g_pars := valueof(pars); |
| 1427 | } |
| 1428 | fn.apply(id); |
| 1429 | } |
| 1430 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1431 | private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1432 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1433 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1434 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1435 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1436 | const OCT8 kc := '0001020304050607'O; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1437 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1438 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1439 | 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] | 1440 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1441 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1442 | f_cipher_mode('01'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1443 | } |
| 1444 | |
| 1445 | testcase TC_assignment_fr_a5_0() runs on test_CT { |
| 1446 | var MSC_ConnHdlr vc_conn; |
| 1447 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1448 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1449 | f_sleep(1.0); |
| 1450 | |
| 1451 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_0), testcasename()); |
| 1452 | vc_conn.done; |
| 1453 | } |
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | private function f_tc_assignment_fr_a5_1(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1458 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1459 | |
| 1460 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1461 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1462 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1463 | const OCT8 kc := '0001020304050607'O; |
| 1464 | |
| 1465 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1466 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1467 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1468 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1469 | f_cipher_mode('02'O, kc); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1470 | } |
| 1471 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1472 | testcase TC_assignment_fr_a5_1() runs on test_CT { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1473 | var MSC_ConnHdlr vc_conn; |
| 1474 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1475 | f_init(1, true); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1476 | f_sleep(1.0); |
| 1477 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1478 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1), testcasename()); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1479 | vc_conn.done; |
| 1480 | } |
| 1481 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1482 | /* Expect ASSIGNMENT FAIL if mandatory IE is missing */ |
| 1483 | private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1484 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1485 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 1486 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1487 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1488 | const OCT8 kc := '0001020304050607'O; |
| 1489 | |
| 1490 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1491 | f_establish_fully(ass_cmd, exp_fail); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1492 | } |
| 1493 | |
| 1494 | testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT { |
| 1495 | var MSC_ConnHdlr vc_conn; |
| 1496 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1497 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1498 | f_sleep(1.0); |
| 1499 | |
| 1500 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing), testcasename()); |
| 1501 | vc_conn.done; |
| 1502 | } |
| 1503 | |
| 1504 | |
| 1505 | private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1506 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1507 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1508 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1509 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1510 | const OCT8 kc := '0001020304050607'O; |
| 1511 | |
| 1512 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1513 | 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] | 1514 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1515 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1516 | f_cipher_mode('08'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | testcase TC_assignment_fr_a5_3() runs on test_CT { |
| 1520 | var MSC_ConnHdlr vc_conn; |
| 1521 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1522 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1523 | f_sleep(1.0); |
| 1524 | |
| 1525 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_3), testcasename()); |
| 1526 | vc_conn.done; |
| 1527 | } |
| 1528 | |
| 1529 | |
| 1530 | private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1531 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1532 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1533 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1534 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1535 | const OCT8 kc := '0001020304050607'O; |
| 1536 | const OCT16 kc128 := kc & kc; |
| 1537 | |
| 1538 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1539 | 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] | 1540 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1541 | f_cipher_mode('10'O, kc, kc128, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1542 | /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */ |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | testcase TC_assignment_fr_a5_4() runs on test_CT { |
| 1546 | var MSC_ConnHdlr vc_conn; |
| 1547 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1548 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1549 | f_sleep(1.0); |
| 1550 | |
| 1551 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4), testcasename()); |
| 1552 | vc_conn.done; |
| 1553 | } |
| 1554 | |
| 1555 | |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1556 | private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr { |
| 1557 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1558 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit); |
| 1559 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit)); |
| 1560 | |
| 1561 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL); |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1562 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | testcase TC_assignment_sign() runs on test_CT { |
| 1566 | var MSC_ConnHdlr vc_conn; |
| 1567 | |
| 1568 | f_init(1, true); |
| 1569 | f_sleep(1.0); |
| 1570 | |
| 1571 | vc_conn := f_start_handler(refers(f_tc_assignment_sign), testcasename()); |
| 1572 | vc_conn.done; |
| 1573 | } |
| 1574 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1575 | /*********************************************************************** |
| 1576 | * Codec (list) testing |
| 1577 | ***********************************************************************/ |
| 1578 | |
| 1579 | /* check if the given rsl_mode is compatible with the a_elem */ |
| 1580 | private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode) |
| 1581 | return boolean { |
| 1582 | select (a_elem.codecType) { |
| 1583 | case (GSM_FR) { |
| 1584 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) { |
| 1585 | return true; |
| 1586 | } |
| 1587 | } |
| 1588 | case (GSM_HR) { |
| 1589 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) { |
| 1590 | return true; |
| 1591 | } |
| 1592 | } |
| 1593 | case (GSM_EFR) { |
| 1594 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) { |
| 1595 | return true; |
| 1596 | } |
| 1597 | } |
| 1598 | case (FR_AMR) { |
| 1599 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) { |
| 1600 | return true; |
| 1601 | } |
| 1602 | } |
| 1603 | case (HR_AMR) { |
| 1604 | if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) { |
| 1605 | return true; |
| 1606 | } |
| 1607 | } |
| 1608 | case else { } |
| 1609 | } |
| 1610 | return false; |
| 1611 | } |
| 1612 | |
| 1613 | /* check if the given rsl_mode is compatible with the a_list */ |
| 1614 | private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode) |
| 1615 | return boolean { |
| 1616 | for (var integer i := 0; i < sizeof(a_list); i := i+1) { |
| 1617 | if (f_match_codec(a_list.codecElements[i], rsl_mode)) { |
| 1618 | return true; |
| 1619 | } |
| 1620 | } |
| 1621 | return false; |
| 1622 | } |
| 1623 | |
| 1624 | /* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */ |
| 1625 | private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem) |
| 1626 | return BSSMAP_IE_ChannelType { |
| 1627 | /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */ |
| 1628 | var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType); |
| 1629 | select (a_elem.codecType) { |
| 1630 | case (GSM_FR) { |
| 1631 | ret.channelRateAndType := ChRate_TCHF; |
| 1632 | ret.speechId_DataIndicator := Spdi_TCHF_FR; |
| 1633 | } |
| 1634 | case (GSM_HR) { |
| 1635 | ret.channelRateAndType := ChRate_TCHH; |
| 1636 | ret.speechId_DataIndicator := Spdi_TCHH_HR; |
| 1637 | } |
| 1638 | case (GSM_EFR) { |
| 1639 | ret.channelRateAndType := ChRate_TCHF; |
| 1640 | ret.speechId_DataIndicator := Spdi_TCHF_EFR; |
| 1641 | } |
| 1642 | case (FR_AMR) { |
| 1643 | ret.channelRateAndType := ChRate_TCHF; |
| 1644 | ret.speechId_DataIndicator := Spdi_TCHF_AMR; |
| 1645 | } |
| 1646 | case (HR_AMR) { |
| 1647 | ret.channelRateAndType := ChRate_TCHH; |
| 1648 | ret.speechId_DataIndicator := Spdi_TCHH_AMR; |
| 1649 | } |
| 1650 | case else { |
| 1651 | setverdict(fail, "Unsupported codec ", a_elem); |
| 1652 | self.stop; |
| 1653 | } |
| 1654 | } |
| 1655 | return ret; |
| 1656 | } |
| 1657 | |
Harald Welte | a63b910 | 2018-03-22 20:36:16 +0100 | [diff] [blame] | 1658 | private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem) |
| 1659 | return template RSL_IE_Body { |
| 1660 | var template RSL_IE_Body mode_ie := { |
| 1661 | chan_mode := { |
| 1662 | len := ?, |
| 1663 | reserved := ?, |
| 1664 | dtx_d := ?, |
| 1665 | dtx_u := ?, |
| 1666 | spd_ind := RSL_SPDI_SPEECH, |
| 1667 | ch_rate_type := -, |
| 1668 | coding_alg_rate := - |
| 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | select (a_elem.codecType) { |
| 1673 | case (GSM_FR) { |
| 1674 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1675 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1; |
| 1676 | } |
| 1677 | case (GSM_HR) { |
| 1678 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H; |
| 1679 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1; |
| 1680 | } |
| 1681 | case (GSM_EFR) { |
| 1682 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1683 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2; |
| 1684 | } |
| 1685 | case (FR_AMR) { |
| 1686 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F; |
| 1687 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3; |
| 1688 | } |
| 1689 | case (HR_AMR) { |
| 1690 | mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H; |
| 1691 | mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3; |
| 1692 | } |
| 1693 | } |
| 1694 | return mode_ie; |
| 1695 | } |
| 1696 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1697 | type record CodecListTest { |
| 1698 | BSSMAP_IE_SpeechCodecList codec_list, |
| 1699 | charstring id |
| 1700 | } |
| 1701 | type record of CodecListTest CodecListTests |
| 1702 | |
| 1703 | private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr { |
| 1704 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1705 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1706 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1707 | |
| 1708 | /* puzzle together the ASSIGNMENT REQ for given codec[s] */ |
| 1709 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list; |
| 1710 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := |
| 1711 | f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]); |
| 1712 | exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] := |
| 1713 | g_pars.ass_codec_list.codecElements[0]; |
| 1714 | log("expecting ASS COMPL like this: ", exp_compl); |
| 1715 | |
| 1716 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | a63b910 | 2018-03-22 20:36:16 +0100 | [diff] [blame] | 1717 | |
| 1718 | /* Verify that the RSL-side activation actually matches our expectations */ |
| 1719 | var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr); |
| 1720 | |
| 1721 | var RSL_IE_Body mode_ie; |
| 1722 | if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) { |
| 1723 | setverdict(fail, "Couldn't find CHAN_MODE IE"); |
| 1724 | self.stop; |
| 1725 | } |
| 1726 | var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]); |
| 1727 | if (not match(mode_ie, t_mode_ie)) { |
| 1728 | setverdict(fail, "RSL Channel Mode IE doesn't match expectation"); |
| 1729 | } |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | testcase TC_assignment_codec_fr() runs on test_CT { |
| 1733 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1734 | var MSC_ConnHdlr vc_conn; |
| 1735 | |
| 1736 | f_init(1, true); |
| 1737 | f_sleep(1.0); |
| 1738 | |
| 1739 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 1740 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars); |
| 1741 | vc_conn.done; |
| 1742 | } |
| 1743 | |
| 1744 | testcase TC_assignment_codec_hr() runs on test_CT { |
| 1745 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1746 | var MSC_ConnHdlr vc_conn; |
| 1747 | |
| 1748 | f_init(1, true); |
| 1749 | f_sleep(1.0); |
| 1750 | |
| 1751 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR})); |
| 1752 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars); |
| 1753 | vc_conn.done; |
| 1754 | } |
| 1755 | |
| 1756 | testcase TC_assignment_codec_efr() runs on test_CT { |
| 1757 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1758 | var MSC_ConnHdlr vc_conn; |
| 1759 | |
| 1760 | f_init(1, true); |
| 1761 | f_sleep(1.0); |
| 1762 | |
| 1763 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR})); |
| 1764 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars); |
| 1765 | vc_conn.done; |
| 1766 | } |
| 1767 | |
| 1768 | testcase TC_assignment_codec_amr_f() runs on test_CT { |
| 1769 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1770 | var MSC_ConnHdlr vc_conn; |
| 1771 | |
| 1772 | f_init(1, true); |
| 1773 | f_sleep(1.0); |
| 1774 | |
| 1775 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F})); |
| 1776 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars); |
| 1777 | vc_conn.done; |
| 1778 | } |
| 1779 | |
| 1780 | testcase TC_assignment_codec_amr_h() runs on test_CT { |
| 1781 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1782 | var MSC_ConnHdlr vc_conn; |
| 1783 | |
| 1784 | f_init(1, true); |
| 1785 | f_sleep(1.0); |
| 1786 | |
| 1787 | pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H})); |
| 1788 | vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars); |
| 1789 | vc_conn.done; |
| 1790 | } |
| 1791 | |
| 1792 | |
| 1793 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1794 | /* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */ |
| 1795 | private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1796 | g_pars := valueof(t_def_TestHdlrPars); |
| 1797 | f_create_chan_and_exp(); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1798 | /* we should now have a COMPL_L3 at the MSC */ |
| 1799 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1800 | |
| 1801 | f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2))); |
| 1802 | BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit)); |
| 1803 | setverdict(pass); |
| 1804 | } |
| 1805 | testcase TC_classmark() runs on test_CT { |
| 1806 | var MSC_ConnHdlr vc_conn; |
| 1807 | f_init(1, true); |
| 1808 | f_sleep(1.0); |
| 1809 | vc_conn := f_start_handler(refers(f_tc_classmark), testcasename()); |
| 1810 | vc_conn.done; |
| 1811 | } |
| 1812 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1813 | private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1814 | g_pars := valueof(t_def_TestHdlrPars); |
| 1815 | f_create_chan_and_exp(); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1816 | /* we should now have a COMPL_L3 at the MSC */ |
| 1817 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1818 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1819 | /* send the single message we want to send */ |
| 1820 | f_rsl_send_l3(l3); |
| 1821 | } |
| 1822 | |
| 1823 | private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr { |
| 1824 | timer T := sec; |
| 1825 | var PDU_BSSAP bssap; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1826 | T.start; |
| 1827 | alt { |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1828 | [] BSSAP.receive(PDU_BSSAP:?) -> value bssap { |
| 1829 | setverdict(fail, "Unexpected BSSMAP ", bssap); |
| 1830 | self.stop; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1831 | } |
| 1832 | [] T.timeout { |
| 1833 | setverdict(pass); |
| 1834 | } |
| 1835 | } |
| 1836 | } |
| 1837 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1838 | /* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1839 | private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr { |
| 1840 | f_est_single_l3(ts_RRM_AssignmentFailure('00'O)); |
| 1841 | f_bssap_expect_nothing(); |
| 1842 | } |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1843 | testcase TC_unsol_ass_fail() runs on test_CT { |
| 1844 | var MSC_ConnHdlr vc_conn; |
| 1845 | f_init(1, true); |
| 1846 | f_sleep(1.0); |
| 1847 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail), testcasename()); |
| 1848 | vc_conn.done; |
| 1849 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1850 | |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 1851 | |
| 1852 | /* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1853 | 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] | 1854 | f_est_single_l3(ts_RRM_AssignmentComplete('00'O)); |
| 1855 | f_bssap_expect_nothing(); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 1856 | } |
| 1857 | testcase TC_unsol_ass_compl() runs on test_CT { |
| 1858 | var MSC_ConnHdlr vc_conn; |
| 1859 | f_init(1, true); |
| 1860 | f_sleep(1.0); |
| 1861 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl), testcasename()); |
| 1862 | vc_conn.done; |
| 1863 | } |
| 1864 | |
| 1865 | |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1866 | /* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1867 | 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] | 1868 | f_est_single_l3(ts_RRM_HandoverFailure('00'O)); |
| 1869 | f_bssap_expect_nothing(); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1870 | } |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1871 | testcase TC_unsol_ho_fail() runs on test_CT { |
| 1872 | var MSC_ConnHdlr vc_conn; |
| 1873 | f_init(1, true); |
| 1874 | f_sleep(1.0); |
| 1875 | vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail), testcasename()); |
| 1876 | vc_conn.done; |
| 1877 | } |
| 1878 | |
| 1879 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1880 | /* short message from MS should be ignored */ |
| 1881 | private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1882 | g_pars := valueof(t_def_TestHdlrPars); |
| 1883 | f_create_chan_and_exp(); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1884 | /* we should now have a COMPL_L3 at the MSC */ |
| 1885 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1886 | |
| 1887 | /* send short message */ |
| 1888 | RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O)); |
| 1889 | f_bssap_expect_nothing(); |
| 1890 | } |
| 1891 | testcase TC_err_82_short_msg() runs on test_CT { |
| 1892 | var MSC_ConnHdlr vc_conn; |
| 1893 | f_init(1, true); |
| 1894 | f_sleep(1.0); |
| 1895 | vc_conn := f_start_handler(refers(f_tc_err_82_short_msg), testcasename()); |
| 1896 | vc_conn.done; |
| 1897 | } |
| 1898 | |
| 1899 | |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1900 | /* 24.008 8.4 Unknown message must trigger RR STATUS */ |
| 1901 | private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr { |
| 1902 | f_est_single_l3(ts_RRM_UL_REL('00'O)); |
| 1903 | timer T := 3.0 |
| 1904 | alt { |
| 1905 | [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) { |
| 1906 | setverdict(pass); |
| 1907 | } |
| 1908 | [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); } |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1909 | [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); } |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1910 | } |
| 1911 | } |
| 1912 | testcase TC_err_84_unknown_msg() runs on test_CT { |
| 1913 | var MSC_ConnHdlr vc_conn; |
| 1914 | f_init(1, true); |
| 1915 | f_sleep(1.0); |
| 1916 | vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg), testcasename()); |
| 1917 | vc_conn.done; |
| 1918 | } |
| 1919 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1920 | /* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */ |
| 1921 | private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr) |
| 1922 | runs on MSC_ConnHdlr { |
| 1923 | /* FIXME: resolve those from component-global state */ |
| 1924 | var integer ts_nr := chan_nr.tn; |
| 1925 | var integer ss_nr; |
| 1926 | if (ischosen(chan_nr.u.ch0)) { |
| 1927 | ss_nr := 0; |
| 1928 | } else if (ischosen(chan_nr.u.lm)) { |
| 1929 | ss_nr := chan_nr.u.lm.sub_chan; |
| 1930 | } else if (ischosen(chan_nr.u.sdcch4)) { |
| 1931 | ss_nr := chan_nr.u.sdcch4.sub_chan; |
| 1932 | } else if (ischosen(chan_nr.u.sdcch8)) { |
| 1933 | ss_nr := chan_nr.u.sdcch8.sub_chan; |
| 1934 | } else { |
| 1935 | setverdict(fail, "Invalid ChanNr ", chan_nr); |
| 1936 | self.stop; |
| 1937 | } |
| 1938 | |
| 1939 | var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)& |
| 1940 | " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" "; |
| 1941 | f_vty_transceive(BSCVTY, cmd & suffix); |
| 1942 | } |
| 1943 | |
| 1944 | private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr, |
| 1945 | integer new_bts_nr) |
| 1946 | runs on MSC_ConnHdlr { |
| 1947 | f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr); |
| 1948 | } |
| 1949 | |
| 1950 | /* intra-BSC hand-over between BTS0 and BTS1 */ |
| 1951 | private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr { |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1952 | g_pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1953 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1954 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1955 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1956 | const OCT8 kc := '0001020304050607'O; |
| 1957 | |
| 1958 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1959 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 1960 | |
Harald Welte | a063003 | 2018-03-20 21:09:55 +0100 | [diff] [blame] | 1961 | f_establish_fully(ass_cmd, exp_compl); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1962 | |
| 1963 | var HandoverState hs := { |
| 1964 | rr_ho_cmpl_seen := false, |
| 1965 | handover_done := false, |
| 1966 | old_chan_nr := - |
| 1967 | }; |
| 1968 | /* issue hand-over command on VTY */ |
| 1969 | f_vty_handover(0, 0, g_chan_nr, 1); |
| 1970 | /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */ |
| 1971 | f_rslem_suspend(RSL1_PROC); |
| 1972 | alt { |
| 1973 | [] as_handover(hs); |
| 1974 | /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */ |
| 1975 | } |
| 1976 | } |
| 1977 | |
| 1978 | testcase TC_ho_int() runs on test_CT { |
| 1979 | var MSC_ConnHdlr vc_conn; |
| 1980 | f_init(2, true); |
| 1981 | f_sleep(1.0); |
| 1982 | vc_conn := f_start_handler(refers(f_tc_ho_int), testcasename()); |
| 1983 | vc_conn.done; |
| 1984 | } |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1985 | |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 1986 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 1987 | * BSSMAP Reset just because of that. */ |
| 1988 | testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT { |
| 1989 | var default d; |
| 1990 | var integer i; |
| 1991 | var DchanTuple dt; |
| 1992 | |
| 1993 | f_init(); |
| 1994 | |
| 1995 | /* Wait for initial BSSMAP Reset to pass */ |
| 1996 | f_sleep(4.0); |
| 1997 | |
| 1998 | d := activate(no_bssmap_reset()); |
| 1999 | |
| 2000 | /* Setup up a number of connections and RLSD them again from the MSC |
| 2001 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 2002 | * Let's do it some more times for good measure. */ |
| 2003 | for (i := 0; i < 8; i := i+1) { |
| 2004 | /* Since we're doing a lot of runs, give each one a fresh |
| 2005 | * T_guard from the top. */ |
| 2006 | T_guard.start; |
| 2007 | |
| 2008 | /* Setup a BSSAP connection and clear it right away. This is |
| 2009 | * the MSC telling the BSC about a planned release, it's not an |
| 2010 | * erratic loss of a connection. */ |
| 2011 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 2012 | |
| 2013 | /* MSC disconnects (RLSD). */ |
| 2014 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 2015 | } |
| 2016 | |
| 2017 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 2018 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 2019 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 2020 | f_sleep(4.0); |
| 2021 | |
| 2022 | deactivate(d); |
| 2023 | f_shutdown_helper(); |
| 2024 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 2025 | |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 2026 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 2027 | * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from |
| 2028 | * the MSC. */ |
| 2029 | testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT { |
| 2030 | var default d; |
| 2031 | var integer i; |
| 2032 | var DchanTuple dt; |
| 2033 | var BSSAP_N_DATA_ind rx_di; |
| 2034 | var RSL_Message rx_rsl; |
| 2035 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL; |
| 2036 | var BssmapCause cause := enum2int(cause_val); |
| 2037 | |
| 2038 | f_init(); |
| 2039 | |
| 2040 | /* Wait for initial BSSMAP Reset to pass */ |
| 2041 | f_sleep(4.0); |
| 2042 | |
| 2043 | d := activate(no_bssmap_reset()); |
| 2044 | |
| 2045 | /* Setup up a number of connections and RLSD them again from the MSC |
| 2046 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 2047 | * Let's do it some more times for good measure. */ |
| 2048 | for (i := 0; i < 8; i := i+1) { |
| 2049 | /* Since we're doing a lot of runs, give each one a fresh |
| 2050 | * T_guard from the top. */ |
| 2051 | T_guard.start; |
| 2052 | |
| 2053 | /* Setup a BSSAP connection and clear it right away. This is |
| 2054 | * the MSC telling the BSC about a planned release, it's not an |
| 2055 | * erratic loss of a connection. */ |
| 2056 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 2057 | |
| 2058 | /* Instruct BSC to clear channel */ |
| 2059 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 2060 | |
| 2061 | /* expect BSC to disable the channel */ |
| 2062 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 2063 | /* respond with CHAN REL ACK */ |
| 2064 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 2065 | |
| 2066 | /* expect Clear Complete from BSC */ |
| 2067 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 2068 | |
| 2069 | /* MSC disconnects as instructed. */ |
| 2070 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 2071 | |
| 2072 | |
| 2073 | /* MSC disconnects (RLSD). */ |
| 2074 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 2075 | } |
| 2076 | |
| 2077 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 2078 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 2079 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 2080 | f_sleep(4.0); |
| 2081 | |
| 2082 | deactivate(d); |
| 2083 | f_shutdown_helper(); |
| 2084 | } |
| 2085 | |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 2086 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 2087 | * BSSMAP Reset just because of that. Close connections from the MS side with a |
| 2088 | * Release Ind on RSL. */ |
| 2089 | testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT { |
| 2090 | var default d; |
| 2091 | var integer i; |
| 2092 | var DchanTuple dt; |
| 2093 | var BSSAP_N_DATA_ind rx_di; |
| 2094 | var RSL_Message rx_rsl; |
| 2095 | var integer j; |
| 2096 | |
| 2097 | f_init(); |
| 2098 | |
| 2099 | /* Wait for initial BSSMAP Reset to pass */ |
| 2100 | f_sleep(4.0); |
| 2101 | |
| 2102 | d := activate(no_bssmap_reset()); |
| 2103 | |
| 2104 | /* Setup up a number of connections and RLSD them again from the MSC |
| 2105 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 2106 | * Let's do it some more times for good measure. */ |
| 2107 | for (i := 0; i < 8; i := i+1) { |
| 2108 | /* Since we're doing a lot of runs, give each one a fresh |
| 2109 | * T_guard from the top. */ |
| 2110 | T_guard.start; |
| 2111 | |
| 2112 | /* Setup a BSSAP connection and clear it right away. This is |
| 2113 | * the MSC telling the BSC about a planned release, it's not an |
| 2114 | * erratic loss of a connection. */ |
| 2115 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 2116 | |
| 2117 | /* simulate RLL REL IND */ |
| 2118 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 2119 | |
| 2120 | /* expect Clear Request on MSC side */ |
| 2121 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 2122 | |
| 2123 | /* Instruct BSC to clear channel */ |
| 2124 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 2125 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 2126 | |
| 2127 | /* expect BSC to disable the channel */ |
| 2128 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 2129 | /* respond with CHAN REL ACK */ |
| 2130 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 2131 | |
| 2132 | /* expect Clear Complete from BSC */ |
| 2133 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 2134 | |
| 2135 | /* MSC disconnects as instructed. */ |
| 2136 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 2137 | } |
| 2138 | |
| 2139 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 2140 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 2141 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 2142 | f_sleep(4.0); |
| 2143 | |
| 2144 | deactivate(d); |
| 2145 | f_shutdown_helper(); |
| 2146 | } |
| 2147 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 2148 | control { |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2149 | /* CTRL interface testing */ |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 2150 | execute( TC_ctrl_msc_connection_status() ); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 2151 | execute( TC_ctrl_msc0_connection_status() ); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 2152 | execute( TC_ctrl() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2153 | |
| 2154 | /* RSL DCHAN Channel ACtivation / Deactivation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 2155 | execute( TC_chan_act_noreply() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 2156 | execute( TC_chan_act_counter() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 2157 | execute( TC_chan_act_ack_noest() ); |
| 2158 | execute( TC_chan_act_ack_est_ind_noreply() ); |
| 2159 | execute( TC_chan_act_ack_est_ind_refused() ); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 2160 | execute( TC_chan_act_nack() ); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 2161 | execute( TC_chan_exhaustion() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 2162 | execute( TC_chan_rel_rll_rel_ind() ); |
| 2163 | execute( TC_chan_rel_conn_fail() ); |
| 2164 | execute( TC_chan_rel_hard_clear() ); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 2165 | execute( TC_chan_rel_hard_rlsd() ); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 2166 | execute( TC_chan_rel_a_reset() ); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 2167 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 2168 | execute( TC_outbound_connect() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2169 | |
| 2170 | /* Assignment related */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 2171 | execute( TC_assignment_cic_only() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 2172 | execute( TC_assignment_csd() ); |
| 2173 | execute( TC_assignment_ctm() ); |
| 2174 | execute( TC_assignment_sign() ); |
| 2175 | execute( TC_assignment_fr_a5_0() ); |
| 2176 | execute( TC_assignment_fr_a5_1() ); |
Harald Welte | f1b64e2 | 2017-12-15 14:55:14 +0100 | [diff] [blame] | 2177 | execute( TC_assignment_fr_a5_1_codec_missing() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 2178 | execute( TC_assignment_fr_a5_3() ); |
| 2179 | execute( TC_assignment_fr_a5_4() ); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 2180 | |
Harald Welte | 60aa576 | 2018-03-21 19:33:13 +0100 | [diff] [blame] | 2181 | execute( TC_assignment_codec_fr() ); |
| 2182 | execute( TC_assignment_codec_hr() ); |
| 2183 | execute( TC_assignment_codec_efr() ); |
| 2184 | execute( TC_assignment_codec_amr_f() ); |
| 2185 | execute( TC_assignment_codec_amr_h() ); |
| 2186 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2187 | /* RLL Establish Indication on inactive DCHAN / SAPI */ |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 2188 | execute( TC_rll_est_ind_inact_lchan() ); |
| 2189 | execute( TC_rll_est_ind_inval_sapi1() ); |
| 2190 | execute( TC_rll_est_ind_inval_sapi3() ); |
| 2191 | execute( TC_rll_est_ind_inval_sacch() ); |
| 2192 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2193 | /* Paging related tests */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 2194 | execute( TC_paging_imsi_nochan() ); |
| 2195 | execute( TC_paging_tmsi_nochan() ); |
| 2196 | execute( TC_paging_tmsi_any() ); |
| 2197 | execute( TC_paging_tmsi_sdcch() ); |
| 2198 | execute( TC_paging_tmsi_tch_f() ); |
| 2199 | execute( TC_paging_tmsi_tch_hf() ); |
| 2200 | execute( TC_paging_imsi_nochan_cgi() ); |
| 2201 | execute( TC_paging_imsi_nochan_lac_ci() ); |
| 2202 | execute( TC_paging_imsi_nochan_ci() ); |
| 2203 | execute( TC_paging_imsi_nochan_lai() ); |
| 2204 | execute( TC_paging_imsi_nochan_lac() ); |
| 2205 | execute( TC_paging_imsi_nochan_all() ); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 2206 | execute( TC_paging_imsi_nochan_plmn_lac_rnc() ); |
| 2207 | execute( TC_paging_imsi_nochan_rnc() ); |
| 2208 | execute( TC_paging_imsi_nochan_lac_rnc() ); |
| 2209 | execute( TC_paging_imsi_nochan_lacs() ); |
| 2210 | execute( TC_paging_imsi_nochan_lacs_empty() ); |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 2211 | execute( TC_paging_imsi_nochan_cgi_unknown_cid() ); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 2212 | execute( TC_paging_imsi_a_reset() ); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 2213 | execute( TC_paging_imsi_load() ); |
Philipp Maier | 779a792 | 2018-02-16 11:00:37 +0100 | [diff] [blame] | 2214 | execute( TC_paging_counter() ); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 2215 | |
| 2216 | execute( TC_rsl_drop_counter() ); |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 2217 | execute( TC_rsl_unknown_unit_id() ); |
| 2218 | |
| 2219 | execute( TC_oml_unknown_unit_id() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 2220 | |
| 2221 | execute( TC_classmark() ); |
| 2222 | execute( TC_unsol_ass_fail() ); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 2223 | execute( TC_unsol_ass_compl() ); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 2224 | execute( TC_unsol_ho_fail() ); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 2225 | execute( TC_err_82_short_msg() ); |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 2226 | execute( TC_err_84_unknown_msg() ); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 2227 | execute( TC_ho_int() ); |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 2228 | |
| 2229 | execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 2230 | execute( TC_bssmap_clear_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 2231 | execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() ); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 2232 | } |
| 2233 | |
| 2234 | } |