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