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; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 31 | import from IPA_Types all; |
| 32 | import from RSL_Types all; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 33 | import from RSL_Emulation all; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 34 | import from MGCP_Emulation all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 35 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 36 | import from Osmocom_CTRL_Functions all; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 37 | import from Osmocom_CTRL_Types all; |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 38 | import from Osmocom_CTRL_Adapter all; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 39 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 40 | import from MobileL3_CommonIE_Types all; |
| 41 | import from L3_Templates all; |
| 42 | import from GSM_RR_Types all; |
| 43 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 44 | const integer NUM_BTS := 3; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 45 | const float T3101_MAX := 12.0; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 46 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 47 | /* make sure to sync this with the osmo-bts.cfg you're using */ |
| 48 | const integer NUM_TCHF_PER_BTS := 5; |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 49 | const integer NUM_SDCCH_PER_BTS := 4; |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 50 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 51 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 52 | /* per-BTS state which we keep */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 53 | type record BTS_State { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 54 | /* component reference to the IPA_Client component used for RSL */ |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 55 | IPA_Client rsl |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 58 | type component test_CT extends BSSAP_Adapter_CT, CTRL_Adapter_CT { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 59 | /* Array of per-BTS state */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 60 | var BTS_State bts[NUM_BTS]; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 61 | /* array of per-BTS RSL test ports */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 62 | port IPA_RSL_PT IPA_RSL[NUM_BTS]; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 63 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 64 | var MGCP_Emulation_CT vc_MGCP; |
| 65 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 66 | /* are we initialized yet */ |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 67 | var boolean g_initialized := false; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 68 | |
| 69 | /* global test case guard timer */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 70 | timer T_guard := 30.0; |
| 71 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | modulepar { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 75 | /* IP address at which the BSC can be reached */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 76 | charstring mp_bsc_ip := "127.0.0.1"; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 77 | /* port number to which to establish the IPA RSL connections */ |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 78 | integer mp_bsc_rsl_port := 3003; |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 79 | /* port number to which to establish the IPA CTRL connection */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 80 | integer mp_bsc_ctrl_port := 4249; |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 81 | /* IP address at which the test binds */ |
| 82 | charstring mp_test_ip := "127.0.0.1"; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 85 | type record IPA_Client { |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 86 | /* IPA Emulation component reference */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 87 | IPA_Emulation_CT vc_IPA, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 88 | /* Unit-ID and other CCM parameters to use for IPA client emulation */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 89 | IPA_CCM_Parameters ccm_pars, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 90 | /* String identifier for this IPA Client */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 91 | charstring id, |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 92 | /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 93 | RSL_Emulation_CT vc_RSL optional |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 94 | } |
| 95 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 96 | /*! Start the IPA/RSL related bits for one IPA_Client. |
| 97 | * \param clnt IPA_Client for which to establish |
| 98 | * \param bsc_host IP address / hostname of the BSC |
| 99 | * \param bsc_port TCP port number of the BSC |
| 100 | * \param i number identifying this BTS |
| 101 | * \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] | 102 | function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i, |
| 103 | boolean handler_mode := false) |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 104 | runs on test_CT { |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 105 | timer T := 10.0; |
| 106 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 107 | clnt.id := "IPA" & int2str(i) & "-RSL"; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 108 | clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA"); |
| 109 | clnt.ccm_pars := c_IPA_default_ccm_pars; |
| 110 | clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 111 | clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0"; |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 112 | if (handler_mode) { |
| 113 | clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL"); |
| 114 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 115 | |
| 116 | map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 117 | if (handler_mode) { |
| 118 | connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT); |
| 119 | } else { |
| 120 | connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]); |
| 121 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 122 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 123 | 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] | 124 | if (handler_mode) { |
| 125 | clnt.vc_RSL.start(RSL_Emulation.main()); |
| 126 | return; |
| 127 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 128 | |
| 129 | /* wait for IPA RSL link to connect and send ID ACK */ |
| 130 | T.start; |
| 131 | alt { |
| 132 | [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) { |
| 133 | T.stop; |
| 134 | IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23))); |
| 135 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 136 | [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 137 | [] IPA_RSL[i].receive { repeat } |
| 138 | [] T.timeout { |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 139 | setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK"); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 140 | self.stop; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 145 | /* 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] | 146 | function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT { |
| 147 | timer T := secs_max; |
| 148 | T.start; |
| 149 | while (true) { |
| 150 | if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) { |
| 151 | T.stop; |
Harald Welte | bd868bd | 2017-12-10 18:28:40 +0100 | [diff] [blame] | 152 | /* the 'degraded' state exists from OML connection time, and we have to wait |
| 153 | * until all MO's are initialized */ |
| 154 | T.start(1.0); |
| 155 | T.timeout; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 156 | return; |
| 157 | } |
Harald Welte | f0d6ac6 | 2017-12-17 17:02:21 +0100 | [diff] [blame] | 158 | f_sleep(0.1); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 159 | if (not T.running) { |
| 160 | setverdict(fail, "Timeout waiting for oml-connection-state ", status); |
| 161 | self.stop; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 166 | /* sleep for given number of (fractional) seconds */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 167 | function f_sleep(float seconds) { |
| 168 | timer T := seconds; |
| 169 | T.start; |
| 170 | T.timeout; |
| 171 | } |
| 172 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 173 | /* 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] | 174 | altstep as_Tguard() runs on test_CT { |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 175 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 176 | [] T_guard.timeout { setverdict(fail, "Timeout of T_guard"); } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 177 | /* always respond with RESET ACK to RESET */ |
| 178 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 179 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 180 | ts_BSSMAP_ResetAck)); |
Harald Welte | 69c1c26 | 2017-12-13 21:02:08 +0100 | [diff] [blame] | 181 | repeat; |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 182 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 183 | } |
| 184 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 185 | function f_init_mgcp(charstring id) runs on test_CT { |
| 186 | id := id & "-MGCP"; |
| 187 | |
| 188 | var MGCPOps ops := { |
| 189 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 190 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 191 | }; |
| 192 | var MGCP_conn_parameters mgcp_pars := { |
| 193 | callagent_ip := mp_bsc_ip, |
Harald Welte | 9e4273e | 2018-01-29 22:01:22 +0100 | [diff] [blame] | 194 | callagent_udp_port := -1, |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 195 | mgw_ip := mp_test_ip, |
| 196 | mgw_udp_port := 2427 |
| 197 | }; |
| 198 | |
| 199 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 200 | vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id)); |
| 201 | } |
| 202 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 203 | /* global initialization function |
| 204 | * \param nr_bts Number of BTSs we should start/bring up |
| 205 | * \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] | 206 | 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] | 207 | var integer i; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 208 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 209 | if (g_initialized) { |
| 210 | return; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 211 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 212 | g_initialized := true; |
| 213 | |
| 214 | /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the |
| 215 | * MSC-side BSSAP emulation */ |
Harald Welte | 67089ee | 2018-01-17 22:19:03 +0100 | [diff] [blame] | 216 | if (handler_mode) { |
| 217 | f_bssap_init("VirtMSC", MSC_BssmapOps); |
| 218 | } else { |
| 219 | f_bssap_init("VirtMSC", omit); |
| 220 | } |
Harald Welte | ffe55fc | 2018-01-17 22:39:54 +0100 | [diff] [blame] | 221 | f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 222 | |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 223 | f_init_mgcp("VirtMSC"); |
| 224 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 225 | for (i := 0; i < nr_bts; i := i+1) { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 226 | /* wait until osmo-bts-omldummy has respawned */ |
| 227 | f_wait_oml(i, "degraded", 5.0); |
| 228 | /* start RSL connection */ |
Harald Welte | 624f963 | 2017-12-16 19:26:04 +0100 | [diff] [blame] | 229 | 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] | 230 | /* wait until BSC tells us "connected" */ |
| 231 | f_wait_oml(i, "connected", 5.0); |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 232 | } |
| 233 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 234 | T_guard.start; |
| 235 | activate(as_Tguard()); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 236 | } |
| 237 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 238 | /* 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] | 239 | function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 240 | runs on test_CT return RSL_Message { |
| 241 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 242 | timer T := t_secs; |
| 243 | |
| 244 | T.start; |
| 245 | alt { |
| 246 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud { |
| 247 | T.stop; |
| 248 | } |
| 249 | [] IPA_RSL[bts_nr].receive { repeat; } |
Harald Welte | b291770 | 2017-12-10 15:48:52 +0100 | [diff] [blame] | 250 | [] T.timeout { |
| 251 | setverdict(fail, "Timeout expecting ", t_rx); |
| 252 | self.stop; |
| 253 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 254 | } |
| 255 | return rx_rsl_ud.rsl; |
| 256 | } |
| 257 | |
Harald Welte | 21b46bd | 2017-12-17 19:46:32 +0100 | [diff] [blame] | 258 | /* helper function to transmit RSL on a given BTS/stream */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 259 | function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 260 | runs on test_CT { |
| 261 | IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx)); |
| 262 | } |
| 263 | |
| 264 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 265 | /* verify we get a CHAN_ACT after CHAN RQD */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 266 | testcase TC_chan_act_noreply() runs on test_CT { |
| 267 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 268 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 269 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 270 | f_bssap_reset(); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 271 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 272 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
| 273 | f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 274 | setverdict(pass); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 275 | } |
| 276 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 277 | /* verify if the "chreq:total" counter increments as expected */ |
| 278 | testcase TC_chan_act_counter() runs on test_CT { |
| 279 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 280 | var integer chreq_total; |
| 281 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 282 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 283 | f_bssap_reset(); |
| 284 | |
| 285 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 286 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
| 287 | f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 288 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1); |
| 289 | |
| 290 | setverdict(pass); |
| 291 | } |
| 292 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 293 | /* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */ |
| 294 | testcase TC_chan_act_ack_noest() runs on test_CT { |
| 295 | var RSL_Message rx_rsl; |
| 296 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 297 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 298 | f_bssap_reset(); |
| 299 | |
| 300 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 301 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 302 | |
| 303 | /* expect BSC to disable the channel again if there's no RLL EST IND */ |
| 304 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 305 | |
| 306 | setverdict(pass); |
| 307 | } |
| 308 | |
| 309 | /* Test behavior if MSC never answers to CR */ |
| 310 | testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT { |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 311 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 312 | var IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 313 | var RSL_Message rx_rsl; |
Harald Welte | f77aef6 | 2018-01-28 15:35:42 +0100 | [diff] [blame] | 314 | var ASP_RSL_Unitdata rx_rsl_ud; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 315 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 316 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 317 | f_bssap_reset(); |
| 318 | |
| 319 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 320 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 321 | |
| 322 | var octetstring l3 := '00010203040506'O |
| 323 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 324 | |
| 325 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))); |
| 326 | |
| 327 | /* 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] | 328 | /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */ |
| 329 | IPA_RSL[0].clear; |
| 330 | alt { |
| 331 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) -> value rx_rsl_ud { } |
| 332 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(sid, tr_RSL_REL_REQ(chan_nr, ?))) -> value rx_rsl_ud { |
| 333 | f_ipa_tx(0, ts_RSL_REL_CONF(chan_nr, main_dcch)); |
| 334 | repeat; |
| 335 | } |
| 336 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 337 | |
| 338 | setverdict(pass); |
| 339 | } |
| 340 | |
| 341 | /* Test behavior if MSC answers with CREF to CR */ |
| 342 | testcase TC_chan_act_ack_est_ind_refused() runs on test_CT { |
| 343 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 344 | var RSL_Message rx_rsl; |
| 345 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 346 | f_init(1); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 347 | f_bssap_reset(); |
| 348 | |
| 349 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 350 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 351 | |
| 352 | var octetstring l3 := '00010203040506'O |
| 353 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 354 | |
| 355 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 356 | BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0)); |
| 357 | |
| 358 | /* expect BSC to disable the channel */ |
Harald Welte | 725844b | 2018-01-28 16:18:32 +0100 | [diff] [blame] | 359 | f_expect_chan_rel(0, chan_nr); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 360 | setverdict(pass); |
| 361 | } |
| 362 | |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 363 | /* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */ |
| 364 | testcase TC_chan_act_nack() runs on test_CT { |
| 365 | var RSL_Message rx_rsl; |
| 366 | var integer chact_nack; |
| 367 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 368 | f_init(1); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 369 | f_bssap_reset(); |
| 370 | |
| 371 | chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack"); |
| 372 | |
| 373 | f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33)); |
| 374 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 375 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 376 | |
| 377 | f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL)); |
| 378 | |
| 379 | /* wait for some time to hope the NACK arrives before the CTRL GET below */ |
| 380 | f_sleep(0.5); |
| 381 | |
| 382 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1); |
| 383 | |
| 384 | setverdict(pass); |
| 385 | } |
| 386 | |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 387 | /* Test for channel exhaustion due to RACH overload */ |
| 388 | testcase TC_chan_exhaustion() runs on test_CT { |
| 389 | var ASP_RSL_Unitdata rsl_ud; |
| 390 | var integer i; |
| 391 | var integer chreq_total, chreq_nochan; |
| 392 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 393 | f_init(1); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 394 | f_bssap_reset(); |
| 395 | |
| 396 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 397 | chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel"); |
| 398 | |
| 399 | /* expect 5xTCH/F to succeed */ |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 400 | 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] | 401 | f_chreq_act_ack('23'O, i); |
| 402 | } |
| 403 | |
| 404 | IPA_RSL[0].clear; |
| 405 | |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 406 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
| 407 | chreq_total+NUM_TCHF_PER_BTS+NUM_SDCCH_PER_BTS); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 408 | |
| 409 | /* now expect additional channel activations to fail */ |
| 410 | f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42)); |
| 411 | |
| 412 | alt { |
| 413 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 414 | tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) { |
| 415 | setverdict(fail, "Received CHAN ACT ACK without resources?!?"); |
| 416 | } |
| 417 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud { |
| 418 | var GsmRrMessage rr; |
| 419 | /* match on IMM ASS REJ */ |
| 420 | rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload); |
| 421 | if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) { |
| 422 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", |
Harald Welte | dd8cbf3 | 2018-01-28 12:07:52 +0100 | [diff] [blame] | 423 | chreq_total+NUM_TCHF_PER_BTS+NUM_SDCCH_PER_BTS+1); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 424 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel", |
| 425 | chreq_nochan+1); |
| 426 | setverdict(pass); |
| 427 | } else { |
| 428 | repeat; |
| 429 | } |
| 430 | } |
| 431 | [] IPA_RSL[0].receive { repeat; } |
| 432 | } |
| 433 | } |
| 434 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 435 | /*********************************************************************** |
| 436 | * Assignment Testing |
| 437 | ***********************************************************************/ |
| 438 | |
| 439 | /* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction) */ |
| 440 | testcase TC_outbound_connect() runs on test_CT { |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 441 | f_init(1); |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 442 | f_bssap_reset(); |
| 443 | |
| 444 | BSSAP.send(ts_BSSAP_CONNECT_req(g_sccp_addr_peer, g_sccp_addr_own, 2342, ts_BSSMAP_AssignmentReq)); |
| 445 | BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?)); |
| 446 | setverdict(pass); |
| 447 | } |
| 448 | |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 449 | /* Test behavior if MSC answers with CREF to CR */ |
| 450 | testcase TC_assignment_cic_only() runs on test_CT { |
| 451 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 452 | var RSL_Message rx_rsl; |
| 453 | var DchanTuple dt; |
| 454 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 455 | f_init(1); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 456 | f_bssap_reset(); |
| 457 | |
| 458 | dt := f_est_dchan('23'O, 23, '00000000'O); |
| 459 | /* send assignment without AoIP IEs */ |
Harald Welte | cc7e4dc | 2017-12-14 21:55:10 +0100 | [diff] [blame] | 460 | 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] | 461 | alt { |
| 462 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 463 | setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE"); |
| 464 | } |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 465 | /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */ |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 466 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 467 | setverdict(pass); |
| 468 | } |
| 469 | [] BSSAP.receive { repeat; } |
| 470 | } |
| 471 | } |
| 472 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 473 | /* Run everything required up to sending a caller-specified assignment command and expect response */ |
| 474 | function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text) |
| 475 | runs on test_CT { |
| 476 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 477 | var RSL_Message rx_rsl; |
| 478 | var DchanTuple dt; |
| 479 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 480 | f_init(1); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 481 | f_bssap_reset(); |
| 482 | |
| 483 | dt := f_est_dchan('23'O, 23, '00000000'O); |
| 484 | /* send assignment without AoIP IEs */ |
| 485 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd)); |
| 486 | alt { |
| 487 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) { |
| 488 | if (ischosen(exp.pdu.bssmap.assignmentComplete)) { |
| 489 | setverdict(pass); |
| 490 | } else { |
| 491 | setverdict(fail, fail_text); |
| 492 | } |
| 493 | } |
| 494 | [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) { |
| 495 | if (ischosen(exp.pdu.bssmap.assignmentFailure)) { |
| 496 | setverdict(pass); |
| 497 | } else { |
| 498 | setverdict(fail, fail_text); |
| 499 | } |
| 500 | } |
| 501 | [] BSSAP.receive { repeat; } |
| 502 | } |
| 503 | } |
| 504 | testcase TC_assignment_csd() runs on test_CT { |
| 505 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 506 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 507 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 508 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD); |
| 509 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 510 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD"); |
| 511 | } |
| 512 | |
| 513 | testcase TC_assignment_ctm() runs on test_CT { |
| 514 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 515 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 516 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 517 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM); |
| 518 | //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7); |
| 519 | f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM"); |
| 520 | } |
| 521 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 522 | type record DchanTuple { |
| 523 | integer sccp_conn_id, |
| 524 | RslChannelNr rsl_chan_nr |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 525 | } |
| 526 | |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 527 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 528 | private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23) |
| 529 | runs on test_CT return RslChannelNr { |
| 530 | var RSL_Message rx_rsl; |
| 531 | f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn)); |
| 532 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 533 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 534 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10)); |
| 535 | return chan_nr; |
| 536 | } |
| 537 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 538 | /* helper function to establish a dedicated channel via BTS and MSC */ |
| 539 | function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3) |
| 540 | runs on test_CT return DchanTuple { |
| 541 | var BSSAP_N_CONNECT_ind rx_c_ind; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 542 | var DchanTuple dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 543 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 544 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
Harald Welte | d693965 | 2017-12-13 21:02:46 +0100 | [diff] [blame] | 545 | dt.rsl_chan_nr := f_chreq_act_ack(ra, fn); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 546 | |
| 547 | f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 548 | |
| 549 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 550 | dt.sccp_conn_id := rx_c_ind.connectionId; |
| 551 | BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id)); |
| 552 | |
| 553 | return dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 554 | } |
| 555 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 556 | /* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */ |
| 557 | testcase TC_chan_rel_rll_rel_ind() runs on test_CT { |
| 558 | var RSL_Message rx_rsl; |
| 559 | var DchanTuple dt; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 560 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 561 | f_init(1); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 562 | f_bssap_reset(); |
| 563 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 564 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 565 | |
| 566 | /* simulate RLL REL IND */ |
| 567 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 568 | |
| 569 | /* expect BSC to disable the channel */ |
| 570 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 571 | /* respond with CHAN REL ACK */ |
| 572 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 573 | |
| 574 | /* expect DISC_IND on MSC side */ |
| 575 | BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)); |
| 576 | |
| 577 | setverdict(pass); |
| 578 | } |
| 579 | |
| 580 | /* Test behavior of channel release after CONN FAIL IND from BTS */ |
| 581 | testcase TC_chan_rel_conn_fail() runs on test_CT { |
| 582 | var BSSAP_N_DATA_ind rx_di; |
| 583 | var RSL_Message rx_rsl; |
| 584 | var DchanTuple dt; |
| 585 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 586 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 587 | f_bssap_reset(); |
| 588 | |
| 589 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 590 | |
| 591 | /* simulate CONN FAIL IND */ |
Harald Welte | a8ed906 | 2017-12-14 09:46:01 +0100 | [diff] [blame] | 592 | 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] | 593 | /* TODO: different cause values? */ |
| 594 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 595 | /* expect Clear Request from BSC */ |
| 596 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 597 | |
| 598 | /* Instruct BSC to clear channel */ |
| 599 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 600 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 601 | |
Harald Welte | 6ff76ea | 2018-01-28 13:08:01 +0100 | [diff] [blame] | 602 | /* expect BSC to disable the channel */ |
| 603 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 604 | /* respond with CHAN REL ACK */ |
| 605 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 606 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 607 | /* expect Clear Complete from BSC */ |
| 608 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 609 | |
| 610 | /* release the SCCP connection */ |
| 611 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 612 | |
| 613 | /* wait for SCCP emulation to do its job */ |
| 614 | f_sleep(1.0); |
| 615 | |
| 616 | setverdict(pass); |
| 617 | } |
| 618 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 619 | function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr, boolean flush := true, |
| 620 | boolean handle_rll_rel := true) runs on test_CT { |
| 621 | |
| 622 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 623 | if (flush) { |
| 624 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 625 | IPA_RSL[bts_nr].clear; |
| 626 | } |
| 627 | alt { |
| 628 | /* ignore DEACTIVATE SACCH (if any) */ |
| 629 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 630 | tr_RSL_DEACT_SACCH(rsl_chan_nr))) { |
| 631 | repeat; |
| 632 | } |
| 633 | /* acknowledge RLL release (if any)*/ |
| 634 | [handle_rll_rel] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 635 | tr_RSL_REL_REQ(rsl_chan_nr, ?))) { |
| 636 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
| 637 | f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch)); |
| 638 | repeat; |
| 639 | } |
| 640 | /* Expect RF channel release from BSC on Abis */ |
| 641 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 642 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 643 | /* respond with CHAN REL ACK */ |
| 644 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr)); |
| 645 | } |
| 646 | /* ignore any user data */ |
| 647 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) { |
| 648 | repeat; |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 653 | /* Test behavior of channel release after hard Clear Command from MSC */ |
| 654 | testcase TC_chan_rel_hard_clear() runs on test_CT { |
| 655 | var BSSAP_N_DATA_ind rx_di; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 656 | var DchanTuple dt; |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 657 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 658 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 659 | f_bssap_reset(); |
| 660 | |
| 661 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 662 | |
| 663 | /* Instruct BSC to clear channel */ |
| 664 | var BssmapCause cause := 0; |
| 665 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 666 | |
| 667 | /* expect Clear Complete from BSC on A */ |
| 668 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) { |
| 669 | /* release the SCCP connection */ |
| 670 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 671 | } |
| 672 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 673 | f_expect_chan_rel(0, dt.rsl_chan_nr); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 674 | setverdict(pass); |
| 675 | } |
| 676 | |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 677 | /* Test behavior of channel release after hard RLSD from MSC */ |
| 678 | testcase TC_chan_rel_hard_rlsd() runs on test_CT { |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 679 | var DchanTuple dt; |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 680 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 681 | f_init(1); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 682 | f_bssap_reset(); |
| 683 | |
| 684 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 685 | |
| 686 | /* release the SCCP connection */ |
| 687 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 688 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 689 | f_expect_chan_rel(0, dt.rsl_chan_nr); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 690 | setverdict(pass); |
| 691 | } |
| 692 | |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 693 | /* Test behavior of channel release after BSSMAP RESET from MSC */ |
| 694 | testcase TC_chan_rel_a_reset() runs on test_CT { |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 695 | var DchanTuple dt; |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 696 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 697 | f_init(1); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 698 | f_bssap_reset(); |
| 699 | |
| 700 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 701 | |
| 702 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 703 | IPA_RSL[0].clear; |
| 704 | |
| 705 | /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */ |
| 706 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, ts_BSSMAP_Reset(0))); |
| 707 | interleave { |
| 708 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_sccp_addr_own, g_sccp_addr_peer, tr_BSSMAP_ResetAck)) { } |
| 709 | [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { } |
| 710 | } |
| 711 | |
Harald Welte | 91d54a5 | 2018-01-28 15:35:07 +0100 | [diff] [blame] | 712 | f_expect_chan_rel(0, dt.rsl_chan_nr); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 713 | setverdict(pass); |
| 714 | } |
| 715 | |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 716 | /* Test behavior if RSL EST IND for non-active channel */ |
| 717 | testcase TC_rll_est_ind_inact_lchan() runs on test_CT { |
| 718 | timer T := 2.0; |
| 719 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 720 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 721 | f_bssap_reset(); |
| 722 | |
| 723 | var octetstring l3 := '00010203040506'O; |
| 724 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6)); |
| 725 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 726 | |
| 727 | T.start; |
| 728 | alt { |
| 729 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 730 | setverdict(fail, "MSC received COMPL L3 for non-active lchan"); |
| 731 | } |
| 732 | [] BSSAP.receive {} |
| 733 | [] IPA_RSL[0].receive {} |
| 734 | [] T.timeout {} |
| 735 | } |
| 736 | |
| 737 | setverdict(pass); |
| 738 | } |
| 739 | |
| 740 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 741 | testcase TC_rll_est_ind_inval_sapi1() runs on test_CT { |
| 742 | var RslChannelNr chan_nr; |
| 743 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 744 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 745 | f_bssap_reset(); |
| 746 | |
| 747 | chan_nr := f_chreq_act_ack() |
| 748 | |
| 749 | var octetstring l3 := '00010203040506'O; |
| 750 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3)); |
| 751 | |
| 752 | timer T := 2.0; |
| 753 | T.start; |
| 754 | alt { |
| 755 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 756 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1"); |
| 757 | } |
| 758 | [] BSSAP.receive { repeat; } |
| 759 | [] IPA_RSL[0].receive { repeat; } |
| 760 | [] T.timeout {} |
| 761 | } |
| 762 | |
| 763 | setverdict(pass); |
| 764 | } |
| 765 | |
| 766 | /* Test behavior if RSL EST IND for invalid SAPI */ |
| 767 | testcase TC_rll_est_ind_inval_sapi3() runs on test_CT { |
| 768 | timer T := 2.0; |
| 769 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 770 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 771 | f_bssap_reset(); |
| 772 | |
| 773 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 774 | |
| 775 | var octetstring l3 := '00010203040506'O; |
| 776 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3)); |
| 777 | |
| 778 | T.start; |
| 779 | alt { |
| 780 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 781 | setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3"); |
| 782 | } |
| 783 | [] BSSAP.receive { repeat; } |
| 784 | [] IPA_RSL[0].receive { repeat; } |
| 785 | [] T.timeout {} |
| 786 | } |
| 787 | |
| 788 | setverdict(pass); |
| 789 | } |
| 790 | |
| 791 | /* Test behavior if RSL EST IND for invalid SACCH */ |
| 792 | testcase TC_rll_est_ind_inval_sacch() runs on test_CT { |
| 793 | timer T := 2.0; |
| 794 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 795 | f_init(1); |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 796 | f_bssap_reset(); |
| 797 | |
| 798 | var RslChannelNr chan_nr := f_chreq_act_ack(); |
| 799 | |
| 800 | var octetstring l3 := '00010203040506'O; |
| 801 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3)); |
| 802 | |
| 803 | T.start; |
| 804 | alt { |
| 805 | [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) { |
| 806 | setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH"); |
| 807 | } |
| 808 | [] BSSAP.receive { repeat; } |
| 809 | [] IPA_RSL[0].receive { repeat; } |
| 810 | [] T.timeout {} |
| 811 | } |
| 812 | |
| 813 | setverdict(pass); |
| 814 | } |
| 815 | |
| 816 | |
| 817 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 818 | |
| 819 | testcase TC_ctrl_msc_connection_status() runs on test_CT { |
| 820 | var charstring ctrl_resp; |
| 821 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 822 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 823 | f_bssap_reset(); |
| 824 | |
| 825 | /* See https://osmocom.org/issues/2729 */ |
| 826 | f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected"); |
| 827 | setverdict(pass); |
| 828 | } |
| 829 | |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 830 | testcase TC_ctrl_msc0_connection_status() runs on test_CT { |
| 831 | var charstring ctrl_resp; |
| 832 | |
| 833 | f_init(1); |
| 834 | f_bssap_reset(); |
| 835 | |
| 836 | f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected"); |
| 837 | setverdict(pass); |
| 838 | } |
| 839 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 840 | testcase TC_ctrl() runs on test_CT { |
| 841 | var charstring ctrl_resp; |
| 842 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 843 | f_init(1); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 844 | f_bssap_reset(); |
| 845 | |
| 846 | /* all below values must match the osmo-bsc.cfg config file used */ |
| 847 | |
| 848 | f_ctrl_get_exp(IPA_CTRL, "mcc", "1"); |
| 849 | f_ctrl_get_exp(IPA_CTRL, "mnc", "1"); |
Harald Welte | 44bdaa5 | 2017-12-17 17:01:47 +0100 | [diff] [blame] | 850 | f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "3"); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 851 | |
| 852 | var integer bts_nr := 0; |
| 853 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1"); |
| 854 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0"); |
| 855 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected"); |
| 856 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs"); |
| 857 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on"); |
| 858 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871"); |
| 859 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20"); |
| 860 | |
| 861 | var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")); |
| 862 | f_sleep(2.0); |
| 863 | if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) { |
| 864 | setverdict(fail, "oml-uptime not incrementing as expected"); |
| 865 | } |
| 866 | /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */ |
| 867 | |
| 868 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0); |
| 869 | |
| 870 | setverdict(pass); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 871 | } |
| 872 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 873 | function f_bssap_tx_ud(template PDU_BSSAP bssap) runs on test_CT { |
| 874 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, bssap)); |
| 875 | } |
| 876 | |
| 877 | |
| 878 | /*********************************************************************** |
| 879 | * Paging Testing |
| 880 | ***********************************************************************/ |
| 881 | |
| 882 | type record Cell_Identity { |
| 883 | GsmMcc mcc, |
| 884 | GsmMnc mnc, |
| 885 | GsmLac lac, |
| 886 | GsmCellId ci |
| 887 | }; |
| 888 | private const Cell_Identity cid := { '001'H, '001'H, 1, 0 }; |
| 889 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 890 | type set of integer BtsIdList; |
| 891 | |
| 892 | private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean { |
| 893 | for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) { |
| 894 | if (bts_id == bts_ids[j]) { |
| 895 | return true; |
| 896 | } |
| 897 | } |
| 898 | return false; |
| 899 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 900 | |
| 901 | /* core paging test helper function; used by most paging test cases */ |
| 902 | private function f_pageing_helper(hexstring imsi, |
| 903 | template BSSMAP_FIELD_CellIdentificationList cid_list, |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 904 | BtsIdList bts_ids := { 0 }, |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 905 | template RSL_ChanNeeded rsl_chneed := omit, |
| 906 | template OCT4 tmsi := omit) runs on test_CT |
| 907 | { |
| 908 | var template BSSMAP_IE_ChannelNeeded bssmap_chneed; |
| 909 | var MobileIdentity mi; |
| 910 | var template octetstring id_enc; /* FIXME */ |
| 911 | var RSL_Message rx_rsl; |
| 912 | var integer paging_group := hex2int(imsi[lengthof(imsi)-1]); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 913 | var integer i; |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 914 | |
| 915 | f_init(); |
| 916 | f_bssap_reset(); |
| 917 | |
| 918 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 919 | for (i := 0; i < sizeof(bts_ids); i := i + 1) { |
| 920 | IPA_RSL[bts_ids[i]].clear; |
| 921 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 922 | |
| 923 | if (isvalue(rsl_chneed)) { |
| 924 | /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */ |
| 925 | bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2)); |
| 926 | } else { |
| 927 | bssmap_chneed := omit; |
| 928 | } |
| 929 | |
| 930 | f_bssap_tx_ud(ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)); |
| 931 | |
| 932 | /* FIXME: Disabled due to bugs in both GSM_RR_Types and MobileL3_CommonIE_Types IMSI encoder |
| 933 | if (isvalue(tmsi)) { |
| 934 | mi := valueof(t_Osmo_MI_TMSI(oct2int(valueof(tmsi)))); |
| 935 | } else { |
| 936 | mi := valueof(ts_Osmo_MI_IMSI(imsi)); |
| 937 | } |
| 938 | id_enc := enc_MobileIdentity(mi); |
| 939 | */ |
| 940 | id_enc := ?; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 941 | for (i := 0; i < sizeof(bts_ids); i := i + 1) { |
| 942 | rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(id_enc)); |
| 943 | /* check channel type, paging group */ |
| 944 | if (rx_rsl.ies[1].body.paging_group != paging_group) { |
| 945 | setverdict(fail, "Paging for wrong paging group"); |
| 946 | } |
| 947 | if (ispresent(rsl_chneed) and |
| 948 | rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) { |
| 949 | setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed"); |
| 950 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 951 | } |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 952 | /* do a quick check on all not-included BTSs if they received paging */ |
| 953 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 954 | timer T := 0.1; |
| 955 | if (f_bts_in_list(i, bts_ids)) { |
| 956 | continue; |
| 957 | } |
| 958 | T.start; |
| 959 | alt { |
| 960 | [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(id_enc))) { |
| 961 | setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids); |
| 962 | } |
| 963 | [] IPA_RSL[i].receive { repeat; } |
| 964 | [] T.timeout { } |
| 965 | } |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | setverdict(pass); |
| 969 | } |
| 970 | |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 971 | const BtsIdList c_BtsId_all := { 0, 1, 2 }; |
| 972 | const BtsIdList c_BtsId_LAC1 := { 0, 1 }; |
| 973 | const BtsIdList c_BtsId_LAC2 := { 2 }; |
| 974 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 975 | /* PAGING by IMSI + TMSI */ |
| 976 | testcase TC_paging_imsi_nochan() runs on test_CT { |
| 977 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 978 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5cfa867 | 2018-01-28 18:28:25 +0100 | [diff] [blame] | 979 | var integer i; |
| 980 | |
| 981 | f_init(); |
| 982 | f_bssap_reset(); |
| 983 | |
| 984 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
| 985 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 986 | IPA_RSL[i].clear; |
| 987 | } |
| 988 | |
| 989 | f_bssap_tx_ud(ts_BSSMAP_Paging('001010123456789'H, cid_list, omit, omit)); |
| 990 | |
| 991 | /* wait for some time until when paging messages would appear */ |
| 992 | f_sleep(3.0); |
| 993 | |
| 994 | for (i := 0; i < NUM_BTS; i := i + 1) { |
| 995 | timer T := 0.01; |
| 996 | T.start; |
| 997 | alt { |
| 998 | [] IPA_RSL[i].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 999 | setverdict(fail, "Received unexpected paging"); |
| 1000 | } |
| 1001 | [] T.timeout {} |
| 1002 | } |
| 1003 | } |
| 1004 | setverdict(pass); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | /* PAGING by IMSI + TMSI */ |
| 1008 | testcase TC_paging_tmsi_nochan() runs on test_CT { |
| 1009 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1010 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1011 | f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | /* Paging with different "channel needed' values */ |
| 1015 | testcase TC_paging_tmsi_any() runs on test_CT { |
| 1016 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1017 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1018 | f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1019 | } |
| 1020 | testcase TC_paging_tmsi_sdcch() runs on test_CT { |
| 1021 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1022 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1023 | f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1024 | } |
| 1025 | testcase TC_paging_tmsi_tch_f() runs on test_CT { |
| 1026 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1027 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1028 | f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1029 | } |
| 1030 | testcase TC_paging_tmsi_tch_hf() runs on test_CT { |
| 1031 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1032 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1033 | f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | /* Paging by CGI */ |
| 1037 | testcase TC_paging_imsi_nochan_cgi() runs on test_CT { |
| 1038 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1039 | 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] | 1040 | f_pageing_helper('001010000000006'H, cid_list, { 0 }); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | /* Paging by LAC+CI */ |
| 1044 | testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT { |
| 1045 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1046 | 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] | 1047 | f_pageing_helper('001010000000007'H, cid_list, { 0 }); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | /* Paging by CI */ |
| 1051 | testcase TC_paging_imsi_nochan_ci() runs on test_CT { |
| 1052 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1053 | cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1054 | f_pageing_helper('001010000000008'H, cid_list, { 0 }); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | /* Paging by LAI */ |
| 1058 | testcase TC_paging_imsi_nochan_lai() runs on test_CT { |
| 1059 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1060 | 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] | 1061 | f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1062 | } |
| 1063 | |
| 1064 | /* Paging by LAC */ |
| 1065 | testcase TC_paging_imsi_nochan_lac() runs on test_CT { |
| 1066 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1067 | cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1068 | f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | /* Paging by "all in BSS" */ |
| 1072 | testcase TC_paging_imsi_nochan_all() runs on test_CT { |
| 1073 | var template BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1074 | cid_list := { cIl_allInBSS := ''O }; |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1075 | f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | /* Paging by PLMN+LAC+RNC */ |
| 1079 | /* Paging by RNC */ |
| 1080 | /* Paging by LAC+RNC */ |
| 1081 | |
| 1082 | /* Paging on multiple cells (multiple in one LAC): Verify all of them page */ |
| 1083 | /* Paging on multiple cells (multiple entries in list): Verify all of them page */ |
| 1084 | /* Verify paging retransmission interval + count */ |
| 1085 | /* Verify paging stops after channel establishment */ |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1086 | /* Test behavior under paging overload */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1087 | |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1088 | /* Verify PCH load */ |
| 1089 | testcase TC_paging_imsi_load() runs on test_CT { |
| 1090 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1091 | timer T := 4.0; |
| 1092 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1093 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1094 | |
| 1095 | /* tell BSC there is no paging space anymore */ |
| 1096 | f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0)); |
| 1097 | |
| 1098 | /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally, |
| 1099 | * there would be 8 retransmissions during 4 seconds */ |
| 1100 | T.start; |
| 1101 | alt { |
| 1102 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1103 | setverdict(fail, "Received PAGING after LOAD_IND(0)"); |
| 1104 | self.stop; |
| 1105 | } |
| 1106 | [] T.timeout { |
| 1107 | setverdict(pass); |
| 1108 | } |
| 1109 | } |
| 1110 | } |
| 1111 | |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1112 | /* Verify Paging Counter */ |
Harald Welte | 1ff6999 | 2017-12-14 12:31:17 +0100 | [diff] [blame] | 1113 | testcase TC_paging_counter() runs on test_CT { |
| 1114 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1115 | timer T := 4.0; |
| 1116 | var integer i; |
| 1117 | var integer paging_attempted_bsc; |
| 1118 | var integer paging_attempted_bts[NUM_BTS]; |
| 1119 | var integer paging_expired_bts[NUM_BTS]; |
| 1120 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
| 1121 | |
| 1122 | f_init(); |
| 1123 | |
| 1124 | /* read counters before paging */ |
| 1125 | paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted"); |
| 1126 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1127 | paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted"); |
| 1128 | paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired"); |
| 1129 | } |
| 1130 | |
| 1131 | f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all); |
| 1132 | |
| 1133 | /* expect the attempted pages on BSC and each BTSs to have incremented by one */ |
| 1134 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1); |
| 1135 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1136 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted", |
| 1137 | paging_attempted_bts[i]+1); |
| 1138 | } |
| 1139 | |
| 1140 | /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */ |
| 1141 | f_sleep(12.0); |
| 1142 | for (i := 0; i < NUM_BTS; i := i+1) { |
| 1143 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired", |
| 1144 | paging_expired_bts[i]+1); |
| 1145 | } |
| 1146 | setverdict(pass); |
| 1147 | |
| 1148 | } |
| 1149 | |
| 1150 | |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1151 | /* Verify paging stops after A-RESET */ |
| 1152 | testcase TC_paging_imsi_a_reset() runs on test_CT { |
| 1153 | var BSSMAP_FIELD_CellIdentificationList cid_list; |
| 1154 | timer T := 3.0; |
| 1155 | cid_list := valueof(ts_BSSMAP_CIL_noCell); |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1156 | f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1157 | |
| 1158 | /* Perform a BSSMAP Reset and wait for ACK */ |
| 1159 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, ts_BSSMAP_Reset(0))); |
| 1160 | alt { |
| 1161 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_sccp_addr_own, g_sccp_addr_peer, tr_BSSMAP_ResetAck)) { } |
| 1162 | [] BSSAP.receive { repeat; } |
| 1163 | } |
| 1164 | |
| 1165 | /* Clear the queue, it might still contain stuff like BCCH FILLING */ |
| 1166 | IPA_RSL[0].clear; |
| 1167 | |
| 1168 | /* Wait for 3 seconds if any more PAGING CMD are received on RSL */ |
| 1169 | T.start; |
| 1170 | alt { |
| 1171 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1172 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1173 | self.stop; |
| 1174 | } |
Harald Welte | 5d1a220 | 2017-12-13 19:51:29 +0100 | [diff] [blame] | 1175 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1176 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1177 | self.stop; |
| 1178 | } |
| 1179 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_PAGING_CMD(?))) { |
| 1180 | setverdict(fail, "Received PAGING after A-RESET"); |
| 1181 | self.stop; |
| 1182 | } |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1183 | [] T.timeout { |
| 1184 | setverdict(pass); |
| 1185 | } |
| 1186 | } |
| 1187 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1188 | |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1189 | /* Test RSL link drop causes counter increment */ |
| 1190 | testcase TC_rsl_drop_counter() runs on test_CT { |
| 1191 | var integer rsl_fail; |
| 1192 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1193 | f_init(1); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1194 | f_bssap_reset(); |
| 1195 | |
| 1196 | rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail"); |
| 1197 | |
| 1198 | bts[0].rsl.vc_IPA.stop; |
| 1199 | |
| 1200 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1); |
| 1201 | |
| 1202 | setverdict(pass); |
| 1203 | } |
| 1204 | |
| 1205 | /* TODO: Test OML link drop causes counter increment */ |
| 1206 | |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1207 | /*********************************************************************** |
| 1208 | * "New world" test cases using RSL_Emulation + BSSMAP_Emulation |
| 1209 | ***********************************************************************/ |
| 1210 | |
| 1211 | import from BSSMAP_Emulation all; |
| 1212 | import from RSL_Emulation all; |
| 1213 | import from MSC_ConnectionHandler all; |
| 1214 | |
| 1215 | type function void_fn(charstring id) runs on MSC_ConnHdlr; |
| 1216 | |
| 1217 | /* helper function to create, connect and start a MSC_ConnHdlr component */ |
| 1218 | function f_start_handler(void_fn fn, charstring id) runs on test_CT return MSC_ConnHdlr { |
| 1219 | var MSC_ConnHdlr vc_conn; |
| 1220 | |
| 1221 | vc_conn := MSC_ConnHdlr.create(id); |
| 1222 | connect(vc_conn:BSSMAPEM, vc_BSSMAP:PROC); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1223 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1224 | connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT); |
Harald Welte | f70df65 | 2018-01-29 22:00:23 +0100 | [diff] [blame] | 1225 | connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1226 | connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT); |
Daniel Willmann | 191e0d9 | 2018-01-17 12:44:35 +0100 | [diff] [blame] | 1227 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1228 | vc_conn.start(derefers(fn)(id)); |
| 1229 | return vc_conn; |
| 1230 | } |
| 1231 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1232 | private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr { |
| 1233 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1234 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1235 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1236 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1237 | const OCT8 kc := '0001020304050607'O; |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1238 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1239 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1240 | 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] | 1241 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1242 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1243 | f_cipher_mode('01'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | testcase TC_assignment_fr_a5_0() runs on test_CT { |
| 1247 | var MSC_ConnHdlr vc_conn; |
| 1248 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1249 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1250 | f_sleep(1.0); |
| 1251 | |
| 1252 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_0), testcasename()); |
| 1253 | vc_conn.done; |
| 1254 | } |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | 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] | 1259 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1260 | |
| 1261 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1262 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1263 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1264 | const OCT8 kc := '0001020304050607'O; |
| 1265 | |
| 1266 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1267 | 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] | 1268 | |
| 1269 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1270 | f_cipher_mode('02'O, kc); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1271 | } |
| 1272 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1273 | testcase TC_assignment_fr_a5_1() runs on test_CT { |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1274 | var MSC_ConnHdlr vc_conn; |
| 1275 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1276 | f_init(1, true); |
Harald Welte | c1a2fff | 2017-12-17 11:06:19 +0100 | [diff] [blame] | 1277 | f_sleep(1.0); |
| 1278 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1279 | 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] | 1280 | vc_conn.done; |
| 1281 | } |
| 1282 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1283 | /* Expect ASSIGNMENT FAIL if mandatory IE is missing */ |
| 1284 | private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr { |
| 1285 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1286 | var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail; |
| 1287 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1288 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1289 | const OCT8 kc := '0001020304050607'O; |
| 1290 | |
| 1291 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1292 | f_establish_fully(pars, ass_cmd, exp_fail); |
| 1293 | } |
| 1294 | |
| 1295 | testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT { |
| 1296 | var MSC_ConnHdlr vc_conn; |
| 1297 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1298 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1299 | f_sleep(1.0); |
| 1300 | |
| 1301 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing), testcasename()); |
| 1302 | vc_conn.done; |
| 1303 | } |
| 1304 | |
| 1305 | |
| 1306 | private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr { |
| 1307 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1308 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
| 1309 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1310 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1311 | const OCT8 kc := '0001020304050607'O; |
| 1312 | |
| 1313 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1314 | 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] | 1315 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1316 | f_establish_fully(pars, ass_cmd, exp_compl); |
Harald Welte | 73cd271 | 2017-12-17 00:44:52 +0100 | [diff] [blame] | 1317 | f_cipher_mode('08'O, kc); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | testcase TC_assignment_fr_a5_3() runs on test_CT { |
| 1321 | var MSC_ConnHdlr vc_conn; |
| 1322 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1323 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1324 | f_sleep(1.0); |
| 1325 | |
| 1326 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_3), testcasename()); |
| 1327 | vc_conn.done; |
| 1328 | } |
| 1329 | |
| 1330 | |
| 1331 | private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr { |
| 1332 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
Harald Welte | 38b2a10 | 2017-12-23 02:42:58 +0100 | [diff] [blame] | 1333 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1334 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 1335 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla)); |
| 1336 | const OCT8 kc := '0001020304050607'O; |
| 1337 | const OCT16 kc128 := kc & kc; |
| 1338 | |
| 1339 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType); |
| 1340 | 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] | 1341 | f_establish_fully(pars, ass_cmd, exp_compl); |
| 1342 | f_cipher_mode('10'O, kc, kc128, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1343 | /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */ |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | testcase TC_assignment_fr_a5_4() runs on test_CT { |
| 1347 | var MSC_ConnHdlr vc_conn; |
| 1348 | |
Harald Welte | 89d42e8 | 2017-12-17 16:42:41 +0100 | [diff] [blame] | 1349 | f_init(1, true); |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1350 | f_sleep(1.0); |
| 1351 | |
| 1352 | vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4), testcasename()); |
| 1353 | vc_conn.done; |
| 1354 | } |
| 1355 | |
| 1356 | |
Harald Welte | 4532e0a | 2017-12-23 02:05:44 +0100 | [diff] [blame] | 1357 | private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr { |
| 1358 | var TestHdlrParams pars := valueof(t_def_TestHdlrPars); |
| 1359 | var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit); |
| 1360 | var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, omit)); |
| 1361 | |
| 1362 | ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL); |
| 1363 | f_establish_fully(pars, ass_cmd, exp_compl); |
| 1364 | } |
| 1365 | |
| 1366 | testcase TC_assignment_sign() runs on test_CT { |
| 1367 | var MSC_ConnHdlr vc_conn; |
| 1368 | |
| 1369 | f_init(1, true); |
| 1370 | f_sleep(1.0); |
| 1371 | |
| 1372 | vc_conn := f_start_handler(refers(f_tc_assignment_sign), testcasename()); |
| 1373 | vc_conn.done; |
| 1374 | } |
| 1375 | |
Harald Welte | 552620d | 2017-12-16 23:21:36 +0100 | [diff] [blame] | 1376 | |
| 1377 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1378 | control { |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1379 | execute( TC_ctrl_msc_connection_status() ); |
Stefan Sperling | b041b3d | 2018-01-03 17:14:55 +0100 | [diff] [blame] | 1380 | execute( TC_ctrl_msc0_connection_status() ); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 1381 | execute( TC_ctrl() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1382 | execute( TC_chan_act_noreply() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1383 | execute( TC_chan_act_counter() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 1384 | execute( TC_chan_act_ack_noest() ); |
| 1385 | execute( TC_chan_act_ack_est_ind_noreply() ); |
| 1386 | execute( TC_chan_act_ack_est_ind_refused() ); |
Harald Welte | 618ef64 | 2017-12-14 14:58:20 +0100 | [diff] [blame] | 1387 | execute( TC_chan_act_nack() ); |
Harald Welte | 799c97b | 2017-12-14 17:50:30 +0100 | [diff] [blame] | 1388 | execute( TC_chan_exhaustion() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 1389 | execute( TC_chan_rel_rll_rel_ind() ); |
| 1390 | execute( TC_chan_rel_conn_fail() ); |
| 1391 | execute( TC_chan_rel_hard_clear() ); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 1392 | execute( TC_chan_rel_hard_rlsd() ); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 1393 | execute( TC_chan_rel_a_reset() ); |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1394 | |
Harald Welte | cfe2c96 | 2017-12-15 12:09:32 +0100 | [diff] [blame] | 1395 | execute( TC_outbound_connect() ); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 1396 | execute( TC_assignment_cic_only() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1397 | execute( TC_assignment_csd() ); |
| 1398 | execute( TC_assignment_ctm() ); |
| 1399 | execute( TC_assignment_sign() ); |
| 1400 | execute( TC_assignment_fr_a5_0() ); |
| 1401 | execute( TC_assignment_fr_a5_1() ); |
Harald Welte | f1b64e2 | 2017-12-15 14:55:14 +0100 | [diff] [blame] | 1402 | execute( TC_assignment_fr_a5_1_codec_missing() ); |
Harald Welte | 235ebf1 | 2017-12-15 14:18:16 +0100 | [diff] [blame] | 1403 | execute( TC_assignment_fr_a5_3() ); |
| 1404 | execute( TC_assignment_fr_a5_4() ); |
Harald Welte | 16a4adf | 2017-12-14 18:54:01 +0100 | [diff] [blame] | 1405 | |
Harald Welte | 5cd20ed | 2017-12-13 21:03:20 +0100 | [diff] [blame] | 1406 | execute( TC_rll_est_ind_inact_lchan() ); |
| 1407 | execute( TC_rll_est_ind_inval_sapi1() ); |
| 1408 | execute( TC_rll_est_ind_inval_sapi3() ); |
| 1409 | execute( TC_rll_est_ind_inval_sacch() ); |
| 1410 | |
Harald Welte | 6f521d8 | 2017-12-11 19:52:02 +0100 | [diff] [blame] | 1411 | execute( TC_paging_imsi_nochan() ); |
| 1412 | execute( TC_paging_tmsi_nochan() ); |
| 1413 | execute( TC_paging_tmsi_any() ); |
| 1414 | execute( TC_paging_tmsi_sdcch() ); |
| 1415 | execute( TC_paging_tmsi_tch_f() ); |
| 1416 | execute( TC_paging_tmsi_tch_hf() ); |
| 1417 | execute( TC_paging_imsi_nochan_cgi() ); |
| 1418 | execute( TC_paging_imsi_nochan_lac_ci() ); |
| 1419 | execute( TC_paging_imsi_nochan_ci() ); |
| 1420 | execute( TC_paging_imsi_nochan_lai() ); |
| 1421 | execute( TC_paging_imsi_nochan_lac() ); |
| 1422 | execute( TC_paging_imsi_nochan_all() ); |
Harald Welte | 1098500 | 2017-12-12 09:29:15 +0100 | [diff] [blame] | 1423 | execute( TC_paging_imsi_a_reset() ); |
Harald Welte | e65d40e | 2017-12-13 00:09:06 +0100 | [diff] [blame] | 1424 | execute( TC_paging_imsi_load() ); |
Harald Welte | 4e9b9cc | 2017-12-14 18:31:02 +0100 | [diff] [blame] | 1425 | |
| 1426 | execute( TC_rsl_drop_counter() ); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1427 | } |
| 1428 | |
| 1429 | } |