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