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