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