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 }; |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 969 | private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 }; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 970 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 971 | type set of integer BtsIdList; |
| 972 | |
| 973 | private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean { |
| 974 | for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) { |
| 975 | if (bts_id == bts_ids[j]) { |
| 976 | return true; |
| 977 | } |
| 978 | } |
| 979 | return false; |
| 980 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 981 | |
| 982 | /* core paging test helper function; used by most paging test cases */ |
| 983 | private function f_pageing_helper(hexstring imsi, |
| 984 | template BSSMAP_FIELD_CellIdentificationList cid_list, |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 985 | BtsIdList bts_ids := { 0 }, |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 986 | template RSL_ChanNeeded rsl_chneed := omit, |
| 987 | template OCT4 tmsi := omit) runs on test_CT |
| 988 | { |
| 989 | var template BSSMAP_IE_ChannelNeeded bssmap_chneed; |
| 990 | var MobileIdentity mi; |
| 991 | var template octetstring id_enc; /* FIXME */ |
| 992 | var RSL_Message rx_rsl; |
| 993 | var integer paging_group := hex2int(imsi[lengthof(imsi)-1]); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 994 | var integer i; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 995 | |
| 996 | f_init(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 997 | |
| 998 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Harald Welte | c306859 | 2018-03-17 19:55:31 +0100 | [diff] [blame] | 999 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1000 | IPA_RSL[i].clear; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1001 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1002 | |
| 1003 | if (isvalue(rsl_chneed)) { |
| 1004 | /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */ |
| 1005 | bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2)); |
| 1006 | } else { |
| 1007 | bssmap_chneed := omit; |
| 1008 | } |
| 1009 | |
| 1010 | f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)); |
| 1011 | |
| 1012 | /* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder |
| 1013 | if (isvalue(tmsi)) { |
| 1014 | mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi)))); |
| 1015 | } else { |
| 1016 | mi := valueof(ts_Osmo_MI_IMSI(imsi)); |
| 1017 | } |
| 1018 | id_enc := enc_MobileIdentity(mi); |
| 1019 | */ |
| 1020 | id_enc := ?; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1021 | for (i := 0; i < sizeof(bts_ids); i := i + 1) { |
| 1022 | rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc)); |
| 1023 | /* check channel type, paging group */ |
| 1024 | if (rx_rsl.ies[1].body.paging_group != paging_group) { |
| 1025 | setverdict(fail, "Paging for wrong paging group"); |
| 1026 | } |
| 1027 | if (ispresent(rsl_chneed) and |
| 1028 | rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) { |
| 1029 | setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed"); |
| 1030 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1031 | } |
Harald Welte | 2fccd98 | 2018-01-31 15:48:19 +0100 | [diff] [blame] | 1032 | f_sleep(2.0); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1033 | /* do a quick check on all not-included BTSs if they received paging */ |
| 1034 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 1035 | timer T := 0.1; |
| 1036 | if (f_bts_in_list(i, bts_ids)) { |
| 1037 | continue; |
| 1038 | } |
| 1039 | T.start; |
| 1040 | alt { |
| 1041 | [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) { |
| 1042 | setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids); |
| 1043 | } |
| 1044 | [] IPA_RSL[i].receive { repeat; } |
| 1045 | [] T.timeout { } |
| 1046 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | setverdict(pass); |
| 1050 | } |
| 1051 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1052 | const BtsIdList c_BtsId_all := { 0, 1, 2 }; |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1053 | const BtsIdList c_BtsId_none := { }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1054 | const BtsIdList c_BtsId_LAC1 := { 0, 1 }; |
| 1055 | const BtsIdList c_BtsId_LAC2 := { 2 }; |
| 1056 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1057 | /* PAGING by IMSI + TMSI */ |
| 1058 | testcase TC_paging_imsi_nochan() runs on test_CT { |
| 1059 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1060 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Philipp Maier | 8c04b0a | 2018-02-23 13:48:48 +0100 | [diff] [blame] | 1061 | f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1062 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | /* PAGING by IMSI + TMSI */ |
| 1066 | testcase TC_paging_tmsi_nochan() runs on test_CT { |
| 1067 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1068 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1069 | 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] | 1070 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | /* Paging with different "channel needed' values */ |
| 1074 | testcase TC_paging_tmsi_any() runs on test_CT { |
| 1075 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1076 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1077 | 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] | 1078 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1079 | } |
| 1080 | testcase TC_paging_tmsi_sdcch() runs on test_CT { |
| 1081 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1082 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1083 | 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] | 1084 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1085 | } |
| 1086 | testcase TC_paging_tmsi_tch_f() runs on test_CT { |
| 1087 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1088 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1089 | 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] | 1090 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1091 | } |
| 1092 | testcase TC_paging_tmsi_tch_hf() runs on test_CT { |
| 1093 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1094 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1095 | 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] | 1096 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | /* Paging by CGI */ |
| 1100 | testcase TC_paging_imsi_nochan_cgi() runs on test_CT { |
| 1101 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1102 | 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] | 1103 | f_pageing_helper('001010000000006'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1104 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | /* Paging by LAC+CI */ |
| 1108 | testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT { |
| 1109 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1110 | 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] | 1111 | f_pageing_helper('001010000000007'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1112 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | /* Paging by CI */ |
| 1116 | testcase TC_paging_imsi_nochan_ci() runs on test_CT { |
| 1117 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1118 | cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1119 | f_pageing_helper('001010000000008'H, cid_list, { 0 }); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1120 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | /* Paging by LAI */ |
| 1124 | testcase TC_paging_imsi_nochan_lai() runs on test_CT { |
| 1125 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1126 | 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] | 1127 | f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1128 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | /* Paging by LAC */ |
| 1132 | testcase TC_paging_imsi_nochan_lac() runs on test_CT { |
| 1133 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1134 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1135 | f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1136 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | /* Paging by "all in BSS" */ |
| 1140 | testcase TC_paging_imsi_nochan_all() runs on test_CT { |
| 1141 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1142 | cid_list := { cIl_allInBSS := ''O }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1143 | f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1144 | f_shutdown_helper(); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1145 | } |
| 1146 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1147 | /* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1148 | testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT { |
| 1149 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1150 | cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1151 | f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1152 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1153 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1154 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1155 | /* Paging by RNC; We do not implement this; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1156 | testcase TC_paging_imsi_nochan_rnc() runs on test_CT { |
| 1157 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1158 | cid_list := { cIl_RNC := { int2oct(13, 2) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1159 | f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1160 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1161 | } |
| 1162 | |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1163 | /* Paging by LAC+RNC; We do not implement; Verify nothing is paged */ |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1164 | testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT { |
| 1165 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1166 | cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } }; |
Stefan Sperling | 7b5e178 | 2018-03-20 19:32:43 +0100 | [diff] [blame^] | 1167 | f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1168 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1169 | } |
| 1170 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1171 | /* 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] | 1172 | testcase TC_paging_imsi_nochan_lacs() runs on test_CT { |
| 1173 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1174 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } }; |
| 1175 | f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1176 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | /* Paging on empty list: Verify none of them page */ |
| 1180 | testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT { |
| 1181 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1182 | cid_list := { cIl_LAC := { } }; |
| 1183 | f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none); |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1184 | f_shutdown_helper(); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1185 | } |
| 1186 | |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 1187 | /* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */ |
| 1188 | testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT { |
| 1189 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1190 | cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } }; |
| 1191 | f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none); |
| 1192 | f_shutdown_helper(); |
| 1193 | } |
| 1194 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1195 | /* Verify paging retransmission interval + count */ |
| 1196 | /* Verify paging stops after channel establishment */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1197 | /* Test behavior under paging overload */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1198 | |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1199 | /* Verify PCH load */ |
| 1200 | testcase TC_paging_imsi_load() runs on test_CT { |
| 1201 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1202 | timer T := 4.0; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1203 | timer T_retrans := 1.0; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1204 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1205 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1206 | |
| 1207 | /* tell BSC there is no paging space anymore */ |
| 1208 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
Harald Welte | 3b57ab5 | 2018-03-17 18:01:10 +0100 | [diff] [blame] | 1209 | f_sleep(0.2); |
| 1210 | IPA_RSL[0].clear; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1211 | |
| 1212 | /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally, |
| 1213 | * there would be 8 retransmissions during 4 seconds */ |
| 1214 | T.start; |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1215 | T_retrans.start; |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1216 | alt { |
| 1217 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1218 | setverdict(fail, "Received PAGING after LOAD_IND(0)"); |
| 1219 | self.stop; |
| 1220 | } |
Harald Welte | 2caa106 | 2018-03-17 18:19:05 +0100 | [diff] [blame] | 1221 | [] T_retrans.timeout { |
| 1222 | /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */ |
| 1223 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
| 1224 | T_retrans.start; |
| 1225 | repeat; |
| 1226 | } |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1227 | [] T.timeout { |
| 1228 | setverdict(pass); |
| 1229 | } |
| 1230 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1231 | |
| 1232 | f_shutdown_helper(); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1233 | } |
| 1234 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1235 | /* Verify Paging Counter */ |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1236 | testcase TC_paging_counter() runs on test_CT { |
| 1237 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1238 | timer T := 4.0; |
| 1239 | var integer i; |
| 1240 | var integer paging_attempted_bsc; |
| 1241 | var integer paging_attempted_bts[NUM_BTS]; |
| 1242 | var integer paging_expired_bts[NUM_BTS]; |
| 1243 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
| 1244 | |
| 1245 | f_init(); |
| 1246 | |
| 1247 | /* read counters before paging */ |
| 1248 | paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted"); |
| 1249 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1250 | paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted"); |
| 1251 | paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired"); |
| 1252 | } |
| 1253 | |
| 1254 | f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all); |
| 1255 | |
| 1256 | /* expect the attempted pages on BSC and each BTSs to have incremented by one */ |
| 1257 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1); |
| 1258 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1259 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted", |
| 1260 | paging_attempted_bts[i]+1); |
| 1261 | } |
| 1262 | |
| 1263 | /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */ |
| 1264 | f_sleep(12.0); |
| 1265 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1266 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired", |
| 1267 | paging_expired_bts[i]+1); |
| 1268 | } |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1269 | |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1270 | f_shutdown_helper(); |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1274 | /* Verify paging stops after A-RESET */ |
| 1275 | testcase TC_paging_imsi_a_reset() runs on test_CT { |
| 1276 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1277 | timer T := 3.0; |
| 1278 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1279 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1280 | |
| 1281 | /* Perform a BSSMAP Reset and wait for ACK */ |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1282 | 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] | 1283 | alt { |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1284 | [] 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] | 1285 | [] BSSAP.receive { repeat; } |
| 1286 | } |
| 1287 | |
| 1288 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Philipp Maier | 1e6b442 | 2018-02-23 14:02:13 +0100 | [diff] [blame] | 1289 | for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) { |
| 1290 | IPA_RSL[i].clear; |
| 1291 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1292 | |
| 1293 | /* Wait for 3 seconds if any more PAGING CMD are received on RSL */ |
| 1294 | T.start; |
| 1295 | alt { |
| 1296 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1297 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1298 | self.stop; |
| 1299 | } |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1300 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1301 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1302 | self.stop; |
| 1303 | } |
| 1304 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1305 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1306 | self.stop; |
| 1307 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1308 | [] T.timeout { |
| 1309 | setverdict(pass); |
| 1310 | } |
| 1311 | } |
Philipp Maier | 282ca4b | 2018-02-27 17:17:00 +0100 | [diff] [blame] | 1312 | |
| 1313 | f_shutdown_helper(); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1314 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1315 | |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1316 | /* Test RSL link drop causes counter increment */ |
| 1317 | testcase TC_rsl_drop_counter() runs on test_CT { |
| 1318 | var integer rsl_fail; |
| 1319 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1320 | f_init(1); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1321 | |
| 1322 | rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail"); |
| 1323 | |
| 1324 | bts[0].rsl.vc_IPA.stop; |
| 1325 | |
| 1326 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1); |
| 1327 | |
| 1328 | setverdict(pass); |
| 1329 | } |
| 1330 | |
| 1331 | /* TODO: Test OML link drop causes counter increment */ |
| 1332 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1333 | /* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */ |
| 1334 | function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean { |
| 1335 | timer T := 10.0; |
| 1336 | |
| 1337 | bts[0].rsl.id := "IPA-0-RSL"; |
| 1338 | bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA"); |
| 1339 | bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars; |
| 1340 | bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 1341 | bts[0].rsl.ccm_pars.unit_id := "0/0/0"; /* value which is unknown at BTS */ |
| 1342 | |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1343 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
| 1344 | |
| 1345 | f_init_mgcp("VirtMSC"); |
| 1346 | |
| 1347 | /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */ |
| 1348 | map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA); |
| 1349 | connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]); |
| 1350 | bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars)); |
| 1351 | |
| 1352 | /* wait for IPA OML link to connect and then disconnect */ |
| 1353 | T.start; |
| 1354 | alt { |
| 1355 | [] IPA_RSL[0].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_DOWN}) { |
| 1356 | T.stop; |
| 1357 | return true; |
| 1358 | } |
| 1359 | [] IPA_RSL[0].receive { repeat } |
| 1360 | [] T.timeout { |
| 1361 | self.stop; |
| 1362 | return false; |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | return false; |
| 1367 | } |
| 1368 | |
| 1369 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1370 | testcase TC_rsl_unknown_unit_id() runs on test_CT { |
| 1371 | if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) { |
| 1372 | setverdict(pass); |
| 1373 | } else { |
| 1374 | setverdict(fail, "Timeout RSL waiting for connection to close"); |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | |
| 1379 | /* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */ |
| 1380 | testcase TC_oml_unknown_unit_id() runs on test_CT { |
| 1381 | if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) { |
| 1382 | setverdict(pass); |
| 1383 | } else { |
| 1384 | setverdict(fail, "Timeout OML waiting for connection to close"); |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1389 | /*********************************************************************** |
| 1390 | * "New world" test cases using RSL_Emulation + BSSMAP_Emulation |
| 1391 | ***********************************************************************/ |
| 1392 | |
| 1393 | import from BSSMAP_Emulation all; |
| 1394 | import from RSL_Emulation all; |
| 1395 | import from MSC_ConnectionHandler all; |
| 1396 | |
| 1397 | type function void_fn(charstring id) runs on MSC_ConnHdlr; |
| 1398 | |
| 1399 | /* helper function to create, connect and start a MSC_ConnHdlr component */ |
| 1400 | function f_start_handler(void_fn fn, charstring id) runs on test_CT return MSC_ConnHdlr { |
| 1401 | var MSC_ConnHdlr vc_conn; |
| 1402 | |
| 1403 | vc_conn := MSC_ConnHdlr.create(id); |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1404 | connect(vc_conn:BSSMAPEM, g_bssap.vc_BSSMAP:PROC); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1405 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1406 | connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 1407 | connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC); |
Philipp Maier | 88f4ae8 | 2018-03-01 14:00:58 +0100 | [diff] [blame] | 1408 | if (isvalue(bts[1])) { |
Philipp Maier | 956a92f | 2018-02-16 10:58:07 +0100 | [diff] [blame] | 1409 | connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT); |
| 1410 | connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC); |
| 1411 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 1412 | connect(vc_conn:BSSAP, g_bssap.vc_BSSMAP:CLIENT); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1413 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1414 | vc_conn.start(derefers(fn)(id)); |
| 1415 | return vc_conn; |
| 1416 | } |
| 1417 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1418 | private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr { |
| 1419 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1420 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1421 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1422 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1423 | const OCT8 kc := '0001020304050607'O; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1424 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1425 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1426 | 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] | 1427 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1428 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1429 | f_cipher_mode('01'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | testcase TC_assignment_fr_a5_0() runs on test_CT { |
| 1433 | var MSC_ConnHdlr vc_conn; |
| 1434 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1435 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1436 | f_sleep(1.0); |
| 1437 | |
| 1438 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_0), testcasename()); |
| 1439 | vc_conn.done; |
| 1440 | } |
| 1441 | |
| 1442 | |
| 1443 | |
| 1444 | 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] | 1445 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1446 | |
| 1447 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1448 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1449 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1450 | const OCT8 kc := '0001020304050607'O; |
| 1451 | |
| 1452 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1453 | 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] | 1454 | |
| 1455 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1456 | f_cipher_mode('02'O, kc); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1457 | } |
| 1458 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1459 | testcase TC_assignment_fr_a5_1() runs on test_CT { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1460 | var MSC_ConnHdlr vc_conn; |
| 1461 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1462 | f_init(1, true); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1463 | f_sleep(1.0); |
| 1464 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1465 | 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] | 1466 | vc_conn.done; |
| 1467 | } |
| 1468 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1469 | /* Expect ASSIGNMENT FAIL if mandatory IE is missing */ |
| 1470 | private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr { |
| 1471 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1472 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 1473 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1474 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1475 | const OCT8 kc := '0001020304050607'O; |
| 1476 | |
| 1477 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1478 | f_establish_fully(pars, ass_cmd, exp_fail); |
| 1479 | } |
| 1480 | |
| 1481 | testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT { |
| 1482 | var MSC_ConnHdlr vc_conn; |
| 1483 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1484 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1485 | f_sleep(1.0); |
| 1486 | |
| 1487 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing), testcasename()); |
| 1488 | vc_conn.done; |
| 1489 | } |
| 1490 | |
| 1491 | |
| 1492 | private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr { |
| 1493 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1494 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1495 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1496 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1497 | const OCT8 kc := '0001020304050607'O; |
| 1498 | |
| 1499 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1500 | 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] | 1501 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1502 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1503 | f_cipher_mode('08'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | testcase TC_assignment_fr_a5_3() runs on test_CT { |
| 1507 | var MSC_ConnHdlr vc_conn; |
| 1508 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1509 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1510 | f_sleep(1.0); |
| 1511 | |
| 1512 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_3), testcasename()); |
| 1513 | vc_conn.done; |
| 1514 | } |
| 1515 | |
| 1516 | |
| 1517 | private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr { |
| 1518 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1519 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1520 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1521 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1522 | const OCT8 kc := '0001020304050607'O; |
| 1523 | const OCT16 kc128 := kc & kc; |
| 1524 | |
| 1525 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1526 | 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] | 1527 | f_establish_fully(pars, ass_cmd, exp_compl); |
| 1528 | f_cipher_mode('10'O, kc, kc128, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1529 | /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */ |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1530 | } |
| 1531 | |
| 1532 | testcase TC_assignment_fr_a5_4() runs on test_CT { |
| 1533 | var MSC_ConnHdlr vc_conn; |
| 1534 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1535 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1536 | f_sleep(1.0); |
| 1537 | |
| 1538 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4), testcasename()); |
| 1539 | vc_conn.done; |
| 1540 | } |
| 1541 | |
| 1542 | |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1543 | private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr { |
| 1544 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1545 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit); |
| 1546 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit)); |
| 1547 | |
| 1548 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL); |
| 1549 | f_establish_fully(pars, ass_cmd, exp_compl); |
| 1550 | } |
| 1551 | |
| 1552 | testcase TC_assignment_sign() runs on test_CT { |
| 1553 | var MSC_ConnHdlr vc_conn; |
| 1554 | |
| 1555 | f_init(1, true); |
| 1556 | f_sleep(1.0); |
| 1557 | |
| 1558 | vc_conn := f_start_handler(refers(f_tc_assignment_sign), testcasename()); |
| 1559 | vc_conn.done; |
| 1560 | } |
| 1561 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1562 | /* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */ |
| 1563 | private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr { |
| 1564 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1565 | f_create_chan_and_exp(pars); |
| 1566 | /* we should now have a COMPL_L3 at the MSC */ |
| 1567 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1568 | |
| 1569 | f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2))); |
| 1570 | BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit)); |
| 1571 | setverdict(pass); |
| 1572 | } |
| 1573 | testcase TC_classmark() runs on test_CT { |
| 1574 | var MSC_ConnHdlr vc_conn; |
| 1575 | f_init(1, true); |
| 1576 | f_sleep(1.0); |
| 1577 | vc_conn := f_start_handler(refers(f_tc_classmark), testcasename()); |
| 1578 | vc_conn.done; |
| 1579 | } |
| 1580 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1581 | 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] | 1582 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1583 | f_create_chan_and_exp(pars); |
| 1584 | /* we should now have a COMPL_L3 at the MSC */ |
| 1585 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1586 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1587 | /* send the single message we want to send */ |
| 1588 | f_rsl_send_l3(l3); |
| 1589 | } |
| 1590 | |
| 1591 | private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr { |
| 1592 | timer T := sec; |
| 1593 | var PDU_BSSAP bssap; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1594 | T.start; |
| 1595 | alt { |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1596 | [] BSSAP.receive(PDU_BSSAP:?) -> value bssap { |
| 1597 | setverdict(fail, "Unexpected BSSMAP ", bssap); |
| 1598 | self.stop; |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1599 | } |
| 1600 | [] T.timeout { |
| 1601 | setverdict(pass); |
| 1602 | } |
| 1603 | } |
| 1604 | } |
| 1605 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1606 | /* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1607 | private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr { |
| 1608 | f_est_single_l3(ts_RRM_AssignmentFailure('00'O)); |
| 1609 | f_bssap_expect_nothing(); |
| 1610 | } |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1611 | testcase TC_unsol_ass_fail() runs on test_CT { |
| 1612 | var MSC_ConnHdlr vc_conn; |
| 1613 | f_init(1, true); |
| 1614 | f_sleep(1.0); |
| 1615 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail), testcasename()); |
| 1616 | vc_conn.done; |
| 1617 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1618 | |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 1619 | |
| 1620 | /* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1621 | 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] | 1622 | f_est_single_l3(ts_RRM_AssignmentComplete('00'O)); |
| 1623 | f_bssap_expect_nothing(); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 1624 | } |
| 1625 | testcase TC_unsol_ass_compl() runs on test_CT { |
| 1626 | var MSC_ConnHdlr vc_conn; |
| 1627 | f_init(1, true); |
| 1628 | f_sleep(1.0); |
| 1629 | vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl), testcasename()); |
| 1630 | vc_conn.done; |
| 1631 | } |
| 1632 | |
| 1633 | |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1634 | /* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */ |
| 1635 | 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] | 1636 | f_est_single_l3(ts_RRM_HandoverFailure('00'O)); |
| 1637 | f_bssap_expect_nothing(); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1638 | } |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1639 | testcase TC_unsol_ho_fail() runs on test_CT { |
| 1640 | var MSC_ConnHdlr vc_conn; |
| 1641 | f_init(1, true); |
| 1642 | f_sleep(1.0); |
| 1643 | vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail), testcasename()); |
| 1644 | vc_conn.done; |
| 1645 | } |
| 1646 | |
| 1647 | |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1648 | /* short message from MS should be ignored */ |
| 1649 | private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr { |
| 1650 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1651 | f_create_chan_and_exp(pars); |
| 1652 | /* we should now have a COMPL_L3 at the MSC */ |
| 1653 | BSSAP.receive(tr_BSSMAP_ComplL3); |
| 1654 | |
| 1655 | /* send short message */ |
| 1656 | RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O)); |
| 1657 | f_bssap_expect_nothing(); |
| 1658 | } |
| 1659 | testcase TC_err_82_short_msg() runs on test_CT { |
| 1660 | var MSC_ConnHdlr vc_conn; |
| 1661 | f_init(1, true); |
| 1662 | f_sleep(1.0); |
| 1663 | vc_conn := f_start_handler(refers(f_tc_err_82_short_msg), testcasename()); |
| 1664 | vc_conn.done; |
| 1665 | } |
| 1666 | |
| 1667 | |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1668 | /* 24.008 8.4 Unknown message must trigger RR STATUS */ |
| 1669 | private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr { |
| 1670 | f_est_single_l3(ts_RRM_UL_REL('00'O)); |
| 1671 | timer T := 3.0 |
| 1672 | alt { |
| 1673 | [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) { |
| 1674 | setverdict(pass); |
| 1675 | } |
| 1676 | [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); } |
| 1677 | [] T.timeout { setverdict(inconc); } |
| 1678 | } |
| 1679 | } |
| 1680 | testcase TC_err_84_unknown_msg() runs on test_CT { |
| 1681 | var MSC_ConnHdlr vc_conn; |
| 1682 | f_init(1, true); |
| 1683 | f_sleep(1.0); |
| 1684 | vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg), testcasename()); |
| 1685 | vc_conn.done; |
| 1686 | } |
| 1687 | |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1688 | /* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */ |
| 1689 | private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr) |
| 1690 | runs on MSC_ConnHdlr { |
| 1691 | /* FIXME: resolve those from component-global state */ |
| 1692 | var integer ts_nr := chan_nr.tn; |
| 1693 | var integer ss_nr; |
| 1694 | if (ischosen(chan_nr.u.ch0)) { |
| 1695 | ss_nr := 0; |
| 1696 | } else if (ischosen(chan_nr.u.lm)) { |
| 1697 | ss_nr := chan_nr.u.lm.sub_chan; |
| 1698 | } else if (ischosen(chan_nr.u.sdcch4)) { |
| 1699 | ss_nr := chan_nr.u.sdcch4.sub_chan; |
| 1700 | } else if (ischosen(chan_nr.u.sdcch8)) { |
| 1701 | ss_nr := chan_nr.u.sdcch8.sub_chan; |
| 1702 | } else { |
| 1703 | setverdict(fail, "Invalid ChanNr ", chan_nr); |
| 1704 | self.stop; |
| 1705 | } |
| 1706 | |
| 1707 | var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)& |
| 1708 | " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" "; |
| 1709 | f_vty_transceive(BSCVTY, cmd & suffix); |
| 1710 | } |
| 1711 | |
| 1712 | private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr, |
| 1713 | integer new_bts_nr) |
| 1714 | runs on MSC_ConnHdlr { |
| 1715 | f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr); |
| 1716 | } |
| 1717 | |
| 1718 | /* intra-BSC hand-over between BTS0 and BTS1 */ |
| 1719 | private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr { |
| 1720 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1721 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1722 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1723 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1724 | const OCT8 kc := '0001020304050607'O; |
| 1725 | |
| 1726 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1727 | ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR})); |
| 1728 | |
| 1729 | f_establish_fully(pars, ass_cmd, exp_compl); |
| 1730 | |
| 1731 | var HandoverState hs := { |
| 1732 | rr_ho_cmpl_seen := false, |
| 1733 | handover_done := false, |
| 1734 | old_chan_nr := - |
| 1735 | }; |
| 1736 | /* issue hand-over command on VTY */ |
| 1737 | f_vty_handover(0, 0, g_chan_nr, 1); |
| 1738 | /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */ |
| 1739 | f_rslem_suspend(RSL1_PROC); |
| 1740 | alt { |
| 1741 | [] as_handover(hs); |
| 1742 | /* FIXME: somehow determine that the hand-over has completed, by MGCP MDCX? */ |
| 1743 | } |
| 1744 | } |
| 1745 | |
| 1746 | testcase TC_ho_int() runs on test_CT { |
| 1747 | var MSC_ConnHdlr vc_conn; |
| 1748 | f_init(2, true); |
| 1749 | f_sleep(1.0); |
| 1750 | vc_conn := f_start_handler(refers(f_tc_ho_int), testcasename()); |
| 1751 | vc_conn.done; |
| 1752 | } |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1753 | |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 1754 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 1755 | * BSSMAP Reset just because of that. */ |
| 1756 | testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT { |
| 1757 | var default d; |
| 1758 | var integer i; |
| 1759 | var DchanTuple dt; |
| 1760 | |
| 1761 | f_init(); |
| 1762 | |
| 1763 | /* Wait for initial BSSMAP Reset to pass */ |
| 1764 | f_sleep(4.0); |
| 1765 | |
| 1766 | d := activate(no_bssmap_reset()); |
| 1767 | |
| 1768 | /* Setup up a number of connections and RLSD them again from the MSC |
| 1769 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 1770 | * Let's do it some more times for good measure. */ |
| 1771 | for (i := 0; i < 8; i := i+1) { |
| 1772 | /* Since we're doing a lot of runs, give each one a fresh |
| 1773 | * T_guard from the top. */ |
| 1774 | T_guard.start; |
| 1775 | |
| 1776 | /* Setup a BSSAP connection and clear it right away. This is |
| 1777 | * the MSC telling the BSC about a planned release, it's not an |
| 1778 | * erratic loss of a connection. */ |
| 1779 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 1780 | |
| 1781 | /* MSC disconnects (RLSD). */ |
| 1782 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 1783 | } |
| 1784 | |
| 1785 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 1786 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 1787 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 1788 | f_sleep(4.0); |
| 1789 | |
| 1790 | deactivate(d); |
| 1791 | f_shutdown_helper(); |
| 1792 | } |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1793 | |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 1794 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 1795 | * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from |
| 1796 | * the MSC. */ |
| 1797 | testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT { |
| 1798 | var default d; |
| 1799 | var integer i; |
| 1800 | var DchanTuple dt; |
| 1801 | var BSSAP_N_DATA_ind rx_di; |
| 1802 | var RSL_Message rx_rsl; |
| 1803 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL; |
| 1804 | var BssmapCause cause := enum2int(cause_val); |
| 1805 | |
| 1806 | f_init(); |
| 1807 | |
| 1808 | /* Wait for initial BSSMAP Reset to pass */ |
| 1809 | f_sleep(4.0); |
| 1810 | |
| 1811 | d := activate(no_bssmap_reset()); |
| 1812 | |
| 1813 | /* Setup up a number of connections and RLSD them again from the MSC |
| 1814 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 1815 | * Let's do it some more times for good measure. */ |
| 1816 | for (i := 0; i < 8; i := i+1) { |
| 1817 | /* Since we're doing a lot of runs, give each one a fresh |
| 1818 | * T_guard from the top. */ |
| 1819 | T_guard.start; |
| 1820 | |
| 1821 | /* Setup a BSSAP connection and clear it right away. This is |
| 1822 | * the MSC telling the BSC about a planned release, it's not an |
| 1823 | * erratic loss of a connection. */ |
| 1824 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 1825 | |
| 1826 | /* Instruct BSC to clear channel */ |
| 1827 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 1828 | |
| 1829 | /* expect BSC to disable the channel */ |
| 1830 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 1831 | /* respond with CHAN REL ACK */ |
| 1832 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 1833 | |
| 1834 | /* expect Clear Complete from BSC */ |
| 1835 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 1836 | |
| 1837 | /* MSC disconnects as instructed. */ |
| 1838 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 1839 | |
| 1840 | |
| 1841 | /* MSC disconnects (RLSD). */ |
| 1842 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 1843 | } |
| 1844 | |
| 1845 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 1846 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 1847 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 1848 | f_sleep(4.0); |
| 1849 | |
| 1850 | deactivate(d); |
| 1851 | f_shutdown_helper(); |
| 1852 | } |
| 1853 | |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 1854 | /* OS#3041: Open and close N connections in a normal fashion, and expect no |
| 1855 | * BSSMAP Reset just because of that. Close connections from the MS side with a |
| 1856 | * Release Ind on RSL. */ |
| 1857 | testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT { |
| 1858 | var default d; |
| 1859 | var integer i; |
| 1860 | var DchanTuple dt; |
| 1861 | var BSSAP_N_DATA_ind rx_di; |
| 1862 | var RSL_Message rx_rsl; |
| 1863 | var integer j; |
| 1864 | |
| 1865 | f_init(); |
| 1866 | |
| 1867 | /* Wait for initial BSSMAP Reset to pass */ |
| 1868 | f_sleep(4.0); |
| 1869 | |
| 1870 | d := activate(no_bssmap_reset()); |
| 1871 | |
| 1872 | /* Setup up a number of connections and RLSD them again from the MSC |
| 1873 | * side. In the buggy behavior, the fourth one triggers BSSMAP Reset. |
| 1874 | * Let's do it some more times for good measure. */ |
| 1875 | for (i := 0; i < 8; i := i+1) { |
| 1876 | /* Since we're doing a lot of runs, give each one a fresh |
| 1877 | * T_guard from the top. */ |
| 1878 | T_guard.start; |
| 1879 | |
| 1880 | /* Setup a BSSAP connection and clear it right away. This is |
| 1881 | * the MSC telling the BSC about a planned release, it's not an |
| 1882 | * erratic loss of a connection. */ |
| 1883 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 1884 | |
| 1885 | /* simulate RLL REL IND */ |
| 1886 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 1887 | |
| 1888 | /* expect Clear Request on MSC side */ |
| 1889 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 1890 | |
| 1891 | /* Instruct BSC to clear channel */ |
| 1892 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 1893 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 1894 | |
| 1895 | /* expect BSC to disable the channel */ |
| 1896 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 1897 | /* respond with CHAN REL ACK */ |
| 1898 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 1899 | |
| 1900 | /* expect Clear Complete from BSC */ |
| 1901 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 1902 | |
| 1903 | /* MSC disconnects as instructed. */ |
| 1904 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 1905 | } |
| 1906 | |
| 1907 | /* In the buggy behavior, a timeout of 2 seconds happens between above |
| 1908 | * trigger (logs "SIGTRAN connection down, reconnecting...") and the |
| 1909 | * actual BSSMAP Reset. Wait a bit longer just to make sure. */ |
| 1910 | f_sleep(4.0); |
| 1911 | |
| 1912 | deactivate(d); |
| 1913 | f_shutdown_helper(); |
| 1914 | } |
| 1915 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1916 | control { |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1917 | /* CTRL interface testing */ |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1918 | execute( TC_ctrl_msc_connection_status() ); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 1919 | execute( TC_ctrl_msc0_connection_status() ); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 1920 | execute( TC_ctrl() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1921 | |
| 1922 | /* RSL DCHAN Channel ACtivation / Deactivation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1923 | execute( TC_chan_act_noreply() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1924 | execute( TC_chan_act_counter() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1925 | execute( TC_chan_act_ack_noest() ); |
| 1926 | execute( TC_chan_act_ack_est_ind_noreply() ); |
| 1927 | execute( TC_chan_act_ack_est_ind_refused() ); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 1928 | execute( TC_chan_act_nack() ); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 1929 | execute( TC_chan_exhaustion() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1930 | execute( TC_chan_rel_rll_rel_ind() ); |
| 1931 | execute( TC_chan_rel_conn_fail() ); |
| 1932 | execute( TC_chan_rel_hard_clear() ); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 1933 | execute( TC_chan_rel_hard_rlsd() ); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 1934 | execute( TC_chan_rel_a_reset() ); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1935 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 1936 | execute( TC_outbound_connect() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1937 | |
| 1938 | /* Assignment related */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 1939 | execute( TC_assignment_cic_only() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1940 | execute( TC_assignment_csd() ); |
| 1941 | execute( TC_assignment_ctm() ); |
| 1942 | execute( TC_assignment_sign() ); |
| 1943 | execute( TC_assignment_fr_a5_0() ); |
| 1944 | execute( TC_assignment_fr_a5_1() ); |
Harald Welte | f1b64e2 | 2017-12-15 14:55:14 +0100 | [diff] [blame] | 1945 | execute( TC_assignment_fr_a5_1_codec_missing() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1946 | execute( TC_assignment_fr_a5_3() ); |
| 1947 | execute( TC_assignment_fr_a5_4() ); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 1948 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1949 | /* RLL Establish Indication on inactive DCHAN / SAPI */ |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1950 | execute( TC_rll_est_ind_inact_lchan() ); |
| 1951 | execute( TC_rll_est_ind_inval_sapi1() ); |
| 1952 | execute( TC_rll_est_ind_inval_sapi3() ); |
| 1953 | execute( TC_rll_est_ind_inval_sacch() ); |
| 1954 | |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1955 | /* Paging related tests */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1956 | execute( TC_paging_imsi_nochan() ); |
| 1957 | execute( TC_paging_tmsi_nochan() ); |
| 1958 | execute( TC_paging_tmsi_any() ); |
| 1959 | execute( TC_paging_tmsi_sdcch() ); |
| 1960 | execute( TC_paging_tmsi_tch_f() ); |
| 1961 | execute( TC_paging_tmsi_tch_hf() ); |
| 1962 | execute( TC_paging_imsi_nochan_cgi() ); |
| 1963 | execute( TC_paging_imsi_nochan_lac_ci() ); |
| 1964 | execute( TC_paging_imsi_nochan_ci() ); |
| 1965 | execute( TC_paging_imsi_nochan_lai() ); |
| 1966 | execute( TC_paging_imsi_nochan_lac() ); |
| 1967 | execute( TC_paging_imsi_nochan_all() ); |
Harald Welte | 751d3eb | 2018-01-31 15:51:06 +0100 | [diff] [blame] | 1968 | execute( TC_paging_imsi_nochan_plmn_lac_rnc() ); |
| 1969 | execute( TC_paging_imsi_nochan_rnc() ); |
| 1970 | execute( TC_paging_imsi_nochan_lac_rnc() ); |
| 1971 | execute( TC_paging_imsi_nochan_lacs() ); |
| 1972 | execute( TC_paging_imsi_nochan_lacs_empty() ); |
Stefan Sperling | 049a86e | 2018-03-20 15:51:00 +0100 | [diff] [blame] | 1973 | execute( TC_paging_imsi_nochan_cgi_unknown_cid() ); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1974 | execute( TC_paging_imsi_a_reset() ); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1975 | execute( TC_paging_imsi_load() ); |
Philipp Maier | 779a792 | 2018-02-16 11:00:37 +0100 | [diff] [blame] | 1976 | execute( TC_paging_counter() ); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1977 | |
| 1978 | execute( TC_rsl_drop_counter() ); |
Stefan Sperling | 830dc9d | 2018-02-12 21:08:28 +0100 | [diff] [blame] | 1979 | execute( TC_rsl_unknown_unit_id() ); |
| 1980 | |
| 1981 | execute( TC_oml_unknown_unit_id() ); |
Harald Welte | 898113b | 2018-01-31 18:32:21 +0100 | [diff] [blame] | 1982 | |
| 1983 | execute( TC_classmark() ); |
| 1984 | execute( TC_unsol_ass_fail() ); |
Harald Welte | ea99a00 | 2018-01-31 20:46:43 +0100 | [diff] [blame] | 1985 | execute( TC_unsol_ass_compl() ); |
Harald Welte | fbf9b5e | 2018-01-31 20:41:23 +0100 | [diff] [blame] | 1986 | execute( TC_unsol_ho_fail() ); |
Harald Welte | e3bd658 | 2018-01-31 22:51:25 +0100 | [diff] [blame] | 1987 | execute( TC_err_82_short_msg() ); |
Harald Welte | e9e02e4 | 2018-01-31 23:36:25 +0100 | [diff] [blame] | 1988 | execute( TC_err_84_unknown_msg() ); |
Harald Welte | 261af4b | 2018-02-12 21:20:39 +0100 | [diff] [blame] | 1989 | execute( TC_ho_int() ); |
Neels Hofmeyr | cdc2d76 | 2018-03-12 01:48:11 +0100 | [diff] [blame] | 1990 | |
| 1991 | execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | 4ff9328 | 2018-03-12 04:25:35 +0100 | [diff] [blame] | 1992 | execute( TC_bssmap_clear_does_not_cause_bssmap_reset() ); |
Neels Hofmeyr | fd445c3 | 2018-03-09 15:39:31 +0100 | [diff] [blame] | 1993 | execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() ); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1994 | } |
| 1995 | |
| 1996 | } |