Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 3 | /* Integration Tests for OsmoBTS |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 4 | * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 5 | * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 13 | * This test suite tests OsmoBTS by attaching to the external interfaces |
| 14 | * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation |
| 15 | * using the L1CTL protocol/interface. |
| 16 | * |
| 17 | * You can run the tests with |
| 18 | * a) osmo-bts-trx + trxcon + fake_trx (without any hardware) |
| 19 | * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware) |
| 20 | * c) osmo-bts-virtual + virt_phy (without any hardware) |
| 21 | * |
| 22 | * Some of the tests will only run on a subset of those three configurations |
| 23 | * due to limitations in the respective L1. |
| 24 | */ |
| 25 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 26 | import from Misc_Helpers all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 27 | import from General_Types all; |
| 28 | import from GSM_Types all; |
| 29 | import from GSM_RR_Types all; |
| 30 | import from Osmocom_Types all; |
| 31 | import from GSM_Types all; |
Vadim Yanitskiy | 5d2cf44 | 2020-05-02 16:49:17 +0700 | [diff] [blame] | 32 | import from GSM_RestOctets all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 33 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 34 | import from L1CTL_PortType all; |
| 35 | import from L1CTL_Types all; |
| 36 | import from LAPDm_Types all; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 37 | import from LAPDm_RAW_PT all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 38 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 39 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 40 | |
| 41 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 42 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 43 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 44 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 45 | import from RSL_Emulation all; |
| 46 | |
| 47 | import from IPL4asp_Types all; |
| 48 | import from TRXC_Types all; |
| 49 | import from TRXC_CodecPort all; |
| 50 | import from TRXC_CodecPort_CtrlFunct all; |
| 51 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 52 | import from PCUIF_Types all; |
| 53 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 54 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 55 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 56 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 57 | import from MobileL3_RRM_Types all; |
| 58 | import from MobileL3_Types all; |
| 59 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 60 | import from L3_Common all; |
| 61 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 62 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 63 | import from Osmocom_VTY_Functions all; |
| 64 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 65 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 66 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 67 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 68 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 69 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 70 | friend module BTS_Tests_perf; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 71 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 72 | /* The tests assume a BTS with the following timeslot configuration: |
| 73 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 74 | * TS1 : TCH/F |
| 75 | * TS2 : TCH/F |
| 76 | * TS3 : TCH/F_PDCH (IPA Style) |
| 77 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 78 | * TS5 : TCH/H |
| 79 | * TS6 : SDCCH/8 |
| 80 | * TS7 : PDCH |
| 81 | */ |
| 82 | |
| 83 | modulepar { |
| 84 | charstring mp_rsl_ip := "127.0.0.2"; |
| 85 | integer mp_rsl_port := 3003; |
| 86 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 87 | integer mp_trx1_arfcn := 873; |
| 88 | integer mp_trx2_arfcn := 875; |
| 89 | integer mp_trx3_arfcn := 877; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 90 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 91 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 92 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 93 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 94 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 95 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 96 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 97 | integer mp_tolerance_rxqual := 1; |
| 98 | integer mp_tolerance_rxlev := 3; |
| 99 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 100 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 101 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 102 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 103 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 104 | integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */ |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 105 | integer mp_ms_actual_ta_exp := 0; |
| 106 | integer mp_timing_offset_256syms_exp := 512; |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 107 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 108 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 109 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 110 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 111 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 112 | /* how many transceivers do we expect to connect */ |
| 113 | integer mp_transceiver_num := 1; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 114 | } |
| 115 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 116 | type record of RslChannelNr ChannelNrs; |
| 117 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 118 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 119 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 120 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 121 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 122 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 123 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 124 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 125 | |
| 126 | /* L1CTL port (for classic tests) */ |
| 127 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 128 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 129 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 130 | port TRXC_CODEC_PT BTS_TRXC; |
| 131 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 132 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 133 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 134 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 135 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 136 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 137 | /* PCU Interface of BTS */ |
| 138 | port PCUIF_CODEC_PT PCU; |
| 139 | var integer g_pcu_conn_id; |
| 140 | /* Last PCU INFO IND we received */ |
| 141 | var PCUIF_Message g_pcu_last_info; |
| 142 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 143 | /* SI configuration */ |
| 144 | var SystemInformationConfig si_cfg := { |
| 145 | bcch_extended := false, |
| 146 | si1_present := false, |
| 147 | si2bis_present := false, |
| 148 | si2ter_present := false, |
| 149 | si2quater_present := false, |
| 150 | si7_present := false, |
| 151 | si8_present := false, |
| 152 | si9_present := false, |
| 153 | si13_present := false, |
| 154 | si13alt_present := false, |
| 155 | si15_present := false, |
| 156 | si16_present := false, |
| 157 | si17_present := false, |
| 158 | si2n_present := false, |
| 159 | si21_present := false, |
| 160 | si22_present := false |
| 161 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 162 | |
| 163 | /* all logical channels available on the BTS */ |
| 164 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 165 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 169 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 170 | port L1CTL_PT L1CTL; |
| 171 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 172 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 173 | port TRXC_CODEC_PT BTS_TRXC; |
| 174 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 175 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 176 | /* port to be initialized optionally to access BSC VTY */ |
| 177 | port TELNETasp_PT BSCVTY; |
| 178 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 179 | timer g_Tguard; |
| 180 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 181 | |
| 182 | var ConnHdlrPars g_pars; |
| 183 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 184 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 185 | |
| 186 | /* PCU Interface of BTS */ |
| 187 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 188 | } |
| 189 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 190 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 191 | var bitstring trx_mask := '00000000'B; |
| 192 | var integer trx_count := 0; |
| 193 | var RSLEm_Event ev; |
| 194 | timer T; |
| 195 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 196 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 197 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 198 | |
| 199 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 200 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 201 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 202 | |
| 203 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 204 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 205 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 206 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 207 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 208 | T.start(mp_ipa_up_timeout); |
| 209 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 210 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 211 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 212 | /* Make sure that all transceivers use unique stream ID */ |
| 213 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 214 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 215 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 216 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 217 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 218 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 219 | RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ev.sid)); |
| 220 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 221 | trx_count := trx_count + 1; |
| 222 | |
| 223 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
| 224 | if (trx_count < mp_transceiver_num) { repeat; } |
| 225 | } |
| 226 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 227 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 228 | [] T.timeout { |
| 229 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 230 | "Timeout waiting for RSL bring up"); |
| 231 | } |
| 232 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | type record ConnHdlrPars { |
| 236 | RslChannelNr chan_nr, |
| 237 | RSL_IE_ChannelMode chan_mode, |
| 238 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 239 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 240 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 241 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 242 | BtsBand bts0_band optional, |
| 243 | |
| 244 | /* Frequency hopping parameters (disabled if absent) */ |
| 245 | MaioHsn maio_hsn optional, |
| 246 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 247 | MobileAllocation ma_map, |
| 248 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 249 | L1ctlMA ma |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /* Test-specific parameters */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 253 | private type union TestSpecUnion { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 254 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 255 | } |
| 256 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 257 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 258 | max_retrans := RACH_MAX_RETRANS_7, |
| 259 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 260 | cell_barr_access := false, |
| 261 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 262 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 265 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 266 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 267 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 268 | acs := '0'B, |
| 269 | neci := true, |
| 270 | rxlev_access_min := 0 |
| 271 | } |
| 272 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 273 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 274 | mcc_mnc := '262F42'H, |
| 275 | lac := 42 |
| 276 | } |
| 277 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 278 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 279 | ra_colour := 0, |
| 280 | si13_pos := '0'B |
| 281 | } |
| 282 | |
| 283 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 284 | modifies ts_SI3RestOctets := { |
| 285 | gprs_ind := { |
| 286 | presence := CSN1_H, |
| 287 | ind := ts_GPRSIndicator_def |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 292 | modifies ts_SI4RestOctets := { |
| 293 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 294 | presence := CSN1_H, |
| 295 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 299 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 300 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 301 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 302 | payload := { |
| 303 | si3 := { |
| 304 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 305 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 306 | ctrl_chan_desc := { |
| 307 | msc_r99 := true, |
| 308 | att := true, |
| 309 | bs_ag_blks_res := 1, |
| 310 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 311 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 312 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 313 | spare := '00'B, |
| 314 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 315 | t3212 := 1 /* 6 minutes */ |
| 316 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 317 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 318 | dn_ind := false, |
| 319 | pwrc := false, |
| 320 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 321 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 322 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 323 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 324 | rach_control := ts_RachCtrl_default, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 325 | rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def)) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 329 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 330 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 331 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 332 | payload := { |
| 333 | si2 := { |
| 334 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 335 | ncc_permitted := '11111111'B, |
| 336 | rach_control := ts_RachCtrl_default |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 341 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 342 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 343 | payload := { |
| 344 | si4 := { |
| 345 | lai := ts_LAI_default, |
| 346 | cell_sel_par := ts_CellSelPar_default, |
| 347 | rach_control := ts_RachCtrl_default, |
| 348 | cbch_chan_desc := omit, |
| 349 | cbch_mobile_alloc := omit, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 350 | rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def)) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 355 | private function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 356 | runs on test_CT { |
| 357 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 358 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc))); |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 359 | } |
| 360 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 361 | private function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 362 | runs on test_CT { |
| 363 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 364 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 365 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 366 | } |
| 367 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 368 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 369 | map(self:BTSVTY, system:BTSVTY); |
| 370 | f_vty_set_prompts(BTSVTY); |
| 371 | f_vty_transceive(BTSVTY, "enable"); |
| 372 | } |
| 373 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 374 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 375 | map(self:BSCVTY, system:BSCVTY); |
| 376 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 377 | f_vty_transceive(BSCVTY, "enable"); |
| 378 | } |
| 379 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 380 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 381 | map(self:BSCVTY, system:BSCVTY); |
| 382 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 383 | f_vty_transceive(BSCVTY, "enable"); |
| 384 | } |
| 385 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 386 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 387 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 388 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 389 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 390 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 391 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 392 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 393 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 394 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 398 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 399 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 400 | timer T := 2.0; |
| 401 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 402 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 403 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 404 | return; |
| 405 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 406 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 407 | |
| 408 | T.start; |
| 409 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 410 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 411 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 417 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 418 | out integer trxc_conn_id) { |
| 419 | var Result res; |
| 420 | |
| 421 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 422 | "", -1, -1, { udp := {} }, {}); |
| 423 | if (not ispresent(res.connId)) { |
| 424 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 425 | "Could not connect to the control (TRXC) interface " & |
| 426 | "of FakeTRX, check your configuration"); |
| 427 | } |
| 428 | trxc_conn_id := res.connId; |
| 429 | } |
| 430 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 431 | /* global init function */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 432 | friend function f_init() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 433 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 434 | g_AllChannels := { |
| 435 | /* TS 1..4: TCH/F */ |
| 436 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 437 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 438 | /* TS 5: TCH/H */ |
| 439 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 440 | /* TS 0: SDCCH/4 */ |
| 441 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 442 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 443 | /* TS 6: SDCCH/8 */ |
| 444 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 445 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 446 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 447 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 448 | }; |
| 449 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 450 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 451 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 452 | g_AllChanTypes := { |
| 453 | /* TS 1..4: TCH/F */ |
| 454 | valueof(ts_RslChanNr_Bm(1)), |
| 455 | /* TS 5: TCH/H */ |
| 456 | valueof(ts_RslChanNr_Lm(5,1)), |
| 457 | /* TS 0: SDCCH/4 */ |
| 458 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 459 | /* TS 6: SDCCH/8 */ |
| 460 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 461 | }; |
| 462 | } else { |
| 463 | g_AllChanTypes := { |
| 464 | /* TS 1..4: TCH/F */ |
| 465 | valueof(ts_RslChanNr_Bm(1)), |
| 466 | /* TS 0: SDCCH/4 */ |
| 467 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 468 | /* TS 6: SDCCH/8 */ |
| 469 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 470 | }; |
| 471 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 472 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 473 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 474 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 475 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 476 | |
| 477 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 478 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 479 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 480 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 481 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 482 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 483 | map(self:PCU, system:PCU); |
| 484 | f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 485 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 486 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 487 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 488 | |
| 489 | /* Init TRXC interface to FakeTRX */ |
| 490 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 491 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 492 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 493 | /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 494 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256))); |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 495 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60))); |
Vadim Yanitskiy | de535e0 | 2019-07-26 16:29:27 +0700 | [diff] [blame] | 496 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 497 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60))); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 498 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 499 | |
| 500 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 501 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 502 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 503 | } |
| 504 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 505 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 506 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 507 | map(self:L1CTL, system:L1CTL); |
| 508 | f_connect_reset(L1CTL); |
| 509 | } |
| 510 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 511 | private type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 512 | |
| 513 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 514 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 515 | boolean pcu_comp := false, |
| 516 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 517 | runs on test_CT return ConnHdlr { |
| 518 | var charstring id := testcasename(); |
| 519 | var ConnHdlr vc_conn; |
| 520 | |
| 521 | vc_conn := ConnHdlr.create(id); |
| 522 | /* connect to RSL Emulation main component */ |
| 523 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 524 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 525 | |
| 526 | /* The ConnHdlr component may want to talk to some ports directly, |
| 527 | * so we disconnect it from the test_CT and connect it to the component. |
| 528 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 529 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 530 | unmap(self:PCU, system:PCU); |
| 531 | map(vc_conn:PCU, system:PCU); |
| 532 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 533 | if (trxc_comp) { |
| 534 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 535 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 536 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 537 | |
| 538 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 539 | return vc_conn; |
| 540 | } |
| 541 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 542 | private altstep as_Tguard() runs on ConnHdlr { |
| 543 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 544 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 545 | } |
| 546 | } |
| 547 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 548 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 549 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 550 | } |
| 551 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 552 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 553 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 554 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 555 | } |
| 556 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 557 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 558 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 559 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | /* first function started in ConnHdlr component */ |
| 563 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 564 | runs on ConnHdlr { |
| 565 | g_pars := pars; |
| 566 | g_chan_nr := pars.chan_nr; |
| 567 | |
| 568 | map(self:L1CTL, system:L1CTL); |
| 569 | f_connect_reset(L1CTL); |
| 570 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 571 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 572 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 573 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 574 | |
| 575 | g_Tguard.start(pars.t_guard); |
| 576 | activate(as_Tguard()); |
| 577 | |
| 578 | f_rslem_register(0, pars.chan_nr); |
| 579 | |
| 580 | /* call the user-supplied test case function */ |
| 581 | fn.apply(id); |
| 582 | } |
| 583 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 584 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 585 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 586 | runs on ConnHdlr return RSL_Message { |
| 587 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 588 | timer T := 3.0; |
| 589 | RSL.send(tx); |
| 590 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 591 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 592 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 593 | T.stop; |
| 594 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 595 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 596 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 597 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 598 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 599 | [not ignore_other] as_l1_sacch(); |
| 600 | [not ignore_other] as_meas_res(); |
| 601 | [not ignore_other] as_l1_dcch(); |
| 602 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 603 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 604 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 605 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 606 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 607 | return rx; |
| 608 | } |
| 609 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 610 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 611 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 612 | runs on ConnHdlr { |
| 613 | var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 614 | } |
| 615 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 616 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 617 | boolean encr_enable := false, |
| 618 | RSL_IE_List more_ies := {}, |
| 619 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 620 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 621 | var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type)); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 622 | if (encr_enable) { |
| 623 | /* append encryption related IEs, if requested */ |
| 624 | var RSL_IE_EncryptionInfo encr_info; |
| 625 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 626 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 627 | encr_info})) }; |
| 628 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 629 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 630 | f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT"); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 631 | } |
| 632 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 633 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 634 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 635 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 636 | } |
| 637 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 638 | /* Default Mobile Allocation to be used for frequency hopping */ |
| 639 | private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn }, |
| 640 | { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } }; |
| 641 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 642 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 643 | template RSL_IE_ChannelMode chan_mode, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 644 | template (omit) MaioHsn maio_hsn := omit, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 645 | float t_guard := 20.0) := { |
| 646 | chan_nr := valueof(chan_nr), |
| 647 | chan_mode := valueof(chan_mode), |
| 648 | t_guard := t_guard, |
| 649 | l1_pars := { |
| 650 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 651 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 652 | meas_ul := { |
| 653 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 654 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 655 | rxqual := 0 |
| 656 | }, |
| 657 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 658 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 659 | rxqual := 0 |
| 660 | } |
| 661 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 662 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 663 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 664 | ms_power_level := mp_ms_power_level_exp, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 665 | ms_actual_ta := mp_ms_actual_ta_exp |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 666 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 667 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 668 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 669 | bts0_band := omit, |
| 670 | maio_hsn := maio_hsn, |
| 671 | ma_map := c_MA_null, |
| 672 | ma := l1ctl_ma_def |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 673 | } |
| 674 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 675 | /*********************************************************************** |
| 676 | * Channel Activation / Deactivation |
| 677 | ***********************************************************************/ |
| 678 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 679 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 680 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 681 | for (var integer i := 0; i < 500; i := i+1) { |
| 682 | f_rsl_chan_act(g_pars.chan_mode); |
| 683 | f_rsl_chan_deact(); |
| 684 | } |
| 685 | setverdict(pass); |
| 686 | } |
| 687 | testcase TC_chan_act_stress() runs on test_CT { |
| 688 | var ConnHdlr vc_conn; |
| 689 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 690 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 691 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 692 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 697 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 698 | f_rsl_chan_act(g_pars.chan_mode); |
| 699 | /* attempt to activate the same lchan again -> expect reject */ |
| 700 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 701 | alt { |
| 702 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 703 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 704 | } |
| 705 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 706 | setverdict(pass); |
| 707 | } |
| 708 | } |
| 709 | f_rsl_chan_deact(); |
| 710 | } |
| 711 | testcase TC_chan_act_react() runs on test_CT { |
| 712 | var ConnHdlr vc_conn; |
| 713 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 714 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 715 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 716 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 717 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 721 | private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 722 | timer T := 3.0; |
| 723 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 724 | T.start; |
| 725 | alt { |
| 726 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 727 | setverdict(pass); |
| 728 | } |
| 729 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 730 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 731 | } |
| 732 | } |
| 733 | } |
| 734 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 735 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 736 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 737 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 738 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 739 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 743 | private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 744 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 745 | alt { |
| 746 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 747 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 748 | } |
| 749 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 750 | setverdict(pass); |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | private type record WrongChanNrCase { |
| 755 | RslChannelNr chan_nr, |
| 756 | charstring description |
| 757 | } |
| 758 | private type record of WrongChanNrCase WrongChanNrCases; |
| 759 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 760 | chan_nr := chan_nr, |
| 761 | description := desc |
| 762 | } |
| 763 | |
| 764 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 765 | var ConnHdlr vc_conn; |
| 766 | var ConnHdlrPars pars; |
| 767 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 768 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 769 | |
| 770 | var WrongChanNrCases wrong := { |
| 771 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 772 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 773 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 774 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 775 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 776 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 777 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 778 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 779 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 780 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 781 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 782 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 783 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 784 | }; |
| 785 | |
| 786 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 787 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 788 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 789 | vc_conn.done; |
| 790 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 791 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 792 | } |
| 793 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 794 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 795 | friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 796 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 797 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 798 | |
| 799 | /* test on each of the channels we have */ |
| 800 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 801 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 802 | |
| 803 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 804 | vc_conn := f_start_handler(fn, pars); |
| 805 | vc_conn.done; |
| 806 | } |
| 807 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 808 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 809 | } |
| 810 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 811 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 812 | * SACCH handling |
| 813 | ***********************************************************************/ |
| 814 | |
| 815 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 816 | timer T_sacch := 3.0; |
| 817 | T_sacch.start; |
| 818 | alt { |
| 819 | [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 820 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it"); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 821 | } |
| 822 | [not exp] T_sacch.timeout { |
| 823 | setverdict(pass); |
| 824 | } |
| 825 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 826 | setverdict(pass); |
| 827 | } |
| 828 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 829 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr)); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 830 | } |
| 831 | [] L1CTL.receive { repeat; } |
| 832 | [] RSL.receive { repeat; } |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 837 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 838 | f_l1_tune(L1CTL); |
| 839 | RSL.clear; |
| 840 | |
| 841 | /* activate the logical channel */ |
| 842 | f_est_dchan(); |
| 843 | L1CTL.clear; |
| 844 | |
| 845 | /* check that SACCH actually are received as expected */ |
| 846 | f_exp_sacch(true); |
| 847 | |
| 848 | /* deactivate SACCH on the logical channel */ |
| 849 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 850 | f_sleep(1.0); |
| 851 | L1CTL.clear; |
| 852 | |
| 853 | /* check that no SACCH are received anymore */ |
| 854 | f_exp_sacch(false); |
| 855 | |
| 856 | /* release the channel */ |
| 857 | f_rsl_chan_deact(); |
| 858 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 859 | } |
| 860 | testcase TC_deact_sacch() runs on test_CT { |
| 861 | var ConnHdlr vc_conn; |
| 862 | var ConnHdlrPars pars; |
| 863 | f_init(); |
| 864 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 865 | //for (var integer i := 0; i < 1; i := i+1) { |
| 866 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 867 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 868 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 869 | vc_conn.done; |
| 870 | } |
| 871 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 872 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 873 | } |
| 874 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 875 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 876 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 877 | var L1ctlDlMessage dl; |
| 878 | /* check that the specified SI5 value is actually sent */ |
| 879 | timer T_sacch := 3.0; |
| 880 | L1CTL.clear; |
| 881 | T_sacch.start; |
| 882 | alt { |
| 883 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 884 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 885 | if (match(l3, l3_exp)) { |
| 886 | setverdict(pass); |
| 887 | } else { |
| 888 | repeat; |
| 889 | } |
| 890 | } |
| 891 | [] L1CTL.receive { repeat; } |
| 892 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 893 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp)); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 894 | } |
| 895 | } |
| 896 | } |
| 897 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 898 | /* verify that given SACCH payload is not present */ |
| 899 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 900 | var L1ctlDlMessage dl; |
| 901 | /* check that the specified SI5 value is actually sent */ |
| 902 | timer T_sacch := 3.0; |
| 903 | L1CTL.clear; |
| 904 | T_sacch.start; |
| 905 | alt { |
| 906 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 907 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 908 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 909 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 910 | } else { |
| 911 | repeat; |
| 912 | } |
| 913 | } |
| 914 | [] L1CTL.receive { repeat; } |
| 915 | [] T_sacch.timeout { |
| 916 | setverdict(pass); |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 921 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 922 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 923 | /* Set a known default SACCH filling for SI5 */ |
| 924 | var octetstring si5 := f_rnd_octstring(19); |
| 925 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 926 | |
| 927 | f_l1_tune(L1CTL); |
| 928 | RSL.clear; |
| 929 | |
| 930 | /* activate the logical channel */ |
| 931 | f_est_dchan(); |
| 932 | |
| 933 | /* check that the specified SI5 value is actually sent */ |
| 934 | f_sacch_present(si5); |
| 935 | |
| 936 | /* release the channel */ |
| 937 | RSL.clear; |
| 938 | f_rsl_chan_deact(); |
| 939 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 940 | } |
| 941 | testcase TC_sacch_filling() runs on test_CT { |
| 942 | var ConnHdlr vc_conn; |
| 943 | var ConnHdlrPars pars; |
| 944 | f_init(); |
| 945 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 946 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 947 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 948 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 949 | vc_conn.done; |
| 950 | } |
| 951 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 952 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 953 | } |
| 954 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 955 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 956 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 957 | /* Set a known default SACCH filling for SI5 */ |
| 958 | var octetstring si5 := f_rnd_octstring(19); |
| 959 | var octetstring si5_diff := f_rnd_octstring(19); |
| 960 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 961 | |
| 962 | f_l1_tune(L1CTL); |
| 963 | RSL.clear; |
| 964 | |
| 965 | log("Activating channel, expecting standard SI5"); |
| 966 | /* activate the logical channel */ |
| 967 | f_est_dchan(); |
| 968 | /* check that the specified SI5 value is actually sent */ |
| 969 | f_sacch_present(si5); |
| 970 | |
| 971 | /* set channel-specific different SI5 */ |
| 972 | log("Setting channel specific SACCH INFO, expecting it"); |
| 973 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 974 | /* check that the specified lchan-specific value is now used */ |
| 975 | f_sacch_present(si5_diff); |
| 976 | |
| 977 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 978 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 979 | f_rsl_chan_deact(); |
| 980 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 981 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 982 | f_sacch_present(si5); |
| 983 | |
| 984 | /* release the channel */ |
| 985 | RSL.clear; |
| 986 | f_rsl_chan_deact(); |
| 987 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 988 | } |
| 989 | testcase TC_sacch_info_mod() runs on test_CT { |
| 990 | var ConnHdlr vc_conn; |
| 991 | var ConnHdlrPars pars; |
| 992 | f_init(); |
| 993 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 994 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 995 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 996 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 997 | vc_conn.done; |
| 998 | } |
| 999 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1000 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1003 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1004 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1005 | var octetstring si5 := f_rnd_octstring(19); |
| 1006 | var octetstring si5bis := f_rnd_octstring(19); |
| 1007 | var octetstring si5ter := f_rnd_octstring(19); |
| 1008 | var octetstring si6 := f_rnd_octstring(19); |
| 1009 | |
| 1010 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1011 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1012 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1013 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1014 | |
| 1015 | f_l1_tune(L1CTL); |
| 1016 | RSL.clear; |
| 1017 | |
| 1018 | /* activate the logical channel */ |
| 1019 | f_est_dchan(); |
| 1020 | L1CTL.clear; |
| 1021 | |
| 1022 | /* check that SACCH actually are received as expected */ |
| 1023 | f_sacch_present(si5); |
| 1024 | f_sacch_present(si5bis); |
| 1025 | f_sacch_present(si5ter); |
| 1026 | f_sacch_present(si6); |
| 1027 | |
| 1028 | /* release the channel */ |
| 1029 | f_rsl_chan_deact(); |
| 1030 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1031 | } |
| 1032 | testcase TC_sacch_multi() runs on test_CT { |
| 1033 | var ConnHdlr vc_conn; |
| 1034 | var ConnHdlrPars pars; |
| 1035 | f_init(); |
| 1036 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1037 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1038 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1039 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1040 | vc_conn.done; |
| 1041 | } |
| 1042 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1043 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1044 | } |
| 1045 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1046 | /* Test if SACH information is modified as expected */ |
| 1047 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1048 | var octetstring si5 := f_rnd_octstring(19); |
| 1049 | var octetstring si6 := f_rnd_octstring(19); |
| 1050 | |
| 1051 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1052 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1053 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1054 | |
| 1055 | f_l1_tune(L1CTL); |
| 1056 | RSL.clear; |
| 1057 | |
| 1058 | /* activate the logical channel */ |
| 1059 | f_est_dchan(); |
| 1060 | L1CTL.clear; |
| 1061 | |
| 1062 | /* check that SACCH actually are received as expected */ |
| 1063 | f_sacch_present(si5); |
| 1064 | f_sacch_present(si6); |
| 1065 | |
| 1066 | /* disable SI6 */ |
| 1067 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1068 | |
| 1069 | /* check that SI5 is still transmitted */ |
| 1070 | f_sacch_present(si5); |
| 1071 | /* check if SI6 is now gone */ |
| 1072 | f_sacch_missing(si6); |
| 1073 | |
| 1074 | /* release the channel */ |
| 1075 | f_rsl_chan_deact(); |
| 1076 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1077 | } |
| 1078 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1079 | var ConnHdlr vc_conn; |
| 1080 | var ConnHdlrPars pars; |
| 1081 | f_init(); |
| 1082 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1083 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1084 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1085 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1086 | vc_conn.done; |
| 1087 | } |
| 1088 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1089 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1090 | } |
| 1091 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1092 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1093 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1094 | var octetstring si5 := f_rnd_octstring(19); |
| 1095 | var octetstring si6 := f_rnd_octstring(19); |
| 1096 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1097 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1098 | |
| 1099 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1100 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1101 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1102 | |
| 1103 | f_l1_tune(L1CTL); |
| 1104 | RSL.clear; |
| 1105 | |
| 1106 | /* activate channel with different SACCH filling */ |
| 1107 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1108 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1109 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1110 | })); |
| 1111 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1112 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1113 | f_est_dchan(more_ies := addl_ies); |
| 1114 | |
| 1115 | /* check that SACCH actually are received as expected */ |
| 1116 | f_sacch_present(si5_specific); |
| 1117 | f_sacch_present(si6_specific); |
| 1118 | |
| 1119 | /* release the channel */ |
| 1120 | f_rsl_chan_deact(); |
| 1121 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1122 | } |
| 1123 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1124 | var ConnHdlr vc_conn; |
| 1125 | var ConnHdlrPars pars; |
| 1126 | f_init(); |
| 1127 | |
| 1128 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1129 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1130 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1131 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1132 | vc_conn.done; |
| 1133 | } |
| 1134 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1135 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1136 | } |
| 1137 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1138 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1139 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1140 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1141 | var octetstring si5 := f_rnd_octstring(19); |
| 1142 | |
| 1143 | f_l1_tune(L1CTL); |
| 1144 | RSL.clear; |
| 1145 | |
| 1146 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1147 | |
| 1148 | /* Activate channel on BTS side */ |
| 1149 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1150 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1151 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1152 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1153 | |
| 1154 | /* Verify that no DL SACCH is being received */ |
| 1155 | f_sacch_missing(?); |
| 1156 | |
| 1157 | f_rsl_chan_deact(); |
| 1158 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1159 | |
| 1160 | |
| 1161 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1162 | |
| 1163 | /* Activate channel on BTS side */ |
| 1164 | var RSL_IE_List addl_ies := { |
| 1165 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1166 | }; |
| 1167 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1168 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1169 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1170 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1171 | |
| 1172 | /* Verify that DL SACCH is being received */ |
| 1173 | f_sacch_present(si5); |
| 1174 | |
| 1175 | f_rsl_chan_deact(); |
| 1176 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1177 | } |
| 1178 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1179 | var ConnHdlr vc_conn; |
| 1180 | var ConnHdlrPars pars; |
| 1181 | f_init(); |
| 1182 | |
| 1183 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1184 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1185 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1186 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1187 | vc_conn.done; |
| 1188 | } |
| 1189 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1190 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1191 | } |
| 1192 | |
| 1193 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1194 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1195 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1196 | var octetstring si5 := f_rnd_octstring(19); |
| 1197 | var RSL_IE_List addl_ies; |
| 1198 | |
| 1199 | f_l1_tune(L1CTL); |
| 1200 | RSL.clear; |
| 1201 | |
| 1202 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1203 | |
| 1204 | /* Activate channel on BTS side */ |
| 1205 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1206 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1207 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1208 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1209 | |
| 1210 | /* Verify that no DL SACCH is being received */ |
| 1211 | f_sacch_missing(?); |
| 1212 | |
| 1213 | f_rsl_chan_deact(); |
| 1214 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1215 | |
| 1216 | |
| 1217 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1218 | |
| 1219 | /* Activate channel on BTS side */ |
| 1220 | addl_ies := { |
| 1221 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1222 | }; |
| 1223 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1224 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1225 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1226 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1227 | |
| 1228 | /* Verify that no DL SACCH is being received */ |
| 1229 | f_sacch_missing(?); |
| 1230 | |
| 1231 | f_rsl_chan_deact(); |
| 1232 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1233 | |
| 1234 | |
| 1235 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1236 | |
| 1237 | /* Activate channel on BTS side */ |
| 1238 | addl_ies := { |
| 1239 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1240 | }; |
| 1241 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1242 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1243 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1244 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1245 | |
| 1246 | /* Verify that no DL SACCH is being received */ |
| 1247 | f_sacch_missing(?); |
| 1248 | |
| 1249 | f_rsl_chan_deact(); |
| 1250 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1251 | |
| 1252 | |
| 1253 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1254 | |
| 1255 | /* Activate channel on BTS side */ |
| 1256 | addl_ies := { |
| 1257 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1258 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1259 | }; |
| 1260 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1261 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1262 | /* enable dedicated mode */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1263 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1264 | |
| 1265 | /* Verify that DL SACCH is being received */ |
| 1266 | f_sacch_present(si5); |
| 1267 | |
| 1268 | f_rsl_chan_deact(); |
| 1269 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1270 | } |
| 1271 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1272 | var ConnHdlr vc_conn; |
| 1273 | var ConnHdlrPars pars; |
| 1274 | f_init(); |
| 1275 | |
| 1276 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1277 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1278 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1279 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1280 | vc_conn.done; |
| 1281 | } |
| 1282 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1283 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1284 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1285 | |
| 1286 | |
| 1287 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1288 | * RACH Handling |
| 1289 | ***********************************************************************/ |
| 1290 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1291 | /* like L1SAP_IS_PACKET_RACH */ |
| 1292 | private function ra_is_ps(OCT1 ra) return boolean { |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1293 | if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1294 | return true; |
| 1295 | } |
| 1296 | return false; |
| 1297 | } |
| 1298 | |
| 1299 | /* generate a random RACH for circuit-switched */ |
| 1300 | private function f_rnd_ra_cs() return OCT1 { |
| 1301 | var OCT1 ra; |
| 1302 | do { |
| 1303 | ra := f_rnd_octstring(1); |
| 1304 | } while (ra_is_ps(ra)); |
| 1305 | return ra; |
| 1306 | } |
| 1307 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 1308 | /* generate a random RACH for packet-switched */ |
| 1309 | private function f_rnd_ra_ps() return OCT1 { |
| 1310 | var OCT1 ra; |
| 1311 | do { |
| 1312 | ra := f_rnd_octstring(1); |
| 1313 | } while (not ra_is_ps(ra)); |
| 1314 | return ra; |
| 1315 | } |
| 1316 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 1317 | /* generate a random 11-bit RA (packet-switched only) */ |
| 1318 | private function f_rnd_ra11_ps() return BIT11 { |
| 1319 | var integer ra11 := f_rnd_int(bit2int('11111111111'B)); |
| 1320 | return int2bit(ra11, 11); |
| 1321 | } |
| 1322 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1323 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 1324 | testcase TC_rach_content() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1325 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1326 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1327 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1328 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1329 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1330 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1331 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1332 | var OCT1 ra := f_rnd_ra_cs(); |
| 1333 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1334 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1335 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1336 | } |
| 1337 | fn_last := fn; |
| 1338 | |
| 1339 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1340 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1341 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1342 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1343 | T.stop; |
| 1344 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1345 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1346 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1347 | } |
| 1348 | [] RSL_CCHAN.receive { repeat; } |
| 1349 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1350 | test_failed := true; |
| 1351 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1352 | } |
| 1353 | } |
| 1354 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1355 | if (test_failed) { |
| 1356 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out")); |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1357 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1358 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1359 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1360 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1361 | |
| 1362 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1363 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1364 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1365 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1366 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1367 | f_l1_tune(L1CTL); |
| 1368 | |
| 1369 | var GsmFrameNumber fn_last := 0; |
| 1370 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1371 | var OCT1 ra := f_rnd_ra_cs(); |
| 1372 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1373 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1374 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1375 | } |
| 1376 | fn_last := fn; |
| 1377 | } |
| 1378 | var integer rsl_chrqd := 0; |
| 1379 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1380 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1381 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1382 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1383 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1384 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1385 | repeat; |
| 1386 | } |
| 1387 | [] RSL_CCHAN.receive { repeat; } |
| 1388 | [] T.timeout { } |
| 1389 | } |
| 1390 | if (rsl_chrqd == 1000) { |
| 1391 | setverdict(pass); |
| 1392 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1393 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH")); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1394 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1396 | } |
| 1397 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1398 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1399 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1400 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1401 | } |
| 1402 | |
| 1403 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1404 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1405 | |
| 1406 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1407 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1408 | var ASP_RSL_Unitdata rx_ud; |
| 1409 | |
| 1410 | f_init_vty_bsc(); |
| 1411 | /* send load indications even at 0% load */ |
| 1412 | f_vty_load_ind_thresh(0); |
| 1413 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1414 | f_sleep(2.0); |
| 1415 | |
| 1416 | f_init(); |
| 1417 | |
| 1418 | timer T := 5.0; |
| 1419 | T.start; |
| 1420 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1421 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1422 | setverdict(pass); |
| 1423 | repeat; |
| 1424 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1425 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1426 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1427 | repeat; |
| 1428 | } |
| 1429 | [] RSL_CCHAN.receive { |
| 1430 | repeat; |
| 1431 | } |
| 1432 | [] T.timeout { } |
| 1433 | } |
| 1434 | |
| 1435 | f_vty_load_ind_thresh(10); |
| 1436 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1437 | } |
| 1438 | |
| 1439 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1440 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1441 | var ASP_RSL_Unitdata rx_ud; |
| 1442 | |
| 1443 | f_init_vty_bsc(); |
| 1444 | f_init(); |
| 1445 | |
| 1446 | timer T := 5.0; |
| 1447 | T.start; |
| 1448 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1449 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1450 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1451 | repeat; |
| 1452 | } |
| 1453 | [] RSL_CCHAN.receive { |
| 1454 | repeat; |
| 1455 | } |
| 1456 | [] T.timeout { |
| 1457 | setverdict(pass); |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1462 | } |
| 1463 | |
| 1464 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1465 | testcase TC_rach_load_count() runs on test_CT { |
| 1466 | var ASP_RSL_Unitdata rx_ud; |
| 1467 | var integer load_access_count := 0; |
| 1468 | |
| 1469 | f_init_vty_bsc(); |
| 1470 | /* send load indications even at 0% load */ |
| 1471 | f_vty_load_ind_thresh(0); |
| 1472 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1473 | f_sleep(2.0); |
| 1474 | f_init(); |
| 1475 | |
| 1476 | f_init_l1ctl(); |
| 1477 | f_sleep(1.0); |
| 1478 | f_l1_tune(L1CTL); |
| 1479 | |
| 1480 | var GsmFrameNumber fn_last := 0; |
| 1481 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1482 | var OCT1 ra := f_rnd_ra_cs(); |
| 1483 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1484 | if (fn == fn_last) { |
| 1485 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1486 | } |
| 1487 | fn_last := fn; |
| 1488 | } |
| 1489 | |
| 1490 | timer T := 5.0; |
| 1491 | T.start; |
| 1492 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1493 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?))) |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1494 | -> value rx_ud { |
| 1495 | var RSL_IE_Body ie; |
| 1496 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1497 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1498 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1499 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1500 | } |
| 1501 | repeat; |
| 1502 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1503 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1504 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1505 | repeat; |
| 1506 | } |
| 1507 | [] RSL_CCHAN.receive { |
| 1508 | repeat; |
| 1509 | } |
| 1510 | [] T.timeout { } |
| 1511 | } |
| 1512 | if (load_access_count == 1000) { |
| 1513 | setverdict(pass); |
| 1514 | } else { |
| 1515 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1516 | } |
| 1517 | |
| 1518 | f_vty_load_ind_thresh(10); |
| 1519 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1520 | } |
| 1521 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1522 | private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1523 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1524 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1525 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1526 | f_sleep(0.5); |
| 1527 | |
| 1528 | /* Transmit RACH request + wait for confirmation */ |
| 1529 | var OCT1 ra := f_rnd_ra_cs(); |
| 1530 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1531 | |
| 1532 | /* Check for expected result */ |
| 1533 | timer T := 1.5; |
| 1534 | T.start; |
| 1535 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1536 | [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1537 | setverdict(pass); |
| 1538 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1539 | [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1540 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256)); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1541 | } |
| 1542 | [] RSL_CCHAN.receive { repeat; } |
| 1543 | [not expect_pass] T.timeout { |
| 1544 | setverdict(pass); |
| 1545 | } |
| 1546 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1547 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra)); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1548 | } |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1553 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1554 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1555 | f_init_l1ctl(); |
| 1556 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1557 | f_sleep(1.0); |
| 1558 | |
| 1559 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1560 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1561 | /* We allow early arrival up to 2 symbols */ |
| 1562 | f_rach_toffs(-1*256, true); |
| 1563 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1564 | f_rach_toffs(-10*256, false); |
| 1565 | |
| 1566 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1567 | f_rach_toffs(0, true); |
| 1568 | f_rach_toffs(32*256, true); |
| 1569 | f_rach_toffs(63*256, true); |
| 1570 | |
| 1571 | /* more than 63 bits is not legal / permitted */ |
| 1572 | f_rach_toffs(64*256, false); |
| 1573 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1574 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1575 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1576 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1577 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1578 | var GsmFrameNumber fn; |
| 1579 | var RSL_Message rm; |
| 1580 | |
| 1581 | f_l1_tune(L1CTL); |
| 1582 | RSL.clear; |
| 1583 | |
| 1584 | /* Generate a random Handover Reference */ |
| 1585 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1586 | |
| 1587 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1588 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1589 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1590 | |
| 1591 | /* Activate a channel on the BTS side (no encryption) */ |
| 1592 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1593 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1594 | |
| 1595 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1596 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 1597 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1598 | |
| 1599 | /* Send handover Access Burst */ |
| 1600 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1601 | |
| 1602 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1603 | |
| 1604 | /* Wait for handover detection */ |
| 1605 | timer T := 3.0; |
| 1606 | T.start; |
| 1607 | alt { |
| 1608 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1609 | log("Handover RACH has been detected: ", rm); |
| 1610 | setverdict(pass); |
| 1611 | } |
| 1612 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1613 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1614 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1615 | } |
| 1616 | [] RSL.receive { repeat; } |
| 1617 | [] T.timeout { |
| 1618 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1619 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | /* Release the channel */ |
| 1624 | f_rsl_chan_deact(); |
| 1625 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1626 | } |
| 1627 | |
| 1628 | /* Test handover RACH detection */ |
| 1629 | testcase TC_ho_rach() runs on test_CT { |
| 1630 | var ConnHdlrPars pars; |
| 1631 | var ConnHdlr vc_conn; |
| 1632 | |
| 1633 | f_init(); |
| 1634 | |
| 1635 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1636 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1637 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1638 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1639 | vc_conn.done; |
| 1640 | } |
| 1641 | |
| 1642 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1643 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1644 | } |
| 1645 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1646 | /*********************************************************************** |
| 1647 | * Measurement Processing / Reporting |
| 1648 | ***********************************************************************/ |
| 1649 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1650 | private template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1651 | spare := '0'B, |
| 1652 | lpd := 0, |
| 1653 | sapi := sapi, |
| 1654 | c_r := c_r, |
| 1655 | ea := true |
| 1656 | } |
| 1657 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1658 | private template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1659 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1660 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1661 | len := 0, /* overwritten */ |
| 1662 | m := false, |
| 1663 | el := 1, |
| 1664 | payload := pl |
| 1665 | } |
| 1666 | |
| 1667 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1668 | private altstep as_l1_sacch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1669 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1670 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1671 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1672 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp, 0, 0, omit)); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1673 | var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1674 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1675 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1676 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1677 | g_pars.l1_pars.ms_power_level, false, |
| 1678 | g_pars.l1_pars.ms_actual_ta); |
| 1679 | |
| 1680 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1681 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1682 | |
| 1683 | log("Sending Measurement Report: ", l1h, l2); |
| 1684 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1685 | repeat; |
| 1686 | } |
| 1687 | } |
| 1688 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1689 | private altstep as_l1_dcch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1690 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1691 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1692 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1693 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1694 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1695 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1696 | repeat; |
| 1697 | } |
| 1698 | } |
| 1699 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1700 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1701 | uint6_t rxlev, |
| 1702 | uint3_t rxqual |
| 1703 | } |
| 1704 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1705 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1706 | MeasElem full, |
| 1707 | MeasElem sub |
| 1708 | } |
| 1709 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1710 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1711 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1712 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1713 | MeasElemFS meas_ul, |
| 1714 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1715 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1716 | uint5_t ms_power_level, |
| 1717 | uint8_t ms_actual_ta |
| 1718 | } |
| 1719 | |
| 1720 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1721 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1722 | return 63 + (toffs256s/256); |
| 1723 | } |
| 1724 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1725 | private function f_max(integer a, integer b) return integer { |
| 1726 | if (a > b) { |
| 1727 | return a; |
| 1728 | } else { |
| 1729 | return b; |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | private function f_min(integer a, integer b) return integer { |
| 1734 | if (a < b) { |
| 1735 | return a; |
| 1736 | } else { |
| 1737 | return b; |
| 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1742 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1743 | val := val - tolerance; |
| 1744 | return f_max(val, min); |
| 1745 | } |
| 1746 | |
| 1747 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1748 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1749 | val := val + tolerance; |
| 1750 | return f_min(val, max); |
| 1751 | } |
| 1752 | |
| 1753 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1754 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1755 | return template integer { |
| 1756 | var template integer ret; |
| 1757 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1758 | return ret; |
| 1759 | } |
| 1760 | |
| 1761 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1762 | /* build a template for matching measurement results against */ |
| 1763 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1764 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1765 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1766 | len := 3, |
| 1767 | rfu := '0'B, |
| 1768 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1769 | rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1770 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1771 | rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1772 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1773 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1774 | rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1775 | supp_meas_info := omit |
| 1776 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1777 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1778 | ul_meas.len := (3+8); |
| 1779 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1780 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1781 | toa256_min := ?, |
| 1782 | toa256_max := ?, |
| 1783 | toa256_std_dev := ? |
| 1784 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1785 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1786 | var template RSL_IE_BS_Power bs_power := { |
| 1787 | reserved := 0, |
| 1788 | epc := false, |
| 1789 | fpc := false, |
| 1790 | power_level := l1p.bs_power_level |
| 1791 | }; |
| 1792 | var template RSL_IE_L1Info l1_info := { |
| 1793 | ms_power_lvl := l1p.ms_power_level, |
| 1794 | fpc := false, |
| 1795 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1796 | actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1797 | }; |
| 1798 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1799 | var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1800 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1801 | ?, t_toffs); |
| 1802 | } |
| 1803 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1804 | /* build a template for matching measurement results that do not contain any |
| 1805 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 1806 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 1807 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1808 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1809 | len := 3, |
| 1810 | rfu := '0'B, |
| 1811 | dtx_d := l1p.dtx_enabled, |
| 1812 | rxlev_f_u := ?, |
| 1813 | reserved1 := '00'B, |
| 1814 | rxlev_s_u := ?, |
| 1815 | reserved2 := '00'B, |
| 1816 | rxq_f_u := ?, |
| 1817 | rxq_s_u := ?, |
| 1818 | supp_meas_info := omit |
| 1819 | }; |
| 1820 | if (l1p.toa256_enabled) { |
| 1821 | ul_meas.len := (3+8); |
| 1822 | ul_meas.supp_meas_info := { |
| 1823 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 1824 | toa256_min := ?, |
| 1825 | toa256_max := ?, |
| 1826 | toa256_std_dev := ? |
| 1827 | } |
| 1828 | } |
| 1829 | var template RSL_IE_BS_Power bs_power := { |
| 1830 | reserved := 0, |
| 1831 | epc := false, |
| 1832 | fpc := false, |
| 1833 | power_level := l1p.bs_power_level |
| 1834 | }; |
| 1835 | |
| 1836 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 1837 | } |
| 1838 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1839 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1840 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1841 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1842 | var boolean chan_est := false; |
| 1843 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1844 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1845 | |
| 1846 | /* Receive osmocom specific measurement reports. This is the normal |
| 1847 | * case. Here we verify that the measurement reports we sent are |
| 1848 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1849 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1850 | /* increment counter of next to-be-expected meas rep */ |
| 1851 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1852 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1853 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1854 | |
| 1855 | /* The following two cases may only happen in the beginning |
| 1856 | * of the channel establishment phase. Once we have received |
| 1857 | * the "our" measurement report the first time, the channel |
| 1858 | * is established and empty or hardcoded TRXCON reports must |
| 1859 | * not occur anymore. */ |
| 1860 | chan_est := true; |
| 1861 | |
| 1862 | repeat; |
| 1863 | } |
| 1864 | |
| 1865 | /* When the BTS has established the channel, the MS might need slightly |
| 1866 | * more time to establish the channel and actually start sending. The |
| 1867 | * result is then a measurement report that just lacks the measurement |
| 1868 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 1869 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 1870 | /* increment counter of next to-be-expected meas rep */ |
| 1871 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1872 | /* Re-start the timer expecting the next MEAS RES */ |
| 1873 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1874 | repeat; |
| 1875 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1876 | |
| 1877 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 1878 | * measurements if the TTCN3 side does not supply measurement input in |
| 1879 | * time. In those cases TRXCON will either use a cached measurement |
| 1880 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 1881 | * report the templates above will not match. We tolerate this |
| 1882 | * behavior, but only once. */ |
| 1883 | [chan_est == false] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl { |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1884 | /* increment counter of next to-be-expected meas rep */ |
| 1885 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1886 | if (g_first_meas_res) { |
| 1887 | g_first_meas_res := false; |
| 1888 | repeat; |
| 1889 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1890 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl)); |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1891 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1892 | } |
| 1893 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1894 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1895 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 1896 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1897 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result") |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1898 | } |
| 1899 | } |
| 1900 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1901 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1902 | select (rsl_alg_id) { |
| 1903 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1904 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1905 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1906 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1907 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1908 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1909 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1910 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1911 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1912 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1913 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1914 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1915 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1916 | } |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1921 | select (rsl_alg_id) { |
| 1922 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1923 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1924 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1925 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1926 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1927 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1928 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1929 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1930 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1931 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1932 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1933 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1934 | } |
| 1935 | } |
| 1936 | } |
| 1937 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1938 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 1939 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 1940 | var GsmFrameNumber fn; |
| 1941 | timer T := 8.0; |
| 1942 | |
| 1943 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 1944 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 1945 | |
| 1946 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 1947 | /* Send the actual RACH */ |
| 1948 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 1949 | |
| 1950 | T.start; |
| 1951 | alt { |
| 1952 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 1953 | [] T.timeout { |
| 1954 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 1955 | } |
| 1956 | } |
| 1957 | T.stop |
| 1958 | return fn; |
| 1959 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1960 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1961 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1962 | private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1963 | var GsmFrameNumber fn; |
| 1964 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1965 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1966 | var integer ra := 23; |
| 1967 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1968 | /* Send RACH request and wait for ChanReq */ |
| 1969 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1970 | |
| 1971 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1972 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1973 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1974 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 1975 | if (ispresent(g_pars.maio_hsn)) { |
| 1976 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, maio_hsn := g_pars.maio_hsn)); |
| 1977 | } else { |
| 1978 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr)); |
| 1979 | } |
| 1980 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1981 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1982 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.ma_map)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1983 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 1984 | |
| 1985 | /* receive IMM.ASS on MS side */ |
| 1986 | var ImmediateAssignment ia_um; |
| 1987 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1988 | |
| 1989 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 1990 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 1991 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 1992 | } |
| 1993 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1994 | /* enable dedicated mode */ |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 1995 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.ma); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1996 | /* enable encryption, if requested */ |
| 1997 | if (encr_enable) { |
| 1998 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 1999 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2000 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2001 | |
| 2002 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2003 | } |
| 2004 | |
| 2005 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2006 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2007 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2008 | RSL.clear; |
| 2009 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2010 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2011 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2012 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2013 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2014 | |
| 2015 | f_est_dchan(); |
| 2016 | |
| 2017 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2018 | * RSL measurement reports on Abis side */ |
| 2019 | timer T := 8.0; |
| 2020 | T.start; |
| 2021 | alt { |
| 2022 | [] as_l1_sacch(); |
| 2023 | [] as_meas_res(); |
| 2024 | [] as_l1_dcch(); |
| 2025 | [] L1CTL.receive { repeat; } |
| 2026 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2027 | /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2028 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2029 | setverdict(pass); |
| 2030 | } |
| 2031 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2032 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2036 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2037 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2038 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2039 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2040 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2041 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2042 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2043 | timer Tup := 10.0; |
| 2044 | Tup.start; |
| 2045 | alt { |
| 2046 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2047 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2048 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2049 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2050 | if (rx_lvl != max_rx_lvl) { |
| 2051 | repeat; |
| 2052 | } |
| 2053 | Tup.stop; |
| 2054 | } |
| 2055 | [] L1CTL.receive { repeat; } |
| 2056 | [] Tup.timeout { |
| 2057 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2058 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2059 | } |
| 2060 | } |
| 2061 | return max_rx_lvl; |
| 2062 | } |
| 2063 | |
| 2064 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2065 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2066 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2067 | var integer initial_rx_lvl := -1; |
| 2068 | var integer last_rx_lvl := -1; |
| 2069 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2070 | |
| 2071 | timer T := 2.0; |
| 2072 | alt { |
| 2073 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2074 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2075 | log("Received rx_level=", rx_lvl); |
| 2076 | if (initial_rx_lvl == -1) { |
| 2077 | initial_rx_lvl := rx_lvl; |
| 2078 | last_rx_lvl := rx_lvl; |
| 2079 | |
| 2080 | /* Expect a somehow low value during first received messages */ |
| 2081 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2083 | log2str("Detected high initial tx power during ramp up: ", |
| 2084 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2085 | } |
| 2086 | } |
| 2087 | |
| 2088 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2089 | if (rx_lvl > max_rx_lvl) { |
| 2090 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2091 | log2str("Detected Tx power higher than full power: ", |
| 2092 | rx_lvl , " > ", max_rx_lvl)); |
| 2093 | } |
| 2094 | |
| 2095 | /* Make sure it never decreases, since we are rumping up */ |
| 2096 | if (last_rx_lvl > rx_lvl) { |
| 2097 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2098 | log2str("Detected Tx power decrease during ramp up: ", |
| 2099 | last_rx_lvl , " -> ", rx_lvl)); |
| 2100 | } |
| 2101 | |
| 2102 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2103 | /* We reached the maximum power, start timer and receive |
| 2104 | /* a few more to make sure we don't surpass it */ |
| 2105 | log("Reached full power, wating a bit more until success"); |
| 2106 | T.start; |
| 2107 | } |
| 2108 | |
| 2109 | last_rx_lvl := rx_lvl; |
| 2110 | repeat; |
| 2111 | } |
| 2112 | [] L1CTL.receive { repeat; } |
| 2113 | [] T.timeout { } |
| 2114 | } |
| 2115 | |
| 2116 | /* We didn't increase tx power during ramp up */ |
| 2117 | if (initial_rx_lvl < last_rx_lvl) { |
| 2118 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2119 | } else { |
| 2120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2121 | log2str("No Tx power increase during whole ramp up: ", |
| 2122 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2123 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | /* verify BTS ramps power down to rx_level 0 */ |
| 2127 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2128 | var L1ctlDlMessage l1_dl; |
| 2129 | var integer last_rx_lvl := max_rx_lvl; |
| 2130 | |
| 2131 | timer Tdown := 5.0; |
| 2132 | Tdown.start; |
| 2133 | alt { |
| 2134 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2135 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2136 | log("Received rx_level=", rx_lvl); |
| 2137 | |
| 2138 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2139 | if (rx_lvl > max_rx_lvl) { |
| 2140 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2141 | log2str("Detected Tx power higher than full power: ", |
| 2142 | rx_lvl , " > ", max_rx_lvl)); |
| 2143 | } |
| 2144 | |
| 2145 | /* Make sure it never increases, since we are rumping down */ |
| 2146 | if (last_rx_lvl < rx_lvl) { |
| 2147 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2148 | log2str("Detected Tx power increase during ramp up: ", |
| 2149 | last_rx_lvl , " -> ", rx_lvl)); |
| 2150 | } |
| 2151 | |
| 2152 | last_rx_lvl := rx_lvl; |
| 2153 | if (last_rx_lvl != 0) { |
| 2154 | repeat; |
| 2155 | } |
| 2156 | /* we reached power level 0, we are done */ |
| 2157 | Tdown.stop; |
| 2158 | } |
| 2159 | [] L1CTL.receive { repeat; } |
| 2160 | [] Tdown.timeout { } |
| 2161 | } |
| 2162 | |
| 2163 | /* We didn't increase tx power during ramp down */ |
| 2164 | if (max_rx_lvl > last_rx_lvl) { |
| 2165 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2166 | } else { |
| 2167 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2168 | log2str("No Tx power decrease during whole ramp down: ", |
| 2169 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2170 | } |
| 2171 | } |
| 2172 | |
| 2173 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2174 | private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2175 | f_l1_tune(L1CTL); |
| 2176 | RSL.clear; |
| 2177 | |
| 2178 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2179 | |
| 2180 | setverdict(pass); |
| 2181 | } |
| 2182 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2183 | var ConnHdlr vc_conn; |
| 2184 | var ConnHdlrPars pars; |
| 2185 | f_init(); |
| 2186 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2187 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2188 | pcu_comp := false, trxc_comp := true); |
| 2189 | vc_conn.done; |
| 2190 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2191 | } |
| 2192 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2193 | /* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2194 | private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2195 | f_connhdlr_init_vty_bsc(); |
| 2196 | |
| 2197 | f_l1_tune(L1CTL); |
| 2198 | RSL.clear; |
| 2199 | |
| 2200 | /* Wait until BTS is started and at full power */ |
| 2201 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2202 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2203 | |
| 2204 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2205 | f_verify_ramp_down(max_rx_lvl); |
| 2206 | |
| 2207 | setverdict(pass); |
| 2208 | } |
| 2209 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2210 | var ConnHdlr vc_conn; |
| 2211 | var ConnHdlrPars pars; |
| 2212 | f_init(); |
| 2213 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2214 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2215 | pcu_comp := false, trxc_comp := true); |
| 2216 | vc_conn.done; |
| 2217 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2218 | } |
| 2219 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2220 | /* Verify Tx power: |
| 2221 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2222 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2223 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2224 | private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2225 | var L1ctlDlMessage l1_dl; |
| 2226 | var integer last_rx_lvl; |
| 2227 | |
| 2228 | f_connhdlr_init_vty_bsc(); |
| 2229 | |
| 2230 | f_l1_tune(L1CTL); |
| 2231 | RSL.clear; |
| 2232 | |
| 2233 | /* Wait until BTS is started and at full power */ |
| 2234 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2235 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2236 | |
| 2237 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2238 | f_vty_enter_cfg_trx(BSCVTY); |
| 2239 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2240 | last_rx_lvl := max_rx_lvl; |
| 2241 | f_verify_ramp_down(max_rx_lvl); |
| 2242 | |
| 2243 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2244 | * anymore because scheduler has stopped after ramping down */ |
| 2245 | f_sleep(2.0); |
| 2246 | L1CTL.clear; |
| 2247 | timer Tlocked := 2.0; |
| 2248 | Tlocked.start; |
| 2249 | alt { |
| 2250 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2251 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2252 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2253 | } |
| 2254 | [] L1CTL.receive { repeat; } |
| 2255 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2256 | } |
| 2257 | |
| 2258 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2259 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2260 | f_verify_ramp_up(); |
| 2261 | setverdict(pass); |
| 2262 | } |
| 2263 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2264 | var ConnHdlr vc_conn; |
| 2265 | var ConnHdlrPars pars; |
| 2266 | f_init(); |
| 2267 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2268 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2269 | pcu_comp := false, trxc_comp := true); |
| 2270 | vc_conn.done; |
| 2271 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2272 | } |
| 2273 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2274 | private function f_check_meas_bs_power_level(integer level) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2275 | timer T := 8.0; |
| 2276 | T.start; |
| 2277 | var RSL_Message rsl; |
| 2278 | alt { |
| 2279 | [] as_l1_sacch(); |
| 2280 | [] L1CTL.receive { repeat; } |
| 2281 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2282 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2283 | setverdict(pass) |
| 2284 | } else { |
| 2285 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2286 | } |
| 2287 | } |
| 2288 | [] T.timeout { |
| 2289 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2290 | } |
| 2291 | } |
| 2292 | } |
| 2293 | |
| 2294 | /* see if the rsl meas res contains our expeced bs power level |
| 2295 | bs power set during assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2296 | private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2297 | f_l1_tune(L1CTL); |
| 2298 | RSL.clear; |
| 2299 | |
| 2300 | if (mp_bts_trxc_port != -1) { |
| 2301 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2302 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2303 | } |
| 2304 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2305 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2306 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2307 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2308 | |
| 2309 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2310 | |
| 2311 | f_check_meas_bs_power_level(pwr_var); |
| 2312 | |
| 2313 | f_rsl_chan_deact(); |
| 2314 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2315 | } |
| 2316 | |
| 2317 | /* see if the rsl meas res contains our expeced bs power level |
| 2318 | bs power set after assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2319 | private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr { |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2320 | f_l1_tune(L1CTL); |
| 2321 | RSL.clear; |
| 2322 | |
| 2323 | if (mp_bts_trxc_port != -1) { |
| 2324 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2325 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2326 | } |
| 2327 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2328 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2329 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2330 | |
| 2331 | f_est_dchan(); |
| 2332 | |
| 2333 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2334 | |
| 2335 | f_check_meas_bs_power_level(pwr_var); |
| 2336 | |
| 2337 | f_rsl_chan_deact(); |
| 2338 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2339 | } |
| 2340 | |
| 2341 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2342 | var ConnHdlr vc_conn; |
| 2343 | var ConnHdlrPars pars; |
| 2344 | f_init(); |
| 2345 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2346 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2347 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2348 | pcu_comp := false, trxc_comp := true); |
| 2349 | vc_conn.done; |
| 2350 | } |
| 2351 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2352 | } |
| 2353 | |
| 2354 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2355 | var ConnHdlr vc_conn; |
| 2356 | var ConnHdlrPars pars; |
| 2357 | f_init(); |
| 2358 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2359 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2360 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2361 | pcu_comp := false, trxc_comp := true); |
| 2362 | vc_conn.done; |
| 2363 | } |
| 2364 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2365 | } |
| 2366 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2367 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2368 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2369 | These power levels are valid for all bands and require no special handling */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2370 | private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2371 | var uint5_t pwr_var := 7; |
| 2372 | var L1ctlDlMessage l1_dl; |
| 2373 | |
| 2374 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2375 | f_l1_tune(L1CTL); |
| 2376 | RSL.clear; |
| 2377 | |
| 2378 | var RSL_IE_List addl_ies; |
| 2379 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2380 | |
| 2381 | addl_ies := { |
| 2382 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2383 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2384 | }; |
| 2385 | |
| 2386 | /* establish with power parameters */ |
| 2387 | f_est_dchan(more_ies := addl_ies); |
| 2388 | |
| 2389 | /* set a high value to ensure L1 power control level increases */ |
| 2390 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2391 | |
| 2392 | timer T2 := 6.0; |
| 2393 | T2.start; |
| 2394 | alt { |
| 2395 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2396 | /* Update sent MS power to follow what BTS requests */ |
| 2397 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2398 | if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2399 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2400 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2401 | T2.stop; |
| 2402 | } |
| 2403 | [] L1CTL.receive { repeat; } |
| 2404 | [] T2.timeout { |
| 2405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2406 | "Power Level in L1 header has not increased sufficiently"); |
| 2407 | } |
| 2408 | } |
| 2409 | |
| 2410 | /* set a low value to ensure L1 power control level decreases */ |
| 2411 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2412 | |
| 2413 | timer T4 := 6.0; |
| 2414 | T4.start; |
| 2415 | alt { |
| 2416 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2417 | /* Update sent MS power to follow what BTS requests */ |
| 2418 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2419 | if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2420 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2421 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2422 | T4.stop; |
| 2423 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2424 | } |
| 2425 | [] L1CTL.receive { repeat; } |
| 2426 | [] T4.timeout { |
| 2427 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2428 | "Power Level in L1 header has not decreased sufficiently"); |
| 2429 | } |
| 2430 | } |
| 2431 | |
| 2432 | f_rsl_chan_deact(); |
| 2433 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2434 | |
| 2435 | } |
| 2436 | |
| 2437 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2438 | private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2439 | var uint5_t pwr_var := 7; |
| 2440 | var L1ctlDlMessage l1_dl; |
| 2441 | |
| 2442 | /* set a low value to ensure power increases */ |
| 2443 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2444 | f_l1_tune(L1CTL); |
| 2445 | RSL.clear; |
| 2446 | |
| 2447 | var RSL_IE_List addl_ies; |
| 2448 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2449 | |
| 2450 | addl_ies := { |
| 2451 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2452 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2453 | }; |
| 2454 | |
| 2455 | /* establish with power parameters */ |
| 2456 | f_est_dchan(more_ies := addl_ies); |
| 2457 | |
| 2458 | timer T1 := 10.0; |
| 2459 | T1.start; |
| 2460 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2461 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2462 | /* Update sent MS power to follow what BTS requests */ |
| 2463 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2464 | repeat; |
| 2465 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2466 | [] L1CTL.receive { repeat; } |
| 2467 | [] T1.timeout { |
| 2468 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2469 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2470 | } |
| 2471 | } |
| 2472 | } |
| 2473 | |
| 2474 | f_rsl_chan_deact(); |
| 2475 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2476 | |
| 2477 | } |
| 2478 | |
| 2479 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2480 | private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2481 | var L1ctlDlMessage l1_dl; |
| 2482 | var uint5_t pwr_var := 15; |
| 2483 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2484 | |
| 2485 | /* set a low value to ensure power increases */ |
| 2486 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2487 | f_l1_tune(L1CTL); |
| 2488 | RSL.clear; |
| 2489 | |
| 2490 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2491 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2492 | |
| 2493 | /* establish with fixed power level */ |
| 2494 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2495 | |
| 2496 | /* check our initial power level */ |
| 2497 | f_wait_for_l1_power_level(pwr_var); |
| 2498 | |
| 2499 | /* update power param to enable power loop |
| 2500 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2501 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2502 | |
| 2503 | /* wait, then check that our power level was reduced */ |
| 2504 | timer T1 := 10.0; |
| 2505 | T1.start; |
| 2506 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2507 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2508 | /* Update sent MS power to follow what BTS requests */ |
| 2509 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2510 | repeat; |
| 2511 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2512 | [] L1CTL.receive { repeat; } |
| 2513 | [] T1.timeout { |
| 2514 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2515 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2516 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2517 | } else { |
| 2518 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2519 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2520 | } |
| 2521 | } |
| 2522 | } |
| 2523 | |
| 2524 | f_rsl_chan_deact(); |
| 2525 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2526 | |
| 2527 | } |
| 2528 | |
| 2529 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2530 | private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2531 | var L1ctlDlMessage l1_dl; |
| 2532 | |
| 2533 | /* set a high value to ensure power decreases */ |
| 2534 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2535 | f_l1_tune(L1CTL); |
| 2536 | RSL.clear; |
| 2537 | |
| 2538 | var uint5_t pwr_var := 5; |
| 2539 | var uint5_t pwr_target_val := 15; |
| 2540 | |
| 2541 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2542 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2543 | |
| 2544 | /* establish with fixed power level */ |
| 2545 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2546 | |
| 2547 | /* check our initial power level */ |
| 2548 | f_wait_for_l1_power_level(pwr_var); |
| 2549 | |
| 2550 | /* update power param to enable power loop |
| 2551 | as per spec the supplied ms power IE should set the max allowed power...*/ |
Pau Espin Pedrol | 61122c8 | 2019-11-05 13:50:27 +0100 | [diff] [blame] | 2552 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val)); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2553 | |
| 2554 | /* wait, then check that our power level was increased */ |
| 2555 | timer T1 := 10.0; |
| 2556 | T1.start; |
| 2557 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2558 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2559 | /* Update sent MS power to follow what BTS requests */ |
| 2560 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2561 | repeat; |
| 2562 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2563 | [] L1CTL.receive { repeat; } |
| 2564 | [] T1.timeout { |
| 2565 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2566 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2567 | } else { |
| 2568 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2569 | "Power level in L1 header NOT increased to lowest power value"); |
| 2570 | } |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | f_rsl_chan_deact(); |
| 2575 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2576 | |
| 2577 | } |
| 2578 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2579 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2580 | rsl chan act WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2581 | private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2582 | var L1ctlDlMessage l1_dl; |
| 2583 | |
| 2584 | /* set a high value to ensure power decreases */ |
| 2585 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2586 | f_l1_tune(L1CTL); |
| 2587 | RSL.clear; |
| 2588 | |
| 2589 | var uint5_t pwr_var := 5; |
| 2590 | |
| 2591 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2592 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2593 | |
| 2594 | /* establish with fixed power level */ |
| 2595 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2596 | |
| 2597 | /* check our initial power level */ |
| 2598 | f_wait_for_l1_power_level(pwr_var); |
| 2599 | |
| 2600 | /* wait, then check that our power level did not change */ |
| 2601 | timer T1 := 10.0; |
| 2602 | T1.start; |
| 2603 | alt { |
| 2604 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2605 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2606 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2607 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2608 | } |
| 2609 | repeat; |
| 2610 | } |
| 2611 | [] L1CTL.receive { repeat; } |
| 2612 | [] T1.timeout { setverdict(pass); } |
| 2613 | } |
| 2614 | |
| 2615 | f_rsl_chan_deact(); |
| 2616 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2617 | |
| 2618 | } |
| 2619 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2620 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2621 | ms power control WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2622 | private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2623 | var L1ctlDlMessage l1_dl; |
| 2624 | |
| 2625 | /* set a high value to ensure power decreases */ |
| 2626 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2627 | f_l1_tune(L1CTL); |
| 2628 | RSL.clear; |
| 2629 | |
| 2630 | var uint5_t pwr_var := 5; |
| 2631 | |
| 2632 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2633 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2634 | |
| 2635 | /* establish with fixed power level */ |
| 2636 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2637 | |
| 2638 | /* check our initial power level */ |
| 2639 | f_wait_for_l1_power_level(pwr_var); |
| 2640 | |
| 2641 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2642 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2643 | |
| 2644 | /* wait, then check that our power level did not change */ |
| 2645 | timer T1 := 10.0; |
| 2646 | T1.start; |
| 2647 | alt { |
| 2648 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2649 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2650 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2651 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2652 | } |
| 2653 | repeat; |
| 2654 | } |
| 2655 | [] L1CTL.receive { repeat; } |
| 2656 | [] T1.timeout { setverdict(pass); } |
| 2657 | } |
| 2658 | |
| 2659 | f_rsl_chan_deact(); |
| 2660 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2661 | |
| 2662 | } |
| 2663 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2664 | private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2665 | var L1ctlDlMessage l1_dl; |
| 2666 | timer T0 := 10.0; |
| 2667 | T0.start; |
| 2668 | alt { |
| 2669 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2670 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2671 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2672 | "Power level in L1 header != signaled (RSL) power level."); |
| 2673 | } |
| 2674 | } |
| 2675 | [] L1CTL.receive { repeat; } |
| 2676 | [] T0.timeout { |
| 2677 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2678 | "Timeout waiting for initial power level"); |
| 2679 | } |
| 2680 | } |
| 2681 | T0.stop; |
| 2682 | } |
| 2683 | |
| 2684 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2685 | var IntegerRecord min_dbm_level; |
| 2686 | var IntegerRecord max_dbm_level; |
| 2687 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2688 | |
| 2689 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2690 | if (min_dbm_level[i] == level) { |
| 2691 | return true; |
| 2692 | } |
| 2693 | } |
| 2694 | return false; |
| 2695 | } |
| 2696 | |
| 2697 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2698 | var IntegerRecord min_dbm_level; |
| 2699 | var IntegerRecord max_dbm_level; |
| 2700 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2701 | |
| 2702 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2703 | if (max_dbm_level[i] == level) { |
| 2704 | return true; |
| 2705 | } |
| 2706 | } |
| 2707 | return false; |
| 2708 | } |
| 2709 | |
| 2710 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2711 | var IntegerRecord min_dbm_level; |
| 2712 | var IntegerRecord max_dbm_level; |
| 2713 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2714 | return max_dbm_level[0]; |
| 2715 | } |
| 2716 | |
| 2717 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2718 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2719 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2720 | // 45.005 4.1.1 |
| 2721 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2722 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2723 | 2, 1, 0}; |
| 2724 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2725 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2726 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2727 | var IntegerRecord rv; |
| 2728 | |
| 2729 | select(band){ |
| 2730 | case (BtsBand_allGSM){ |
| 2731 | rv := gsm_power; |
| 2732 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2733 | max_dbm_level := {2, 1, 0}; |
| 2734 | } |
| 2735 | case("DCS1800"){ |
| 2736 | rv := dcs_power; |
| 2737 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2738 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2739 | } |
| 2740 | case("PCS1900"){ |
| 2741 | rv := pcs_power; |
| 2742 | min_dbm_level := {15}; |
| 2743 | max_dbm_level := {30}; |
| 2744 | } |
| 2745 | } |
| 2746 | |
| 2747 | return rv; |
| 2748 | } |
| 2749 | |
| 2750 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
| 2751 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0); |
| 2752 | } |
| 2753 | |
| 2754 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2755 | var ConnHdlr vc_conn; |
| 2756 | var ConnHdlrPars pars; |
| 2757 | f_init(); |
| 2758 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2759 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2760 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2761 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2762 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2763 | vc_conn.done; |
| 2764 | } |
| 2765 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2766 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2767 | } |
| 2768 | |
| 2769 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2770 | var ConnHdlr vc_conn; |
| 2771 | var ConnHdlrPars pars; |
| 2772 | f_init(); |
| 2773 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2774 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2775 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2776 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2777 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2778 | vc_conn.done; |
| 2779 | } |
| 2780 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2781 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2782 | } |
| 2783 | |
| 2784 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2785 | var ConnHdlr vc_conn; |
| 2786 | var ConnHdlrPars pars; |
| 2787 | f_init(); |
| 2788 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2789 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2790 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2791 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2792 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2793 | vc_conn.done; |
| 2794 | } |
| 2795 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2796 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2797 | } |
| 2798 | |
| 2799 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2800 | var ConnHdlr vc_conn; |
| 2801 | var ConnHdlrPars pars; |
| 2802 | f_init(); |
| 2803 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2804 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2805 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2806 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2807 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2808 | vc_conn.done; |
| 2809 | } |
| 2810 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2811 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2812 | } |
| 2813 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2814 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2815 | var ConnHdlr vc_conn; |
| 2816 | var ConnHdlrPars pars; |
| 2817 | f_init(); |
| 2818 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2819 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2820 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2821 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2822 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2823 | vc_conn.done; |
| 2824 | } |
| 2825 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2826 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2827 | } |
| 2828 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2829 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2830 | var ConnHdlr vc_conn; |
| 2831 | var ConnHdlrPars pars; |
| 2832 | f_init(); |
| 2833 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2834 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2835 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2836 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2837 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2838 | vc_conn.done; |
| 2839 | } |
| 2840 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2841 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2842 | } |
| 2843 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2844 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 2845 | var ConnHdlr vc_conn; |
| 2846 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2847 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2848 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2849 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2850 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2851 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2852 | vc_conn.done; |
| 2853 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2854 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2855 | } |
| 2856 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 2857 | var ConnHdlr vc_conn; |
| 2858 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2859 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2860 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2861 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2862 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2863 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2864 | vc_conn.done; |
| 2865 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2866 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2867 | } |
| 2868 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 2869 | var ConnHdlr vc_conn; |
| 2870 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2871 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2872 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 2873 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2874 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2875 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2876 | vc_conn.done; |
| 2877 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2878 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2879 | } |
| 2880 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 2881 | var ConnHdlr vc_conn; |
| 2882 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2883 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2884 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 2885 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2886 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2887 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2888 | vc_conn.done; |
| 2889 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2890 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2891 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2892 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 2893 | var ConnHdlr vc_conn; |
| 2894 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2895 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2896 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 2897 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2898 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 2899 | pars.l1_pars.toa256_enabled := true; |
| 2900 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 2901 | vc_conn.done; |
| 2902 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2903 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2904 | } |
| 2905 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2906 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 2907 | * the BTS is forwarding those values to the MS via the SACCH L1 header. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2908 | private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2909 | var L1ctlDlMessage l1_dl; |
| 2910 | var RSL_IE_MS_Power ms_power; |
| 2911 | var RSL_Message rsl; |
| 2912 | var uint5_t power_level := 0; |
| 2913 | |
| 2914 | f_l1_tune(L1CTL); |
| 2915 | RSL.clear; |
| 2916 | |
| 2917 | f_est_dchan(); |
| 2918 | |
| 2919 | ms_power.reserved := 0; |
| 2920 | ms_power.fpc_epc := false; |
| 2921 | |
| 2922 | /* Send the first power control command. This will disable any BTS/TRX |
| 2923 | * internal power control and switch the MS (which is not in scope of |
| 2924 | * this test) to a constant power level. We start with a power level |
| 2925 | * of 0 */ |
| 2926 | ms_power.power_level := power_level; |
| 2927 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2928 | RSL.send(rsl); |
| 2929 | |
| 2930 | alt { |
| 2931 | |
| 2932 | /* Pick all SACCH blocks for checking */ |
| 2933 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2934 | |
| 2935 | /* The first byte of the L1 header contains the power level. |
| 2936 | * The reserved bits and the fpc bit is set to 0, so we may |
| 2937 | * compare directly. */ |
| 2938 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 2939 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 2940 | } |
| 2941 | |
| 2942 | /* Signal a new power level via RSL for the next turn. */ |
| 2943 | if (power_level < 31) { |
| 2944 | power_level := power_level + 1; |
| 2945 | ms_power.power_level := power_level; |
| 2946 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2947 | RSL.send(rsl); |
| 2948 | repeat; |
| 2949 | } |
| 2950 | |
| 2951 | } |
| 2952 | |
| 2953 | /* Ignore all other blocks */ |
| 2954 | [] L1CTL.receive { repeat; } |
| 2955 | |
| 2956 | } |
| 2957 | |
| 2958 | f_rsl_chan_deact(); |
| 2959 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2960 | |
| 2961 | setverdict(pass); |
| 2962 | } |
| 2963 | |
| 2964 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 2965 | var ConnHdlr vc_conn; |
| 2966 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2967 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2968 | |
| 2969 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2970 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2971 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 2972 | vc_conn.done; |
| 2973 | } |
| 2974 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2975 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2976 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 2977 | /* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header. |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2978 | TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2979 | private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2980 | var L1ctlDlMessage l1_dl; |
| 2981 | var uint5_t ta_to_test := 16; |
| 2982 | |
| 2983 | |
| 2984 | f_l1_tune(L1CTL); |
| 2985 | RSL.clear; |
| 2986 | |
| 2987 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2988 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2989 | |
| 2990 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 2991 | |
| 2992 | |
| 2993 | alt { |
| 2994 | |
| 2995 | /* Pick all SACCH blocks for checking */ |
| 2996 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2997 | |
| 2998 | /* The second byte of the L1 header contains the TA. */ |
| 2999 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 3000 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3001 | } |
| 3002 | |
| 3003 | } |
| 3004 | |
| 3005 | /* Ignore all other blocks */ |
| 3006 | [] L1CTL.receive { repeat; } |
| 3007 | |
| 3008 | } |
| 3009 | |
| 3010 | f_rsl_chan_deact(); |
| 3011 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3012 | |
| 3013 | setverdict(pass); |
| 3014 | } |
| 3015 | |
| 3016 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3017 | var ConnHdlr vc_conn; |
| 3018 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3019 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3020 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3021 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3022 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3023 | vc_conn.done; |
| 3024 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3025 | } |
| 3026 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3027 | /* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3028 | private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr { |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3029 | var L1ctlDlMessage l1_dl; |
| 3030 | var uint5_t ms_power_level := 7; |
| 3031 | |
| 3032 | var RSL_IE_MS_Power ms_power; |
| 3033 | ms_power.reserved := 0; |
| 3034 | ms_power.fpc_epc := false; |
| 3035 | ms_power.power_level := ms_power_level; |
| 3036 | |
| 3037 | f_l1_tune(L1CTL); |
| 3038 | RSL.clear; |
| 3039 | |
| 3040 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3041 | |
| 3042 | timer T := 1.0; |
| 3043 | T.start; |
| 3044 | alt { |
| 3045 | /* Pick all SACCH blocks for checking */ |
| 3046 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3047 | /* The first byte of the L1 header contains the power level.. */ |
| 3048 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 3049 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3050 | } |
| 3051 | } |
| 3052 | /* Ignore all other blocks */ |
| 3053 | [] L1CTL.receive { repeat; } |
| 3054 | [] T.timeout { |
| 3055 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3056 | } |
| 3057 | } |
| 3058 | |
| 3059 | f_rsl_chan_deact(); |
| 3060 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3061 | setverdict(pass); |
| 3062 | } |
| 3063 | |
| 3064 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3065 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3066 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3067 | } |
| 3068 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3069 | /* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND (TS 48.058 4.10) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3070 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3071 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3072 | RSL.clear; |
| 3073 | |
| 3074 | f_est_dchan(); |
| 3075 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3076 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3077 | |
| 3078 | timer T := 40.0; |
| 3079 | T.start; |
| 3080 | alt { |
| 3081 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3082 | setverdict(pass) |
| 3083 | } |
| 3084 | [] RSL.receive { repeat }; |
| 3085 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3086 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3087 | } |
| 3088 | } |
| 3089 | f_rsl_chan_deact(); |
| 3090 | } |
| 3091 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3092 | var ConnHdlr vc_conn; |
| 3093 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3094 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3095 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3096 | pars.t_guard := 60.0; |
| 3097 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3098 | vc_conn.done; |
| 3099 | } |
| 3100 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3101 | /*********************************************************************** |
| 3102 | * Paging |
| 3103 | ***********************************************************************/ |
| 3104 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3105 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3106 | if (tmsi == 'FFFFFFFF'O) { |
| 3107 | return true; |
| 3108 | } else { |
| 3109 | return false; |
| 3110 | } |
| 3111 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3112 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3113 | private type record allowedFn { integer frame_nr } |
| 3114 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3115 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3116 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3117 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3118 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3119 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3120 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3121 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3122 | private function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3123 | { |
| 3124 | var integer frame_nr_51; |
| 3125 | frame_nr_51 := frame_nr mod 51 |
| 3126 | |
| 3127 | var allowedFn fn_check; |
| 3128 | fn_check.frame_nr := frame_nr_51; |
| 3129 | |
| 3130 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3131 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3132 | return; |
| 3133 | } |
| 3134 | |
| 3135 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3136 | return; |
| 3137 | } |
| 3138 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3139 | return; |
| 3140 | } |
| 3141 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3142 | return; |
| 3143 | } |
| 3144 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3145 | return; |
| 3146 | } |
| 3147 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3148 | return; |
| 3149 | } |
| 3150 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3151 | return; |
| 3152 | } |
| 3153 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3154 | return; |
| 3155 | } |
| 3156 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3157 | return; |
| 3158 | } |
| 3159 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3160 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3161 | return; |
| 3162 | } |
| 3163 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3164 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3165 | inout integer num_paging_rcv_ids, |
| 3166 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3167 | runs on test_CT { |
| 3168 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3169 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3170 | repeat; |
| 3171 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3172 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3173 | var octetstring without_plen := |
| 3174 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3175 | var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3176 | |
| 3177 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3178 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3179 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3180 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3181 | * TODO: does it make sense to count them? */ |
| 3182 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3183 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3184 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3185 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3186 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3187 | } |
| 3188 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3189 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3190 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3191 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3192 | } |
| 3193 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3194 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3195 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3196 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3197 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3198 | } |
| 3199 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3200 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3201 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3202 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3203 | } |
| 3204 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3205 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3206 | } |
| 3207 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3208 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3209 | } |
| 3210 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3211 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3212 | } |
| 3213 | } |
| 3214 | repeat; |
| 3215 | } |
| 3216 | } |
| 3217 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3218 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3219 | boolean combined_ccch, |
| 3220 | integer bs_ag_blks_res, |
| 3221 | float load_factor, |
| 3222 | boolean exp_load_ind, |
| 3223 | boolean exp_overload, |
| 3224 | boolean use_tmsi |
| 3225 | } |
| 3226 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3227 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3228 | integer num_paging_sent, |
| 3229 | integer num_paging_rcv_msgs, |
| 3230 | integer num_paging_rcv_ids, |
| 3231 | integer num_overload |
| 3232 | } |
| 3233 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3234 | /* Helper function for paging related testing */ |
| 3235 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3236 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3237 | f_init_l1ctl(); |
| 3238 | f_l1_tune(L1CTL); |
| 3239 | |
| 3240 | var PagingTestState st := { |
| 3241 | num_paging_sent := 0, |
| 3242 | num_paging_rcv_msgs := 0, |
| 3243 | num_paging_rcv_ids := 0, |
| 3244 | num_overload := 0 |
| 3245 | }; |
| 3246 | |
| 3247 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3248 | var float max_pch_imsi_per_sec; |
| 3249 | if (cfg.use_tmsi) { |
| 3250 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3251 | } else { |
| 3252 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3253 | } |
| 3254 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3255 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3256 | var float time_total := 20.0; |
| 3257 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3258 | log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3259 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3260 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3261 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3262 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3263 | timer T_itv := 0.0; |
| 3264 | T_itv.start; |
| 3265 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3266 | alt { |
| 3267 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3268 | [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3269 | st.num_overload := st.num_overload + 1; |
| 3270 | repeat; |
| 3271 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3272 | [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3273 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3274 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3275 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3276 | log("Rx LOAD_IND"); |
| 3277 | /* FIXME: analyze/verify interval + contents */ |
| 3278 | repeat; |
| 3279 | } |
| 3280 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3281 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3282 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3283 | [] T_itv.timeout { |
| 3284 | /* Send paging cmds based on elapsed time */ |
| 3285 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3286 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3287 | var MobileIdentityV mi; |
| 3288 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3289 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3290 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3291 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3292 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3293 | mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3294 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3295 | |
| 3296 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3297 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3298 | |
| 3299 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3300 | } |
| 3301 | if (st.num_paging_sent < pkt_total) { |
| 3302 | /* Wait for interval to next PAGING COMMAND */ |
| 3303 | var float time_now := T_total.read; |
| 3304 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3305 | if (next_sched > time_now) { |
| 3306 | T_itv.start(next_sched - time_now); |
| 3307 | } else { |
| 3308 | T_itv.start(0.0); |
| 3309 | } |
| 3310 | } else { |
| 3311 | /* We are done, no need to keep counting */ |
| 3312 | T_total.stop; |
| 3313 | } |
| 3314 | } |
| 3315 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3316 | } |
| 3317 | } |
| 3318 | |
| 3319 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3320 | timer T_wait := 18.0; |
| 3321 | T_wait.start; |
| 3322 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3323 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3324 | [] L1CTL.receive { repeat; } |
| 3325 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3326 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3327 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3328 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3329 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3330 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3331 | } |
| 3332 | |
| 3333 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3334 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3335 | return st; |
| 3336 | } |
| 3337 | |
| 3338 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3339 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3340 | * - that CCCH LOAD IND (PCH) are being generated |
| 3341 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3342 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3343 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3344 | var PagingTestCfg cfg := { |
| 3345 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3346 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3347 | load_factor := 0.8, |
| 3348 | exp_load_ind := true, |
| 3349 | exp_overload := false, |
| 3350 | use_tmsi := false |
| 3351 | }; |
| 3352 | var PagingTestState st := f_TC_paging(cfg); |
| 3353 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3354 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3355 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3356 | } else { |
| 3357 | setverdict(pass); |
| 3358 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3359 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3360 | } |
| 3361 | |
| 3362 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3363 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3364 | * - that CCCH LOAD IND (PCH) are being generated |
| 3365 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3366 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3367 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3368 | var PagingTestCfg cfg := { |
| 3369 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3370 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3371 | load_factor := 0.8, |
| 3372 | exp_load_ind := true, |
| 3373 | exp_overload := false, |
| 3374 | use_tmsi := true |
| 3375 | }; |
| 3376 | var PagingTestState st := f_TC_paging(cfg); |
| 3377 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3378 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3379 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3380 | } else { |
| 3381 | setverdict(pass); |
| 3382 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3383 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3384 | } |
| 3385 | |
| 3386 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3387 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3388 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3389 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3390 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3391 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3392 | var PagingTestCfg cfg := { |
| 3393 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3394 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3395 | load_factor := 2.0, |
| 3396 | exp_load_ind := true, |
| 3397 | exp_overload := true, |
| 3398 | use_tmsi := false |
| 3399 | }; |
| 3400 | var PagingTestState st := f_TC_paging(cfg); |
| 3401 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3402 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3403 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3404 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3406 | } else { |
| 3407 | setverdict(pass); |
| 3408 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3409 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3410 | } |
| 3411 | |
| 3412 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3413 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3414 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3415 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3416 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3417 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3418 | var PagingTestCfg cfg := { |
| 3419 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3420 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3421 | load_factor := 2.0, |
| 3422 | exp_load_ind := true, |
| 3423 | exp_overload := true, |
| 3424 | use_tmsi := true |
| 3425 | }; |
| 3426 | var PagingTestState st := f_TC_paging(cfg); |
| 3427 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3428 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3429 | var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3430 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3431 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3432 | } else { |
| 3433 | setverdict(pass); |
| 3434 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3435 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3436 | } |
| 3437 | |
| 3438 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3439 | /*********************************************************************** |
| 3440 | * Immediate Assignment / AGCH |
| 3441 | ***********************************************************************/ |
Vadim Yanitskiy | a9eeb7b | 2020-05-27 01:42:49 +0700 | [diff] [blame] | 3442 | private const MobileAllocation c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3443 | len := 0, |
| 3444 | ma := ''B |
| 3445 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3446 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3447 | private template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, |
| 3448 | template (value) uint3_t tsc := 7, |
| 3449 | template (value) uint12_t arfcn := mp_trx0_arfcn) := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3450 | chan_nr := chan_nr, |
| 3451 | tsc := tsc, |
| 3452 | h := false, |
| 3453 | arfcn := arfcn, |
| 3454 | maio_hsn := omit |
| 3455 | } |
| 3456 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3457 | private template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, |
| 3458 | template (value) uint3_t tsc := 7, |
| 3459 | template (value) MaioHsn maio_hsn) := { |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3460 | chan_nr := chan_nr, |
| 3461 | tsc := tsc, |
| 3462 | h := true, |
| 3463 | arfcn := omit, |
| 3464 | maio_hsn := maio_hsn |
| 3465 | } |
| 3466 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3467 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3468 | return int2str(num_tx) & " sent, " |
| 3469 | & int2str(num_rx) & " received, " |
| 3470 | & int2str(num_del) & " deleted"; |
| 3471 | } |
| 3472 | |
| 3473 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3474 | var L1ctlDlMessage l1_dl; |
| 3475 | timer T := 10.0; |
| 3476 | var integer num_tx := 0; |
| 3477 | var integer num_rx := 0; |
| 3478 | var integer num_del := 0; |
| 3479 | var charstring res_str; |
| 3480 | var float rx_ratio; |
| 3481 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3482 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3483 | f_init_l1ctl(); |
| 3484 | f_l1_tune(L1CTL); |
| 3485 | |
| 3486 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3487 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(valueof(t_RslChanNr_SDCCH4(0, 0)))); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3488 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3489 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3490 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0))); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3491 | num_tx := num_tx+1; |
| 3492 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3493 | } |
| 3494 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3495 | T.start; |
| 3496 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3497 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3498 | num_del := num_del+1; |
| 3499 | repeat; |
| 3500 | } |
| 3501 | [] RSL_CCHAN.receive { |
| 3502 | repeat; |
| 3503 | } |
| 3504 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
| 3505 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3506 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3507 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3508 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3509 | //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3510 | } else { |
| 3511 | num_rx := num_rx+1; |
| 3512 | } |
| 3513 | repeat; |
| 3514 | } |
| 3515 | [] L1CTL.receive { repeat; } |
| 3516 | [] T.timeout { } |
| 3517 | } |
| 3518 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3519 | log("AGCH test: " & res_str); |
| 3520 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3521 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3522 | } |
| 3523 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3524 | if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3525 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3526 | } else { |
| 3527 | setverdict(pass); |
| 3528 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3529 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3530 | } |
| 3531 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3532 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3533 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3534 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3535 | } |
| 3536 | |
| 3537 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3538 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3539 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3540 | } |
| 3541 | |
| 3542 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3543 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3544 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3545 | } |
| 3546 | |
| 3547 | |
| 3548 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3549 | /*********************************************************************** |
| 3550 | * BCCH |
| 3551 | ***********************************************************************/ |
| 3552 | |
| 3553 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3554 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3555 | GsmFrameNumber frame_number, |
| 3556 | SystemInformation si |
| 3557 | } |
| 3558 | |
| 3559 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3560 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3561 | |
| 3562 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3563 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3564 | |
| 3565 | /* determine if a given SI vector contains given SI type at least once */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3566 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 3567 | RrMessageType key, |
| 3568 | boolean bcch_ext := false) |
| 3569 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3570 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3571 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3572 | if (not bcch_ext and fn_mod51 == 2 or |
| 3573 | bcch_ext and fn_mod51 == 6) { |
| 3574 | if (arr[i].si.header.message_type == key) { |
| 3575 | return true; |
| 3576 | } |
| 3577 | } |
| 3578 | } |
| 3579 | return false; |
| 3580 | } |
| 3581 | |
| 3582 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3583 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3584 | integer tc, RrMessageType key, |
| 3585 | boolean ext_bcch := false) |
| 3586 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3587 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3588 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!")); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3589 | } |
| 3590 | } |
| 3591 | |
| 3592 | /* check if a given SI vector contains given SI type at least once on any TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3593 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3594 | RrMessageType key) |
| 3595 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3596 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3597 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3598 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3599 | return true; |
| 3600 | } |
| 3601 | } |
| 3602 | return false; |
| 3603 | } |
| 3604 | |
| 3605 | /* determine if a given SI vector contains given SI type at least N of M times */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3606 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 3607 | RrMessageType key, |
| 3608 | boolean bcch_ext := false, |
| 3609 | integer n := 1, integer m := 4) |
| 3610 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3611 | var integer count := 0; |
| 3612 | if (sizeof(arr) < m) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3613 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3614 | } |
| 3615 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3616 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3617 | if (not bcch_ext and fn_mod51 == 2 or |
| 3618 | bcch_ext and fn_mod51 == 6) { |
| 3619 | if (arr[i].si.header.message_type == key) { |
| 3620 | count := count + 1; |
| 3621 | } |
| 3622 | } |
| 3623 | } |
| 3624 | if (count >= n) { |
| 3625 | return true; |
| 3626 | } else { |
| 3627 | return false; |
| 3628 | } |
| 3629 | } |
| 3630 | |
| 3631 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3632 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 3633 | integer tc, RrMessageType key, |
| 3634 | boolean ext_bcch := false, |
| 3635 | integer n, integer m) |
| 3636 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3637 | if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3638 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!")); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3639 | } |
| 3640 | } |
| 3641 | |
| 3642 | /* determine if a given SI vector contains given SI type at least once */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3643 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 3644 | RrMessageType key, |
| 3645 | boolean bcch_ext := false) |
| 3646 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3647 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3648 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3649 | if (not bcch_ext and fn_mod51 == 2 or |
| 3650 | bcch_ext and fn_mod51 == 6) { |
| 3651 | if (arr[i].si.header.message_type != key) { |
| 3652 | return false; |
| 3653 | } |
| 3654 | } |
| 3655 | } |
| 3656 | return true; |
| 3657 | } |
| 3658 | |
| 3659 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3660 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 3661 | integer tc, RrMessageType key, |
| 3662 | boolean ext_bcch := false) |
| 3663 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3664 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3665 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!")); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3666 | } |
| 3667 | } |
| 3668 | |
| 3669 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3670 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3671 | boolean bcch_extended, |
| 3672 | boolean si1_present, |
| 3673 | boolean si2bis_present, |
| 3674 | boolean si2ter_present, |
| 3675 | boolean si2quater_present, |
| 3676 | boolean si7_present, |
| 3677 | boolean si8_present, |
| 3678 | boolean si9_present, |
| 3679 | boolean si13_present, |
| 3680 | boolean si13alt_present, |
| 3681 | boolean si15_present, |
| 3682 | boolean si16_present, |
| 3683 | boolean si17_present, |
| 3684 | boolean si2n_present, |
| 3685 | boolean si21_present, |
| 3686 | boolean si22_present |
| 3687 | } |
| 3688 | |
| 3689 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3690 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 3691 | SystemInformationVectorPerTc si_per_tc) |
| 3692 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3693 | var integer i; |
| 3694 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3695 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3696 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3697 | } |
| 3698 | } |
| 3699 | if (cfg.si1_present) { |
| 3700 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3701 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3702 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3703 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3704 | /* make sure *ALL* contain SI1 */ |
| 3705 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3706 | } |
| 3707 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3708 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3709 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3710 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3711 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3712 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3713 | |
| 3714 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3715 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3716 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3717 | * consecutive occurrences of TC = 4. */ |
| 3718 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3719 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3720 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3721 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3722 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3723 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3724 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3725 | } |
| 3726 | |
| 3727 | if (cfg.si7_present or cfg.si8_present) { |
| 3728 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3729 | * if System Information type 4 does not contain all information needed for cell |
| 3730 | * selection and reselection. */ |
| 3731 | if (not cfg.bcch_extended) { |
| 3732 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3733 | } |
| 3734 | if (cfg.si7_present) { |
| 3735 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3736 | } |
| 3737 | if (cfg.si8_present) { |
| 3738 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3739 | } |
| 3740 | } |
| 3741 | |
| 3742 | if (cfg.si2quater_present) { |
| 3743 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3744 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3745 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3746 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3747 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3748 | if (not (cfg.bcch_extended)) { |
| 3749 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3750 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3751 | } else { |
| 3752 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3753 | } |
| 3754 | } else { |
| 3755 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3756 | } |
| 3757 | } |
| 3758 | if (cfg.si9_present) { |
| 3759 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3760 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3761 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3762 | } |
| 3763 | if (cfg.si13_present) { |
| 3764 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3765 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3766 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3767 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3768 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3769 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3770 | if (not cfg.bcch_extended) { |
| 3771 | log("not-bccch-extended"); |
| 3772 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3773 | } else { |
| 3774 | log("bccch-extended"); |
| 3775 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3776 | } |
| 3777 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3778 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3779 | } |
| 3780 | } |
| 3781 | if (cfg.si16_present or cfg.si17_present) { |
| 3782 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3783 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3784 | if (cfg.si22_present) { |
| 3785 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3786 | } |
| 3787 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3788 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3789 | } |
| 3790 | if (not cfg.bcch_extended) { |
| 3791 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3792 | } |
| 3793 | if (cfg.si16_present) { |
| 3794 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3795 | } |
| 3796 | if (cfg.si17_present) { |
| 3797 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3798 | } |
| 3799 | } |
| 3800 | |
| 3801 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3802 | * broadcast information. The frequency with which they are sent is determined by the |
| 3803 | * system operator. System Information type 9 identifies the scheduling of System |
| 3804 | * Information type 18 and 20 messages. */ |
| 3805 | |
| 3806 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3807 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 3808 | * Information Type 9. */ |
| 3809 | |
| 3810 | if (cfg.si15_present) { |
| 3811 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 3812 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 3813 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 3814 | * 4 consecutive occurrences of TC = 1. */ |
| 3815 | if (not cfg.bcch_extended) { |
| 3816 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 3817 | } else { |
| 3818 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 3819 | } |
| 3820 | } |
| 3821 | if (cfg.si13alt_present) { |
| 3822 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 3823 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 3824 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 3825 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 3826 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 3827 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 3828 | * of TC = 4. */ |
| 3829 | if (cfg.si13_present) { |
| 3830 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 3831 | } |
| 3832 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3833 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3834 | } |
| 3835 | if (not cfg.bcch_extended) { |
| 3836 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 3837 | } else { |
| 3838 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 3839 | } |
| 3840 | } |
| 3841 | if (cfg.si2n_present) { |
| 3842 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 3843 | * as determined by the system operator. In the case that the message is sent on the |
| 3844 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 3845 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 3846 | * consecutive occurrences of TC = 4. */ |
| 3847 | if (not cfg.bcch_extended) { |
| 3848 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 3849 | } else { |
| 3850 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 3851 | } |
| 3852 | } |
| 3853 | if (cfg.si21_present) { |
| 3854 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 3855 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 3856 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 3857 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 3858 | * cell then this message shall only be sent on BCCH Ext. */ |
| 3859 | if (not cfg.bcch_extended) { |
| 3860 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 3861 | } else { |
| 3862 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 3863 | if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3864 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3865 | } |
| 3866 | } |
| 3867 | } |
| 3868 | if (cfg.si22_present) { |
| 3869 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 3870 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 3871 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 3872 | * =2 and TC=6. */ |
| 3873 | if (cfg.si16_present or cfg.si17_present) { |
| 3874 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3875 | } |
| 3876 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 3877 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3878 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3879 | } |
| 3880 | if (not cfg.bcch_extended) { |
| 3881 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 3882 | } else { |
| 3883 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 3884 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 3885 | } |
| 3886 | } |
| 3887 | } |
| 3888 | |
| 3889 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3890 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 3891 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3892 | timer T := duration; |
| 3893 | var SystemInformationVectorPerTc si_per_tc; |
| 3894 | var L1ctlDlMessage l1_dl; |
| 3895 | |
| 3896 | /* initialize all per-TC vectors empty */ |
| 3897 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3898 | si_per_tc[i] := {}; |
| 3899 | } |
| 3900 | |
| 3901 | /* flush all previous L1 queued msgs */ |
| 3902 | pt.clear; |
| 3903 | |
| 3904 | T.start; |
| 3905 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3906 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3907 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3908 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 3909 | log("Ignoring non-RR SI ", l1_dl); |
| 3910 | repeat; |
| 3911 | } |
| 3912 | var SystemInformationFn sig := { |
| 3913 | frame_number := l1_dl.dl_info.frame_nr, |
| 3914 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 3915 | } |
| 3916 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 3917 | log("SI received at TC=", tc, ": ", sig.si); |
| 3918 | /* append to the per-TC bucket */ |
| 3919 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 3920 | repeat; |
| 3921 | } |
| 3922 | [] pt.receive { repeat; } |
| 3923 | [] T.timeout { } |
| 3924 | } |
| 3925 | |
| 3926 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3927 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 3928 | } |
| 3929 | log("si_per_tc=", si_per_tc); |
| 3930 | return si_per_tc; |
| 3931 | } |
| 3932 | |
| 3933 | /* helper function: Set given SI via RSL + validate scheduling. |
| 3934 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3935 | private function f_TC_si_sched() runs on test_CT { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3936 | var SystemInformationVectorPerTc si_per_tc; |
| 3937 | f_init_l1ctl(); |
| 3938 | f_l1_tune(L1CTL); |
| 3939 | |
| 3940 | /* Sample + Validate Scheduling */ |
| 3941 | si_per_tc := f_l1_sample_si(L1CTL); |
| 3942 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 3943 | |
| 3944 | setverdict(pass); |
| 3945 | } |
| 3946 | |
| 3947 | testcase TC_si_sched_default() runs on test_CT { |
| 3948 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3949 | /* 2+3+4 are mandatory and set in f_init() */ |
| 3950 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3951 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3952 | } |
| 3953 | |
| 3954 | testcase TC_si_sched_1() runs on test_CT { |
| 3955 | f_init(); |
| 3956 | si_cfg.si1_present := true; |
| 3957 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3958 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3959 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3960 | } |
| 3961 | |
| 3962 | testcase TC_si_sched_2bis() runs on test_CT { |
| 3963 | f_init(); |
| 3964 | si_cfg.si2bis_present := true; |
| 3965 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3966 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3967 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3968 | } |
| 3969 | |
| 3970 | testcase TC_si_sched_2ter() runs on test_CT { |
| 3971 | f_init(); |
| 3972 | si_cfg.si2ter_present := true; |
| 3973 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3974 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3976 | } |
| 3977 | |
| 3978 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 3979 | f_init(); |
| 3980 | si_cfg.si2bis_present := true; |
| 3981 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3982 | si_cfg.si2ter_present := true; |
| 3983 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3984 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3985 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3986 | } |
| 3987 | |
| 3988 | testcase TC_si_sched_2quater() runs on test_CT { |
| 3989 | f_init(); |
| 3990 | si_cfg.si2quater_present := true; |
| 3991 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3992 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3993 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3994 | } |
| 3995 | |
| 3996 | testcase TC_si_sched_13() runs on test_CT { |
| 3997 | f_init(); |
| 3998 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3999 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4000 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4001 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4002 | } |
| 4003 | |
| 4004 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 4005 | f_init(); |
| 4006 | si_cfg.si2bis_present := true; |
| 4007 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4008 | si_cfg.si2ter_present := true; |
| 4009 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4010 | si_cfg.si2quater_present := true; |
| 4011 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 4012 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4013 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4014 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4015 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4016 | } |
| 4017 | |
| 4018 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4019 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4020 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4021 | /* FIXME: enable / disable individual BCCH info */ |
| 4022 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4023 | /* expect no ERROR REPORT after either of them * |
| 4024 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4025 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4026 | } |
| 4027 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4028 | /*********************************************************************** |
| 4029 | * Low-Level Protocol Errors / ERROR REPORT |
| 4030 | ***********************************************************************/ |
| 4031 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4032 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4033 | timer T := 5.0; |
| 4034 | T.start; |
| 4035 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4036 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4037 | setverdict(pass); |
| 4038 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4039 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4040 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP"); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4041 | } |
| 4042 | [] RSL_CCHAN.receive { |
| 4043 | repeat; |
| 4044 | } |
| 4045 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4046 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP"); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4047 | } |
| 4048 | } |
| 4049 | } |
| 4050 | |
| 4051 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4052 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4053 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4054 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4055 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4056 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4057 | |
| 4058 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4059 | } |
| 4060 | |
| 4061 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4062 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4063 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4064 | |
| 4065 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4066 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4067 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4068 | |
| 4069 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4070 | } |
| 4071 | |
| 4072 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4073 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4074 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4075 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4076 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4077 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4078 | |
| 4079 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4080 | } |
| 4081 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4082 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4083 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4084 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4085 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4086 | RSL.send(rsl); |
| 4087 | f_rslem_unregister(0, g_chan_nr); |
| 4088 | } |
| 4089 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4090 | var ConnHdlr vc_conn; |
| 4091 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4092 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4093 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4094 | |
| 4095 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4096 | vc_conn.done; |
| 4097 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4098 | |
| 4099 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4100 | } |
| 4101 | |
| 4102 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4103 | private function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4104 | var template (value) RSL_Message rsl_tx; |
| 4105 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4106 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4107 | RSL.send(rsl_tx); |
| 4108 | f_rslem_unregister(0, g_chan_nr); |
| 4109 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4110 | private function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4111 | var template (value) RSL_Message rsl_tx; |
| 4112 | /* we first have to activate the dedicated channel */ |
| 4113 | f_rsl_chan_act(g_pars.chan_mode); |
| 4114 | /* ... to then send an invalid RLL message */ |
| 4115 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4116 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4117 | RSL.send(rsl_tx); |
| 4118 | f_rslem_unregister(0, g_chan_nr); |
| 4119 | } |
| 4120 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4121 | var ConnHdlr vc_conn; |
| 4122 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4123 | var template (value) RSL_Message rsl_tx; |
| 4124 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4125 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4126 | |
| 4127 | /* Common Channel with wrong message type */ |
| 4128 | RSL_CCHAN.clear; |
| 4129 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4130 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4131 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4132 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4133 | |
| 4134 | /* TRX Management */ |
| 4135 | RSL_CCHAN.clear; |
| 4136 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4137 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4138 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4139 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4140 | |
| 4141 | /* Dedicated Channel */ |
| 4142 | RSL_CCHAN.clear; |
| 4143 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4144 | vc_conn.done; |
| 4145 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4146 | |
| 4147 | /* RLL */ |
| 4148 | RSL_CCHAN.clear; |
| 4149 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4150 | vc_conn.done; |
| 4151 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4152 | } |
| 4153 | |
| 4154 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4155 | private function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr { |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4156 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4157 | f_rslem_unregister(0, g_chan_nr); |
| 4158 | } |
| 4159 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4160 | var ConnHdlr vc_conn; |
| 4161 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4162 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4163 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4164 | |
| 4165 | RSL_CCHAN.clear; |
| 4166 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4167 | vc_conn.done; |
| 4168 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4169 | } |
| 4170 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4171 | /*********************************************************************** |
| 4172 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4173 | ***********************************************************************/ |
| 4174 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4175 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4176 | private function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 4177 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4178 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4179 | } |
| 4180 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4181 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4182 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4183 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4184 | vc_conn.done; |
| 4185 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4186 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4187 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4188 | private function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4189 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4190 | "IPA CRCX ACK"); |
| 4191 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4192 | "IPA CRCX NACK"); |
| 4193 | } |
| 4194 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4195 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4196 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4197 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4198 | vc_conn.done; |
| 4199 | } |
| 4200 | |
| 4201 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4202 | private function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4203 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4204 | "IPA CRCX ACK"); |
| 4205 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4206 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4207 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4208 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4209 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4210 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4211 | "IPA MDCX ACK"); |
| 4212 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4213 | "IPA DLCX ACK"); |
| 4214 | } |
| 4215 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4216 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4217 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4218 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4219 | vc_conn.done; |
| 4220 | } |
| 4221 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4222 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4223 | private function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4224 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4225 | "IPA CRCX ACK"); |
| 4226 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4227 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4228 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4229 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4230 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4231 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4232 | "IPA MDCX ACK"); |
| 4233 | /* Second MDCX */ |
| 4234 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4235 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4236 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4237 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4238 | "IPA MDCX ACK"); |
| 4239 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4240 | "IPA DLCX ACK"); |
| 4241 | } |
| 4242 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4243 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4244 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4245 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4246 | vc_conn.done; |
| 4247 | } |
| 4248 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4249 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4250 | private function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4251 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4252 | "IPA CRCX NACK"); |
| 4253 | } |
| 4254 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4255 | var ConnHdlrPars pars; |
| 4256 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4257 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4258 | |
| 4259 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4260 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4261 | vc_conn.done; |
| 4262 | |
| 4263 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4264 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4265 | vc_conn.done; |
| 4266 | } |
| 4267 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4268 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4269 | /*********************************************************************** |
| 4270 | * PCU Socket related tests |
| 4271 | ***********************************************************************/ |
| 4272 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4273 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4274 | friend function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4275 | runs on test_CT { |
| 4276 | timer T := 3.0; |
| 4277 | |
| 4278 | /* we don't expect any RTS.req before PDCH are active */ |
| 4279 | T.start; |
| 4280 | alt { |
| 4281 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4282 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4283 | } |
| 4284 | [] PCU.receive { repeat; } |
| 4285 | [] T.timeout { } |
| 4286 | } |
| 4287 | |
| 4288 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4289 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4290 | |
| 4291 | /* we now expect RTS.req for this timeslot (only) */ |
| 4292 | T.start; |
| 4293 | alt { |
| 4294 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4295 | setverdict(pass); |
| 4296 | } |
| 4297 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4298 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4299 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4300 | } |
| 4301 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4302 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4303 | } |
| 4304 | [] PCU.receive { repeat; } |
| 4305 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4306 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4307 | } |
| 4308 | [not exp_success] T.timeout { |
| 4309 | setverdict(pass); |
| 4310 | } |
| 4311 | } |
| 4312 | } |
| 4313 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4314 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4315 | friend function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4316 | runs on test_CT { |
| 4317 | timer T := 3.0; |
| 4318 | |
| 4319 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4320 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4321 | |
| 4322 | PCU.clear; |
| 4323 | /* we now expect no RTS.req for this timeslot */ |
| 4324 | T.start; |
| 4325 | alt { |
| 4326 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4327 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4328 | } |
| 4329 | [] PCU.receive { repeat; } |
| 4330 | [] T.timeout { |
| 4331 | setverdict(pass); |
| 4332 | } |
| 4333 | } |
| 4334 | } |
| 4335 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4336 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4337 | f_init(); |
| 4338 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4339 | } |
| 4340 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4341 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4342 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4343 | f_init_pcu_test(); |
| 4344 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4345 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4346 | } |
| 4347 | |
| 4348 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4349 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4350 | f_init_pcu_test(); |
| 4351 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4352 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4353 | } |
| 4354 | |
| 4355 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4356 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4357 | f_init_pcu_test(); |
| 4358 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4359 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4360 | } |
| 4361 | |
| 4362 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4363 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4364 | f_init_pcu_test(); |
| 4365 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4366 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4367 | } |
| 4368 | |
| 4369 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4370 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4371 | f_init_pcu_test(); |
| 4372 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4373 | /* Activate PDCH */ |
| 4374 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4375 | f_sleep(1.0); |
| 4376 | /* and De-Activate again */ |
| 4377 | f_TC_pcu_deact_req(0, 0, 7); |
| 4378 | } |
| 4379 | |
| 4380 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4381 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4382 | f_init_pcu_test(); |
| 4383 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4384 | f_TC_pcu_deact_req(0, 0, 1); |
| 4385 | } |
| 4386 | |
| 4387 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4388 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4389 | const octetstring si13 := '00010203040506070909'O; |
| 4390 | var PCUIF_send_data sd; |
| 4391 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4392 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4393 | |
| 4394 | /* Set SI13 via RSL */ |
| 4395 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4396 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4397 | T.start; |
| 4398 | alt { |
| 4399 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4400 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4401 | setverdict(pass); |
| 4402 | } else { |
| 4403 | repeat; |
| 4404 | } |
| 4405 | } |
| 4406 | [] PCU.receive { repeat; } |
| 4407 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4408 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4409 | } |
| 4410 | } |
| 4411 | } |
| 4412 | |
| 4413 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4414 | |
| 4415 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4416 | friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4417 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4418 | runs on test_CT |
| 4419 | { |
| 4420 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4421 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4422 | } |
| 4423 | |
| 4424 | /* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4425 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4426 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4427 | runs on test_CT |
| 4428 | { |
| 4429 | var PCUIF_send_data sd; |
| 4430 | |
| 4431 | timer T := 3.0; |
| 4432 | T.start; |
| 4433 | alt { |
| 4434 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4435 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4436 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4437 | sd.data.u.rts_req.fn, sapi, data); |
| 4438 | } |
| 4439 | [] PCU.receive { repeat; } |
| 4440 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4441 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4442 | } |
| 4443 | } |
| 4444 | } |
| 4445 | |
| 4446 | /* Send DATA.req on invalid BTS */ |
| 4447 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4448 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4449 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4450 | |
| 4451 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4452 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4453 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4454 | f_TfiUsfArrSet(tua, 7, 0); |
| 4455 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4456 | f_sleep(1.0); |
| 4457 | |
| 4458 | f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4459 | } |
| 4460 | |
| 4461 | /* Send DATA.req on invalid TRX */ |
| 4462 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4463 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4464 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4465 | |
| 4466 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4467 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4468 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4469 | f_TfiUsfArrSet(tua, 7, 0); |
| 4470 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4471 | f_sleep(1.0); |
| 4472 | |
| 4473 | f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4474 | } |
| 4475 | |
| 4476 | /* Send DATA.req on invalid timeslot */ |
| 4477 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4478 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4479 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4480 | |
| 4481 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4482 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4483 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4484 | f_TfiUsfArrSet(tua, 7, 0); |
| 4485 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4486 | f_sleep(1.0); |
| 4487 | |
| 4488 | f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4489 | } |
| 4490 | |
| 4491 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4492 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4493 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4494 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4495 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4496 | f_virtphy_common(); |
| 4497 | |
| 4498 | f_TfiUsfArrSet(tua, 7, 0); |
| 4499 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4500 | f_sleep(1.0); |
| 4501 | |
| 4502 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4503 | } |
| 4504 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4505 | private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4506 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4507 | boolean wait_rts := true) |
| 4508 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4509 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4510 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4511 | |
| 4512 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4513 | if (wait_rts) { |
| 4514 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4515 | } else { |
| 4516 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4517 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4518 | |
| 4519 | T.start; |
| 4520 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4521 | [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4522 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4523 | setverdict(pass); |
| 4524 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4525 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4526 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4527 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4528 | [] L1CTL.receive { |
| 4529 | repeat; |
| 4530 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4531 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4532 | setverdict(fail, "Timeout waiting for ", data); |
| 4533 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4534 | [not expect_data] T.timeout { |
| 4535 | setverdict(pass); |
| 4536 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4537 | } |
| 4538 | } |
| 4539 | |
| 4540 | private function f_disable_dynamic_ts() runs on test_CT |
| 4541 | { |
| 4542 | f_init_vty_bsc(); |
| 4543 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4544 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4545 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4546 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4547 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4548 | } |
| 4549 | |
| 4550 | private function f_virtphy_common() runs on test_CT { |
| 4551 | f_disable_dynamic_ts(); |
| 4552 | f_init_l1ctl(); |
| 4553 | f_l1_tune(L1CTL); |
| 4554 | } |
| 4555 | |
| 4556 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4557 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4558 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4559 | |
| 4560 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4561 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4562 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4563 | f_TfiUsfArrSet(tua, 7, 0); |
| 4564 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4565 | f_sleep(1.0); |
| 4566 | |
| 4567 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4568 | } |
| 4569 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4570 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4571 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4572 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4573 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4574 | |
| 4575 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4576 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4577 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4578 | f_TfiUsfArrSet(tua, 7, 0); |
| 4579 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4580 | f_sleep(1.0); |
| 4581 | |
| 4582 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4583 | } |
| 4584 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4585 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4586 | runs on test_CT { |
| 4587 | var template PCUIF_Message pcu_rach_ind; |
| 4588 | var PCUIF_send_data sd; |
| 4589 | var GsmFrameNumber fn; |
| 4590 | timer T; |
| 4591 | |
| 4592 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4593 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4594 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4595 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4596 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4597 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4598 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4599 | |
| 4600 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4601 | T.start(52.0 * 4.615 / 1000.0); |
| 4602 | alt { |
| 4603 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4604 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4605 | setverdict(pass); |
| 4606 | T.stop; |
| 4607 | } |
| 4608 | [] PCU.receive { repeat; } |
| 4609 | [] T.timeout { |
| 4610 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4611 | /* Keep going, that's not the end of the world */ |
| 4612 | } |
| 4613 | } |
| 4614 | } |
| 4615 | |
| 4616 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4617 | var L1ctlDlMessage dl; |
| 4618 | var octetstring data; |
| 4619 | timer T; |
| 4620 | |
| 4621 | f_init_pcu_test(); |
| 4622 | f_init_l1ctl(); |
| 4623 | f_l1_tune(L1CTL); |
| 4624 | |
| 4625 | /* Activate PDCH channel on TS7 */ |
| 4626 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4627 | |
| 4628 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 4629 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4630 | |
| 4631 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4632 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4633 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4634 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4635 | } |
| 4636 | |
| 4637 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4638 | data := f_rnd_octstring(23); |
| 4639 | |
| 4640 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4641 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4642 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4643 | |
| 4644 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4645 | * let's give it more time in case if we miss the beginning. */ |
| 4646 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4647 | alt { |
| 4648 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4649 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4650 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4651 | frame := data)) -> value dl { |
| 4652 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4653 | setverdict(pass); |
| 4654 | T.stop; |
| 4655 | } |
| 4656 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4657 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4658 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4659 | l2_data := data)) -> value dl { |
| 4660 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4661 | setverdict(pass); |
| 4662 | T.stop; |
| 4663 | } |
| 4664 | [] L1CTL.receive { repeat; } |
| 4665 | [] T.timeout { |
| 4666 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4667 | } |
| 4668 | } |
| 4669 | } |
| 4670 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4671 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4672 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4673 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4674 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4675 | f_init_l1ctl(); |
| 4676 | f_l1_tune(L1CTL); |
| 4677 | |
| 4678 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4679 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4680 | |
| 4681 | T.start; |
| 4682 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4683 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4684 | setverdict(pass); |
| 4685 | } |
| 4686 | [] L1CTL.receive { repeat; } |
| 4687 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4688 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4689 | } |
| 4690 | } |
| 4691 | } |
| 4692 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4693 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4694 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4695 | timer T := 3.0; |
| 4696 | f_init_pcu_test(); |
| 4697 | f_init_l1ctl(); |
| 4698 | f_l1_tune(L1CTL); |
| 4699 | |
| 4700 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4701 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4702 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4703 | |
| 4704 | T.start; |
| 4705 | alt { |
| 4706 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4707 | setverdict(pass); |
| 4708 | } |
| 4709 | [] L1CTL.receive { repeat; } |
| 4710 | [] T.timeout { |
| 4711 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4712 | } |
| 4713 | } |
| 4714 | } |
| 4715 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4716 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4717 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4718 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4719 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4720 | f_init_l1ctl(); |
| 4721 | f_l1_tune(L1CTL); |
| 4722 | |
| 4723 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4724 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4725 | |
| 4726 | timer T := 0.5; |
| 4727 | T.start; |
| 4728 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4729 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4730 | /* TODO: verify paging group */ |
| 4731 | setverdict(pass); |
| 4732 | } |
| 4733 | [] L1CTL.receive { repeat; } |
| 4734 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4735 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4736 | } |
| 4737 | } |
| 4738 | } |
| 4739 | |
| 4740 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4741 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4742 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4743 | f_init_l1ctl(); |
| 4744 | f_l1_tune(L1CTL); |
| 4745 | |
| 4746 | var GsmFrameNumber fn_last := 0; |
| 4747 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4748 | var OCT1 ra := f_rnd_ra_ps(); |
| 4749 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4750 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4751 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4752 | } |
| 4753 | fn_last := fn; |
| 4754 | |
| 4755 | timer T := 2.0; |
| 4756 | T.start; |
| 4757 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4758 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn))) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4759 | T.stop; |
| 4760 | } |
| 4761 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4762 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4763 | } |
| 4764 | [] PCU.receive { repeat; } |
| 4765 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4766 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4767 | } |
| 4768 | } |
| 4769 | } |
| 4770 | setverdict(pass); |
| 4771 | } |
| 4772 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4773 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4774 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4775 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4776 | var template PCUIF_Message pcu_rach_ind; |
| 4777 | var GsmFrameNumber fn_last := 0; |
| 4778 | var L1ctlRachSynchSeq synch_seq; |
| 4779 | var PCUIF_BurstType pcu_bt; |
| 4780 | var GsmFrameNumber fn; |
| 4781 | var BIT11 ra11; |
| 4782 | |
| 4783 | f_init_pcu_test(); |
| 4784 | f_init_l1ctl(); |
| 4785 | f_l1_tune(L1CTL); |
| 4786 | |
| 4787 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4788 | /* We need to test both TS1 & TS2 */ |
| 4789 | if (i rem 2 == 0) { |
| 4790 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4791 | pcu_bt := BURST_TYPE_1; |
| 4792 | } else { |
| 4793 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4794 | pcu_bt := BURST_TYPE_2; |
| 4795 | } |
| 4796 | |
| 4797 | ra11 := f_rnd_ra11_ps(); |
| 4798 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4799 | if (fn == fn_last) { |
| 4800 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4801 | "Two RACH in same FN?!?"); |
| 4802 | } |
| 4803 | fn_last := fn; |
| 4804 | |
| 4805 | /* Compose the expected message */ |
| 4806 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4807 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4808 | ra := bit2int(ra11), |
| 4809 | is_11bit := 1, |
| 4810 | burst_type := pcu_bt, |
| 4811 | fn := fn); |
| 4812 | |
| 4813 | timer T := 2.0; |
| 4814 | T.start; |
| 4815 | alt { |
| 4816 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 4817 | T.stop; |
| 4818 | } |
| 4819 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 4820 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 4821 | } |
| 4822 | [] PCU.receive { repeat; } |
| 4823 | [] T.timeout { |
| 4824 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 4825 | } |
| 4826 | } |
| 4827 | } |
| 4828 | setverdict(pass); |
| 4829 | } |
| 4830 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4831 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 4832 | runs on test_CT { |
| 4833 | var template PCUIF_send_data sdt; |
| 4834 | var PCUIF_send_data sd; |
| 4835 | var int16_t lqual_cb; |
| 4836 | timer T := 1.0; |
| 4837 | |
| 4838 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 4839 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 4840 | |
| 4841 | /* Send a random PDTCH frame over Um */ |
| 4842 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 4843 | '0000'O & f_rnd_octstring(21))); |
| 4844 | |
| 4845 | T.start; |
| 4846 | alt { |
| 4847 | /* If expected link quality is above the threshold */ |
| 4848 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 4849 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 4850 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 4851 | |
| 4852 | /* Make sure the actual link quality matches the expected value */ |
| 4853 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 4854 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 4855 | "expected value ", lqual_cb_exp)); |
| 4856 | } else { |
| 4857 | setverdict(pass); |
| 4858 | } |
| 4859 | } |
| 4860 | /* If expected link quality is below the threshold */ |
| 4861 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 4862 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4863 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 4864 | } |
| 4865 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 4866 | [] PCU.receive { repeat; } |
| 4867 | [lqual_cb_exp < thresh] T.timeout { |
| 4868 | log("Rx nothing, as expected"); |
| 4869 | setverdict(pass); |
| 4870 | } |
| 4871 | [lqual_cb_exp >= thresh] T.timeout { |
| 4872 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4873 | "Timeout waiting for PCUIF_DATA.ind"); |
| 4874 | } |
| 4875 | } |
| 4876 | } |
| 4877 | |
| 4878 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 4879 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 4880 | f_init_pcu_test(); |
| 4881 | PCU.clear; |
| 4882 | |
| 4883 | f_init_l1ctl(); |
| 4884 | f_l1_tune(L1CTL); |
| 4885 | |
| 4886 | /* Activate a PDCH channel on TS7 */ |
| 4887 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4888 | |
| 4889 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 5afe885 | 2020-05-27 14:40:51 +0700 | [diff] [blame] | 4890 | L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn)); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4891 | |
| 4892 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 4893 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 4894 | var TrxcMessage ret; |
| 4895 | |
| 4896 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 4897 | valueof(ts_TRXC_FAKE_CI(i))); |
| 4898 | |
| 4899 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 4900 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 4901 | } |
| 4902 | } |
| 4903 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4904 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 4905 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4906 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4907 | |
| 4908 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4909 | var MobileIdentityLV mi_lv; |
| 4910 | var octetstring mi_lv_enc; |
| 4911 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4912 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4913 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4914 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4915 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4916 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4917 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4918 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4919 | |
| 4920 | /* Fancy encoding for PCUIF */ |
| 4921 | mi_lv := valueof(ts_MI_LV(mi)); |
| 4922 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 4923 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4924 | |
| 4925 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4926 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4927 | T.start; |
| 4928 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4929 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4930 | } |
| 4931 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4932 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4933 | } |
| 4934 | [] PCU.receive { repeat; } |
| 4935 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4936 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4937 | } |
| 4938 | } |
| 4939 | } |
| 4940 | setverdict(pass); |
| 4941 | } |
| 4942 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4943 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 4944 | testcase TC_pcu_time_ind() runs on test_CT { |
| 4945 | var PCUIF_send_data pcu_sd; |
| 4946 | var integer num_time_ind := 0; |
| 4947 | var integer first_fn, last_fn; |
| 4948 | var float test_duration := 5.0; |
| 4949 | timer T; |
| 4950 | |
| 4951 | f_init_pcu_test(); |
| 4952 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4953 | |
| 4954 | PCU.clear; |
| 4955 | T.start(test_duration); |
| 4956 | alt { |
| 4957 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 4958 | num_time_ind := num_time_ind + 1; |
| 4959 | if (not isbound(first_fn)) { |
| 4960 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 4961 | } |
| 4962 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 4963 | repeat; |
| 4964 | } |
| 4965 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 4966 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 4967 | repeat; |
| 4968 | } |
| 4969 | [] PCU.receive { |
| 4970 | repeat; |
| 4971 | } |
| 4972 | [] T.timeout {} |
| 4973 | } |
| 4974 | var integer fn_expired := last_fn - first_fn; |
| 4975 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 4976 | |
| 4977 | /* verify the number of frames expired matches our expectation */ |
| 4978 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4979 | var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS; |
Harald Welte | c761c54 | 2019-05-28 11:59:57 +0200 | [diff] [blame] | 4980 | var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4981 | if (not match(fn_expired, t_fn_expected)) { |
| 4982 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4983 | } |
| 4984 | |
| 4985 | /* There are three TIME.ind in every fn MOD 13 */ |
| 4986 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 4987 | /* Add some tolerance */ |
| 4988 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 4989 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 4990 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 4991 | } |
| 4992 | |
| 4993 | setverdict(pass); |
| 4994 | } |
| 4995 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 4996 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 4997 | testcase TC_pcu_rts_req() runs on test_CT { |
| 4998 | var PCUIF_send_data pcu_sd; |
| 4999 | var integer first_fn, last_fn; |
| 5000 | var integer num_rts_pdtch := 0; |
| 5001 | var integer num_rts_ptcch := 0; |
| 5002 | var float test_duration := 5.0; |
| 5003 | timer T; |
| 5004 | |
| 5005 | f_init_pcu_test(); |
| 5006 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5007 | |
| 5008 | PCU.clear; |
| 5009 | T.start(test_duration); |
| 5010 | alt { |
| 5011 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5012 | -> value pcu_sd { |
| 5013 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5014 | if (not isbound(first_fn)) { |
| 5015 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5016 | } |
| 5017 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5018 | repeat; |
| 5019 | } |
| 5020 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5021 | -> value pcu_sd { |
| 5022 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5023 | if (not isbound(first_fn)) { |
| 5024 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5025 | } |
| 5026 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5027 | repeat; |
| 5028 | } |
| 5029 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5030 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5031 | repeat; |
| 5032 | } |
| 5033 | [] PCU.receive { |
| 5034 | repeat; |
| 5035 | } |
| 5036 | [] T.timeout {} |
| 5037 | } |
| 5038 | var integer fn_expired := last_fn - first_fn; |
| 5039 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5040 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5041 | |
| 5042 | /* verify the number of frames expired matches our expectation */ |
| 5043 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5044 | var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS; |
Harald Welte | c761c54 | 2019-05-28 11:59:57 +0200 | [diff] [blame] | 5045 | var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5046 | if (not match(fn_expired, t_fn_expected)) { |
| 5047 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5048 | } |
| 5049 | |
| 5050 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5051 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5052 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5053 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5054 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5055 | t_ptcch_exp); |
| 5056 | } |
| 5057 | |
| 5058 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5059 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5060 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5061 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5062 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5063 | t_pdtch_exp); |
| 5064 | } |
| 5065 | |
| 5066 | setverdict(pass); |
| 5067 | } |
| 5068 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5069 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5070 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5071 | var PCUIF_send_data pcu_sd; |
| 5072 | var integer num_time_ind := 0; |
| 5073 | var integer first_fn, last_fn; |
| 5074 | var float test_duration := 5.0; |
| 5075 | timer T; |
| 5076 | |
| 5077 | f_init_pcu_test(); |
| 5078 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5079 | |
| 5080 | /* re-connect CTRL port from BTS to BSC */ |
| 5081 | f_ipa_ctrl_stop(); |
| 5082 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 5083 | |
| 5084 | /* Send that OML Alert */ |
| 5085 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5086 | |
| 5087 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5088 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5089 | setverdict(pass); |
| 5090 | } |
| 5091 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5092 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5093 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5094 | var PCUIF_Message first_info; |
| 5095 | var integer pcu_conn_id := -1; |
| 5096 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5097 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5098 | var OCT4 tlli := '01020304'O; |
| 5099 | var OCT1 cause := '23'O; |
| 5100 | timer T := 5.0; |
| 5101 | |
| 5102 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5103 | |
| 5104 | f_l1_tune(L1CTL); |
| 5105 | RSL.clear; |
| 5106 | |
| 5107 | f_est_dchan(); |
| 5108 | L1CTL.clear; |
| 5109 | |
| 5110 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5111 | |
| 5112 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5113 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5114 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5115 | |
| 5116 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5117 | T.start; |
| 5118 | alt { |
| 5119 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5120 | setverdict(pass); |
| 5121 | } |
| 5122 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5123 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5124 | } |
| 5125 | [] PCU.receive { |
| 5126 | repeat; |
| 5127 | } |
| 5128 | [] T.timeout { |
| 5129 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5130 | } |
| 5131 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5132 | |
| 5133 | /* release the channel */ |
| 5134 | f_rsl_chan_deact(); |
| 5135 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5136 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5137 | } |
| 5138 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5139 | var ConnHdlrPars pars; |
| 5140 | var ConnHdlr vc_conn; |
| 5141 | |
| 5142 | f_init(); |
| 5143 | |
| 5144 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5145 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5146 | vc_conn.done; |
| 5147 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5148 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5149 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5150 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 5151 | timer T := 5.0; |
| 5152 | |
| 5153 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5154 | f_init(); |
| 5155 | |
| 5156 | /* try to establish a second connection, expect it to fail */ |
| 5157 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5158 | T.start; |
| 5159 | alt { |
| 5160 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 5161 | setverdict(pass); |
| 5162 | } |
| 5163 | [] PCU.receive(UD_connect_result:?) { |
| 5164 | setverdict(fail, "Unexpected unix domain connect result"); |
| 5165 | } |
| 5166 | [] T.timeout { |
| 5167 | setverdict(pass); |
| 5168 | } |
| 5169 | } |
| 5170 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5171 | } |
| 5172 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5173 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5174 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5175 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5176 | f_init(); |
| 5177 | |
| 5178 | f_sleep(1.0); |
| 5179 | |
| 5180 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5181 | g_pcu_conn_id := -1; |
| 5182 | |
| 5183 | f_sleep(1.0); |
| 5184 | |
| 5185 | /* re-connect */ |
| 5186 | PCU.clear; |
| 5187 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5188 | setverdict(pass); |
| 5189 | |
| 5190 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5191 | } |
| 5192 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5193 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5194 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5195 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5196 | var L1ctlDlMessage l1_dl; |
| 5197 | var SystemInformation si; |
| 5198 | timer T := 5.0; |
| 5199 | T.start; |
| 5200 | alt { |
| 5201 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 5202 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 5203 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 5204 | log("Ignoring non-RR SI ", l1_dl); |
| 5205 | repeat; |
| 5206 | } |
| 5207 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5208 | if (si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5209 | repeat; |
| 5210 | } |
| 5211 | } |
| 5212 | [] pt.receive { |
| 5213 | repeat; |
| 5214 | } |
| 5215 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5216 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5217 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5218 | } |
| 5219 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5220 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5221 | } |
| 5222 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5223 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5224 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5225 | runs on test_CT return boolean { |
| 5226 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5227 | |
| 5228 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
| 5229 | var RestOctets ro := si.payload.si3.rest_octets; |
| 5230 | var SI3RestOctets rest := dec_SI3RestOctets(ro); |
| 5231 | return rest.gprs_ind.presence == '1'B; |
| 5232 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
| 5233 | var RestOctets ro := si.payload.si4.rest_octets; |
| 5234 | var SI4RestOctets rest := dec_SI4RestOctets(ro); |
| 5235 | return rest.gprs_ind.presence == '1'B; |
| 5236 | } |
| 5237 | |
| 5238 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5239 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5240 | } |
| 5241 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5242 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5243 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5244 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5245 | /* don't call f_init() as this would connect PCU socket */ |
| 5246 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5247 | |
| 5248 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5249 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5250 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5251 | |
| 5252 | f_init_l1ctl(); |
| 5253 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5254 | f_sleep(2.0); |
| 5255 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5256 | |
| 5257 | if (f_si_has_gprs_indicator(si_type)) { |
| 5258 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5259 | } else { |
| 5260 | setverdict(pass); |
| 5261 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5262 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5263 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5264 | } |
| 5265 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5266 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5267 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5268 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5269 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5270 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5271 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5272 | } |
| 5273 | |
| 5274 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5275 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5276 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5277 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5278 | f_init(); |
| 5279 | f_init_l1ctl(); |
| 5280 | f_l1_tune(L1CTL); |
| 5281 | |
| 5282 | f_sleep(2.0); |
| 5283 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5284 | |
| 5285 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5286 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5287 | } else { |
| 5288 | setverdict(pass); |
| 5289 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5290 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5291 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5292 | } |
| 5293 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5294 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5295 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5296 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5297 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5298 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5299 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5300 | } |
| 5301 | |
| 5302 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5303 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5304 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5305 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5306 | f_init(); |
| 5307 | f_init_l1ctl(); |
| 5308 | f_l1_tune(L1CTL); |
| 5309 | |
| 5310 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5311 | g_pcu_conn_id := -1; |
| 5312 | |
| 5313 | f_sleep(1.0); |
| 5314 | |
| 5315 | /* re-connect */ |
| 5316 | PCU.clear; |
| 5317 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5318 | |
| 5319 | f_sleep(2.0); |
| 5320 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5321 | |
| 5322 | if (f_si_has_gprs_indicator(si_type)) { |
| 5323 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5324 | } else { |
| 5325 | setverdict(pass); |
| 5326 | } |
| 5327 | |
| 5328 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5329 | } |
| 5330 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5331 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5332 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5333 | } |
| 5334 | |
| 5335 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5336 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5337 | } |
| 5338 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5339 | /* Verify that the cell_id of SI3 (TS 04.08 9.1.35) and other values are passed properly to the PCU socket (OS#3854) */ |
| 5340 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5341 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5342 | |
| 5343 | f_init(); |
| 5344 | |
| 5345 | /* Verify cell_id */ |
| 5346 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5347 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5348 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5349 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5350 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5351 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5352 | } |
| 5353 | |
| 5354 | /* Verify LAC */ |
| 5355 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5356 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5357 | if (lac_si3 != lac_pcu) { |
| 5358 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5359 | } |
| 5360 | |
| 5361 | setverdict(pass); |
| 5362 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5363 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5364 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5365 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5366 | ***********************************************************************/ |
| 5367 | |
| 5368 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5369 | runs on ConnHdlr { |
| 5370 | var PCUIF_send_data sd; |
| 5371 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5372 | PCU.clear; |
| 5373 | f_rsl_chan_act(g_pars.chan_mode); |
| 5374 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5375 | timer T_wait := 2.0; |
| 5376 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5377 | alt { |
| 5378 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5379 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5380 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5381 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5382 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5383 | } |
| 5384 | } |
| 5385 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5386 | [] T_wait.timeout { |
| 5387 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5388 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5389 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5390 | } |
| 5391 | /* try to activate this PDCH from the PCU point of view */ |
| 5392 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5393 | /* FIXME: is there a response? */ |
| 5394 | } |
| 5395 | |
| 5396 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5397 | runs on ConnHdlr { |
| 5398 | var PCUIF_send_data sd; |
| 5399 | /* Send RSL CHAN REL (deactivate) */ |
| 5400 | PCU.clear; |
| 5401 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5402 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5403 | timer T_wait := 2.0; |
| 5404 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5405 | alt { |
| 5406 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5407 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5408 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5409 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5410 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5411 | } |
| 5412 | } |
| 5413 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5414 | [] T_wait.timeout { |
| 5415 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5416 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5417 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5418 | } |
| 5419 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5420 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5421 | alt { |
| 5422 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5423 | setverdict(pass); |
| 5424 | } |
| 5425 | [] RSL.receive { repeat; } |
| 5426 | } |
| 5427 | } |
| 5428 | |
| 5429 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5430 | private function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5431 | var PCUIF_Message first_info; |
| 5432 | var integer ts_nr := g_chan_nr.tn; |
| 5433 | var integer trx_nr := 0; |
| 5434 | var integer bts_nr := 0; |
| 5435 | var integer pcu_conn_id := -1; |
| 5436 | |
| 5437 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5438 | |
| 5439 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5440 | f_sleep(3.0); |
| 5441 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5442 | setverdict(pass); |
| 5443 | } |
| 5444 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5445 | var ConnHdlrPars pars; |
| 5446 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5447 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5448 | |
| 5449 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5450 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5451 | vc_conn.done; |
| 5452 | } |
| 5453 | |
| 5454 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5455 | private function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5456 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5457 | var integer pcu_conn_id := -1; |
| 5458 | |
| 5459 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5460 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5461 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5462 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5463 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5464 | setverdict(pass); |
| 5465 | } |
| 5466 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5467 | var ConnHdlrPars pars; |
| 5468 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5469 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5470 | |
| 5471 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5472 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5473 | vc_conn.done; |
| 5474 | } |
| 5475 | |
| 5476 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5477 | private function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5478 | var PCUIF_Message first_info; |
| 5479 | var integer ts_nr := g_chan_nr.tn; |
| 5480 | var integer trx_nr := 0; |
| 5481 | var integer bts_nr := 0; |
| 5482 | var integer pcu_conn_id := -1; |
| 5483 | |
| 5484 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5485 | |
| 5486 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5487 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5488 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5489 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5490 | setverdict(pass); |
| 5491 | } |
| 5492 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5493 | var ConnHdlrPars pars; |
| 5494 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5495 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5496 | |
| 5497 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5498 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5499 | vc_conn.done; |
| 5500 | } |
| 5501 | |
| 5502 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5503 | private function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5504 | var PCUIF_Message first_info; |
| 5505 | var integer ts_nr := g_chan_nr.tn; |
| 5506 | var integer trx_nr := 0; |
| 5507 | var integer bts_nr := 0; |
| 5508 | var integer pcu_conn_id := -1; |
| 5509 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5510 | |
| 5511 | /* register for the TCH/F channel number */ |
| 5512 | f_rslem_register(0, chan_nr); |
| 5513 | |
| 5514 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5515 | |
| 5516 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5517 | "RSL CHAN ACT"); |
| 5518 | setverdict(pass); |
| 5519 | } |
| 5520 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5521 | var ConnHdlrPars pars; |
| 5522 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5523 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5524 | |
| 5525 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5526 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5527 | vc_conn.done; |
| 5528 | } |
| 5529 | |
| 5530 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5531 | private function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5532 | var PCUIF_Message first_info; |
| 5533 | var integer ts_nr := g_chan_nr.tn; |
| 5534 | var integer trx_nr := 0; |
| 5535 | var integer bts_nr := 0; |
| 5536 | var integer pcu_conn_id := -1; |
| 5537 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5538 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5539 | |
| 5540 | /* register for the TCH/H channel numbers */ |
| 5541 | f_rslem_register(0, chan_nr[0]); |
| 5542 | f_rslem_register(0, chan_nr[1]); |
| 5543 | |
| 5544 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5545 | |
| 5546 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5547 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5548 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5549 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5550 | setverdict(pass); |
| 5551 | } |
| 5552 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5553 | var ConnHdlrPars pars; |
| 5554 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5555 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5556 | |
| 5557 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5558 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5559 | vc_conn.done; |
| 5560 | } |
| 5561 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5562 | /*********************************************************************** |
| 5563 | * IPA Style Dynamic Timeslot Support |
| 5564 | ***********************************************************************/ |
| 5565 | |
| 5566 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5567 | runs on ConnHdlr { |
| 5568 | var PCUIF_send_data sd; |
| 5569 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5570 | PCU.clear; |
| 5571 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5572 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5573 | timer T_wait := 2.0; |
| 5574 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5575 | alt { |
| 5576 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5577 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5578 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5579 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5580 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5581 | } |
| 5582 | } |
| 5583 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5584 | [] T_wait.timeout { |
| 5585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5586 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5587 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5588 | } |
| 5589 | /* try to activate this PDCH from the PCU point of view */ |
| 5590 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5591 | /* FIXME: is there a response? */ |
| 5592 | |
| 5593 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5594 | } |
| 5595 | |
| 5596 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5597 | runs on ConnHdlr { |
| 5598 | var PCUIF_send_data sd; |
| 5599 | /* Send RSL CHAN REL (deactivate) */ |
| 5600 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5601 | PCU.clear; |
| 5602 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5603 | timer T_wait := 2.0; |
| 5604 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5605 | alt { |
| 5606 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5607 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5608 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5609 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5610 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5611 | } |
| 5612 | } |
| 5613 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5614 | [] T_wait.timeout { |
| 5615 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5616 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5617 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5618 | } |
| 5619 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5620 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5621 | alt { |
| 5622 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5623 | setverdict(pass); |
| 5624 | } |
| 5625 | [] RSL.receive { repeat; } |
| 5626 | } |
| 5627 | } |
| 5628 | |
| 5629 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5630 | private function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5631 | var PCUIF_Message first_info; |
| 5632 | var integer ts_nr := g_chan_nr.tn; |
| 5633 | var integer trx_nr := 0; |
| 5634 | var integer bts_nr := 0; |
| 5635 | var integer pcu_conn_id := -1; |
| 5636 | |
| 5637 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5638 | |
| 5639 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5640 | f_sleep(3.0); |
| 5641 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5642 | |
| 5643 | setverdict(pass); |
| 5644 | |
| 5645 | } |
| 5646 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5647 | var ConnHdlrPars pars; |
| 5648 | var ConnHdlr vc_conn; |
| 5649 | f_init(); |
| 5650 | |
| 5651 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5652 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5653 | vc_conn.done; |
| 5654 | } |
| 5655 | |
| 5656 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5657 | private function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5658 | var PCUIF_Message first_info; |
| 5659 | var integer ts_nr := g_chan_nr.tn; |
| 5660 | var integer trx_nr := 0; |
| 5661 | var integer bts_nr := 0; |
| 5662 | var integer pcu_conn_id := -1; |
| 5663 | |
| 5664 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5665 | |
| 5666 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5667 | "RSL CHAN ACT"); |
| 5668 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5669 | "RF CHAN REL", true); |
| 5670 | setverdict(pass); |
| 5671 | } |
| 5672 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5673 | var ConnHdlrPars pars; |
| 5674 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5675 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5676 | |
| 5677 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5678 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5679 | vc_conn.done; |
| 5680 | } |
| 5681 | |
| 5682 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5683 | private function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5684 | var PCUIF_Message first_info; |
| 5685 | var integer ts_nr := g_chan_nr.tn; |
| 5686 | var integer trx_nr := 0; |
| 5687 | var integer bts_nr := 0; |
| 5688 | var integer pcu_conn_id := -1; |
| 5689 | |
| 5690 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5691 | |
| 5692 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5693 | "RSL CHAN ACT"); |
| 5694 | |
| 5695 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5696 | alt { |
| 5697 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5698 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5699 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5700 | } |
| 5701 | [] RSL.receive { repeat; } |
| 5702 | } |
| 5703 | |
| 5704 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5705 | "RF CHAN REL", true); |
| 5706 | setverdict(pass); |
| 5707 | } |
| 5708 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5709 | var ConnHdlrPars pars; |
| 5710 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5711 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5712 | |
| 5713 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5714 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5715 | vc_conn.done; |
| 5716 | } |
| 5717 | |
| 5718 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5719 | private function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5720 | var PCUIF_Message first_info; |
| 5721 | var integer ts_nr := g_chan_nr.tn; |
| 5722 | var integer trx_nr := 0; |
| 5723 | var integer bts_nr := 0; |
| 5724 | var integer pcu_conn_id := -1; |
| 5725 | |
| 5726 | /* register for the TCH/F channel number */ |
| 5727 | f_rslem_register(0, g_chan_nr); |
| 5728 | |
| 5729 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5730 | |
| 5731 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5732 | |
| 5733 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5734 | "RSL CHAN ACT"); |
| 5735 | |
| 5736 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5737 | |
| 5738 | setverdict(pass); |
| 5739 | } |
| 5740 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 5741 | var ConnHdlrPars pars; |
| 5742 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5743 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5744 | |
| 5745 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5746 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 5747 | vc_conn.done; |
| 5748 | } |
| 5749 | |
| 5750 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5751 | /*********************************************************************** |
| 5752 | * LAPDm / RLL related |
| 5753 | ***********************************************************************/ |
| 5754 | |
| 5755 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 5756 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 5757 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5758 | var template (value) SacchL1Header l1h; |
| 5759 | |
| 5760 | /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5761 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5762 | /* Compose dummy L1 header */ |
| 5763 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 5764 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1h, f_pad_oct(l2, 21, '2B'O))); |
Pau Espin Pedrol | a0fb42a | 2018-10-10 15:56:39 +0200 | [diff] [blame] | 5765 | } else { |
| 5766 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5767 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, f_pad_oct(l2, 23, '2B'O))); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5768 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5769 | } |
| 5770 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 5771 | private type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5772 | uint3_t sapi, |
| 5773 | RslLinkId link_id, |
| 5774 | octetstring l3, |
| 5775 | boolean exp |
| 5776 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 5777 | private type record of RllTestCase RllTestCases; |
| 5778 | private template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, |
| 5779 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5780 | sapi := sapi, |
| 5781 | link_id := id, |
| 5782 | l3 := l3, |
| 5783 | exp := exp |
| 5784 | } |
| 5785 | |
| 5786 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 5787 | * variety of logical channels */ |
| 5788 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 5789 | var ConnHdlrPars pars; |
| 5790 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5791 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5792 | |
| 5793 | /* test on each of the channels we have */ |
| 5794 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 5795 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 5796 | |
| 5797 | /* test each of the test cases on the current channel */ |
| 5798 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 5799 | pars.spec.rll := tcs[j]; |
| 5800 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 5801 | vc_conn := f_start_handler(fn, pars); |
| 5802 | vc_conn.done; |
| 5803 | } |
| 5804 | } |
| 5805 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5806 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5807 | } |
| 5808 | |
| 5809 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 5810 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 5811 | var RllTestCase tc := g_pars.spec.rll; |
| 5812 | timer T := 3.0; |
| 5813 | |
| 5814 | f_l1_tune(L1CTL); |
| 5815 | RSL.clear; |
| 5816 | |
| 5817 | /* activate the logical channel */ |
| 5818 | f_est_dchan(); |
| 5819 | L1CTL.clear; |
| 5820 | |
| 5821 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 5822 | T.start; |
| 5823 | alt { |
| 5824 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5825 | if (tc.exp) { |
| 5826 | setverdict(pass); |
| 5827 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5828 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5829 | } |
| 5830 | } |
| 5831 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 5832 | if (tc.exp) { |
| 5833 | setverdict(pass); |
| 5834 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5835 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5836 | } |
| 5837 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5838 | /* We also expect to receive the measurements */ |
| 5839 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5840 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5841 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5842 | } |
| 5843 | [not tc.exp] T.timeout { |
| 5844 | setverdict(pass); |
| 5845 | } |
| 5846 | } |
| 5847 | |
| 5848 | f_rsl_chan_deact(); |
| 5849 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5850 | f_rslem_unregister(0, g_chan_nr); |
| 5851 | } |
| 5852 | testcase TC_rll_est_ind() runs on test_CT { |
| 5853 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5854 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5855 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5856 | /* normal SAPI0 establishment */ |
| 5857 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5858 | /* SAPI 3 doesn't support contention resolution */ |
| 5859 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 5860 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 5861 | /* normal SAPI3 establishment on main DCCH */ |
| 5862 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5863 | /* normal SAPI3 establishment on SACCH */ |
| 5864 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5865 | }; |
| 5866 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 5867 | } |
| 5868 | |
| 5869 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 5870 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 5871 | var RllTestCase tc := g_pars.spec.rll; |
| 5872 | var L1ctlDlMessage dl; |
| 5873 | timer T := 3.0; |
| 5874 | |
| 5875 | f_l1_tune(L1CTL); |
| 5876 | RSL.clear; |
| 5877 | |
| 5878 | /* activate the logical channel */ |
| 5879 | f_est_dchan(); |
| 5880 | L1CTL.clear; |
| 5881 | |
| 5882 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 5883 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 5884 | T.start; |
| 5885 | alt { |
| 5886 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5887 | var LapdmFrame lapdm; |
| 5888 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5889 | if (dl.dl_info.link_id.c == SACCH) { |
| 5890 | /* remove L1 header */ |
| 5891 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5892 | } |
| 5893 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5894 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 5895 | setverdict(pass); |
| 5896 | } else { |
| 5897 | repeat; |
| 5898 | } |
| 5899 | } |
| 5900 | [] L1CTL.receive { repeat; } |
| 5901 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5902 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5903 | } |
| 5904 | } |
| 5905 | |
| 5906 | f_rsl_chan_deact(); |
| 5907 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5908 | f_rslem_unregister(0, g_chan_nr); |
| 5909 | } |
| 5910 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 5911 | var RllTestCases tcs := { |
| 5912 | /* normal SAPI3 establishment on main DCCH */ |
| 5913 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 5914 | }; |
| 5915 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5916 | } |
| 5917 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 5918 | var RllTestCases tcs := { |
| 5919 | /* normal SAPI3 establishment on SACCH */ |
| 5920 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5921 | } |
| 5922 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5923 | } |
| 5924 | |
| 5925 | /* altstep to receive a LAPDm frame matching the given template */ |
| 5926 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 5927 | var L1ctlDlMessage dl; |
| 5928 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5929 | var LapdmFrame lapdm; |
| 5930 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5931 | if (dl.dl_info.link_id.c == SACCH) { |
| 5932 | /* remove L1 header */ |
| 5933 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5934 | } |
| 5935 | if (ischosen(exp.ab)) { |
| 5936 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5937 | } else if (ischosen(exp.b4)) { |
| 5938 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 5939 | } else if (ischosen(exp.bbis)) { |
| 5940 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 5941 | } |
| 5942 | log("Rx LAPDm ", lapdm); |
| 5943 | if (match(lapdm, exp)) { |
| 5944 | setverdict(pass); |
| 5945 | } else { |
| 5946 | repeat; |
| 5947 | } |
| 5948 | } |
| 5949 | [] L1CTL.receive { repeat; } |
| 5950 | } |
| 5951 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 5952 | timer T := t; |
| 5953 | T.start; |
| 5954 | alt { |
| 5955 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5956 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5957 | } |
| 5958 | [] as_l1_exp_lapdm(exp); |
| 5959 | } |
| 5960 | } |
| 5961 | |
| 5962 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 5963 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5964 | /* send SABM from MS -> BTS */ |
| 5965 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 5966 | /* expect RLL EST IND on Abis */ |
| 5967 | alt { |
| 5968 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 5969 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 5970 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5971 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5972 | } |
| 5973 | [] RSL.receive { repeat; } |
| 5974 | } |
| 5975 | /* expect UA from BTS -> MS */ |
| 5976 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 5977 | } |
| 5978 | |
| 5979 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 5980 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 5981 | var RllTestCase tc := g_pars.spec.rll; |
| 5982 | |
| 5983 | f_l1_tune(L1CTL); |
| 5984 | RSL.clear; |
| 5985 | |
| 5986 | /* activate the logical channel */ |
| 5987 | f_est_dchan(); |
| 5988 | L1CTL.clear; |
| 5989 | |
| 5990 | /* first establish the link-layer */ |
| 5991 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5992 | |
| 5993 | /* then send the DISC */ |
| 5994 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 5995 | /* ... and expect the REL IND on the RSL side */ |
| 5996 | alt { |
| 5997 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 5998 | setverdict(pass); |
| 5999 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6000 | /* We also expect to receive the measurements */ |
| 6001 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6002 | } |
| 6003 | |
| 6004 | /* release the channel */ |
| 6005 | f_rsl_chan_deact(); |
| 6006 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6007 | f_rslem_unregister(0, g_chan_nr); |
| 6008 | } |
| 6009 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6010 | var RllTestCases tcs := { |
| 6011 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 6012 | }; |
| 6013 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6014 | } |
| 6015 | |
| 6016 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6017 | var RllTestCases tcs := { |
| 6018 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 6019 | }; |
| 6020 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6021 | } |
| 6022 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6023 | var RllTestCases tcs := { |
| 6024 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 6025 | }; |
| 6026 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6027 | } |
| 6028 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6029 | var RllTestCases tcs := { |
| 6030 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6031 | }; |
| 6032 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6033 | } |
| 6034 | |
| 6035 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6036 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6037 | var RllTestCase tc := g_pars.spec.rll; |
| 6038 | f_l1_tune(L1CTL); |
| 6039 | RSL.clear; |
| 6040 | |
| 6041 | /* activate the logical channel */ |
| 6042 | f_est_dchan(); |
| 6043 | L1CTL.clear; |
| 6044 | |
| 6045 | /* first establish the link-layer */ |
| 6046 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6047 | |
| 6048 | /* then send the REL REQ via RSL */ |
| 6049 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6050 | /* ... and expect the DISC on the Um side */ |
| 6051 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6052 | [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6053 | /* FIXME: send a UA in resposne to the DISC */ |
| 6054 | } |
| 6055 | } |
| 6056 | |
| 6057 | /* release the channel */ |
| 6058 | f_rsl_chan_deact(); |
| 6059 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6060 | f_rslem_unregister(0, g_chan_nr); |
| 6061 | } |
| 6062 | testcase TC_rll_rel_req() runs on test_CT { |
| 6063 | var RllTestCases tcs := { |
| 6064 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 6065 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 6066 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6067 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6068 | }; |
| 6069 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6070 | } |
| 6071 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6072 | /* TODO: test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6073 | testcase TC_rll_data_req() runs on test_CT { |
| 6074 | } |
| 6075 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6076 | /* TODO: test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6077 | testcase TC_rll_data_ind() runs on test_CT { |
| 6078 | } |
| 6079 | |
| 6080 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6081 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6082 | var RllTestCase tc := g_pars.spec.rll; |
| 6083 | |
| 6084 | f_l1_tune(L1CTL); |
| 6085 | RSL.clear; |
| 6086 | |
| 6087 | f_est_dchan(); |
| 6088 | L1CTL.clear; |
| 6089 | |
| 6090 | /* Send UNITDATA REQ on RSL side */ |
| 6091 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6092 | /* Expect it to arrive on the other side */ |
| 6093 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6094 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6095 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6096 | f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6097 | } |
| 6098 | |
| 6099 | /* release the channel */ |
| 6100 | f_rsl_chan_deact(); |
| 6101 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6102 | f_rslem_unregister(0, g_chan_nr); |
| 6103 | } |
| 6104 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6105 | var octetstring l3 := f_rnd_octstring(15); |
| 6106 | var RllTestCases tcs := { |
| 6107 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6108 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6109 | }; |
| 6110 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6111 | } |
| 6112 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6113 | var octetstring l3 := f_rnd_octstring(19); |
| 6114 | var RllTestCases tcs := { |
| 6115 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6116 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6117 | }; |
| 6118 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6119 | } |
| 6120 | |
| 6121 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6122 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6123 | var RllTestCase tc := g_pars.spec.rll; |
| 6124 | |
| 6125 | f_l1_tune(L1CTL); |
| 6126 | RSL.clear; |
| 6127 | |
| 6128 | f_est_dchan(); |
| 6129 | L1CTL.clear; |
| 6130 | |
| 6131 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6132 | f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6133 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6134 | alt { |
| 6135 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6136 | setverdict(pass); |
| 6137 | } |
| 6138 | [] RSL.receive { repeat; } |
| 6139 | } |
| 6140 | |
| 6141 | /* release the channel */ |
| 6142 | f_rsl_chan_deact(); |
| 6143 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6144 | f_rslem_unregister(0, g_chan_nr); |
| 6145 | } |
| 6146 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6147 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6148 | var RllTestCases tcs := { |
| 6149 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6150 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6151 | }; |
| 6152 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6153 | } |
| 6154 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6155 | var octetstring l3 := f_rnd_octstring(18); |
| 6156 | var RllTestCases tcs := { |
| 6157 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6158 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6159 | }; |
| 6160 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6161 | } |
| 6162 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6163 | /*********************************************************************** |
| 6164 | * Encryption Related |
| 6165 | ***********************************************************************/ |
| 6166 | |
| 6167 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6168 | private function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6169 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6170 | if (link_id.c == SACCH) { |
| 6171 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6172 | } else { |
| 6173 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6174 | } |
| 6175 | } |
| 6176 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6177 | /* Expect (or not expect) other kinds of messages */ |
| 6178 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6179 | [exp_any] RSL.receive { repeat; } |
| 6180 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6181 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6182 | } |
| 6183 | } |
| 6184 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6185 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
Vadim Yanitskiy | 8d8f91c | 2018-10-04 06:19:45 +0700 | [diff] [blame] | 6186 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6187 | RslLinkId link_id, |
| 6188 | octetstring l3, |
| 6189 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6190 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6191 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6192 | timer T := 3.0; |
| 6193 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6194 | T.start; |
| 6195 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6196 | alt { |
| 6197 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6198 | setverdict(pass); |
| 6199 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6200 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6201 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6202 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6203 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6204 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6205 | } |
| 6206 | } |
| 6207 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6208 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6209 | private function f_data_mo( |
| 6210 | RslLinkId link_id, |
| 6211 | boolean p, uint3_t nr, uint3_t ns, |
| 6212 | octetstring l3, |
| 6213 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6214 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6215 | ) runs on ConnHdlr { |
| 6216 | timer T := 3.0; |
| 6217 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6218 | T.start; |
| 6219 | /* Expect RLL DATA IND on RSL side */ |
| 6220 | alt { |
| 6221 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6222 | setverdict(pass); |
| 6223 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6224 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6225 | [] as_rsl_any_ind(exp_any); |
| 6226 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6227 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6228 | } |
| 6229 | } |
| 6230 | } |
| 6231 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6232 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6233 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6234 | f_l1_tune(L1CTL); |
| 6235 | f_est_dchan(true); |
| 6236 | |
| 6237 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6238 | var L1ctlDlMessage dl; |
| 6239 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6240 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6241 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6242 | |
| 6243 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6244 | f_unitdata_mt(link_id, l3); |
| 6245 | |
| 6246 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6247 | f_unitdata_mo(link_id, l3); |
| 6248 | |
| 6249 | /* release the channel */ |
| 6250 | f_rsl_chan_deact(); |
| 6251 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6252 | f_rslem_unregister(0, g_chan_nr); |
| 6253 | } |
| 6254 | testcase TC_chan_act_a51() runs on test_CT { |
| 6255 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6256 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6257 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6258 | } |
| 6259 | testcase TC_chan_act_a52() runs on test_CT { |
| 6260 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6261 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6262 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6263 | } |
| 6264 | testcase TC_chan_act_a53() runs on test_CT { |
| 6265 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6266 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6267 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6268 | } |
| 6269 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6270 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6271 | which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6272 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6273 | f_l1_tune(L1CTL); |
| 6274 | f_est_dchan(true); |
| 6275 | |
| 6276 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6277 | var L1ctlDlMessage dl; |
| 6278 | |
| 6279 | var octetstring l3 := f_rnd_octstring(20); |
| 6280 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6281 | |
| 6282 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6283 | f_unitdata_mt(link_id, l3); |
| 6284 | |
| 6285 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6286 | f_unitdata_mo(link_id, l3); |
| 6287 | |
| 6288 | var RSL_Message rsl; |
| 6289 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false)))); |
| 6290 | |
| 6291 | /* modify key to break proper encryption */ |
| 6292 | g_pars.encr.key := f_rnd_octstring(8); |
| 6293 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6294 | rsl.ies := rsl.ies & { ei }; |
| 6295 | RSL.send(rsl); |
| 6296 | |
| 6297 | timer T0 := 1.0; |
| 6298 | T0.start; |
| 6299 | /* Expect RSL MODIFY ACK */ |
| 6300 | alt { |
| 6301 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6302 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6303 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6304 | } |
| 6305 | [] T0.timeout { |
| 6306 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6307 | } |
| 6308 | } |
| 6309 | |
| 6310 | var octetstring l3msg := f_rnd_octstring(15); |
| 6311 | timer T1 := 3.0; |
| 6312 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6313 | due to broken encryption */ |
| 6314 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6315 | T1.start; |
| 6316 | alt { |
| 6317 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6318 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6319 | } |
| 6320 | [] T1.timeout { |
| 6321 | setverdict(pass); |
| 6322 | } |
| 6323 | } |
| 6324 | |
| 6325 | /* release the channel */ |
| 6326 | f_rsl_chan_deact(); |
| 6327 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6328 | f_rslem_unregister(0, g_chan_nr); |
| 6329 | } |
| 6330 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6331 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6332 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6333 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6334 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6335 | |
| 6336 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6337 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6338 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6339 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6340 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6341 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6342 | |
| 6343 | f_l1_tune(L1CTL); |
| 6344 | |
| 6345 | /* first establish a dedicated channel in the clear */ |
| 6346 | f_est_dchan(false); |
| 6347 | |
| 6348 | /* Establish ABM */ |
| 6349 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6350 | |
| 6351 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6352 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6353 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6354 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6355 | |
| 6356 | /* configure L1 to apply ciphering */ |
| 6357 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6358 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6359 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6360 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6361 | f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6362 | |
| 6363 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6364 | * and hence enable encryption also on the downlink */ |
| 6365 | |
| 6366 | /* expect bi-directional communication work in encrypted mode */ |
| 6367 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6368 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6369 | |
| 6370 | /* release the channel */ |
| 6371 | f_rsl_chan_deact(); |
| 6372 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6373 | f_rslem_unregister(0, g_chan_nr); |
| 6374 | } |
| 6375 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6376 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6377 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6378 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6379 | } |
| 6380 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6381 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6382 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6383 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6384 | } |
| 6385 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6386 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6387 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6388 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6389 | } |
| 6390 | |
| 6391 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6392 | var LapdmFrame lf; |
| 6393 | var octetstring reenc; |
| 6394 | |
| 6395 | /* decode the LAPDm frame */ |
| 6396 | if (ischosen(exp_match.ab)) { |
| 6397 | lf.ab := dec_LapdmFrameAB(enc); |
| 6398 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6399 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6400 | } |
| 6401 | |
| 6402 | /* check if decoder result matches expectation */ |
| 6403 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6404 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match")); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6405 | } else { |
| 6406 | log(name, ": matched"); |
| 6407 | setverdict(pass); |
| 6408 | } |
| 6409 | |
| 6410 | /* test if re-encoded frame equals original input */ |
| 6411 | reenc := enc_LapdmFrame(lf); |
| 6412 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6413 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match")); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6414 | } else { |
| 6415 | setverdict(pass); |
| 6416 | } |
| 6417 | } |
| 6418 | |
| 6419 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6420 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6421 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6422 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6423 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6424 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6425 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6426 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6427 | } |
| 6428 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6429 | /*********************************************************************** |
| 6430 | * DTX Related (see GSM 05.08, section 8.3) |
| 6431 | ***********************************************************************/ |
| 6432 | |
| 6433 | /* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6434 | private function f_g_chan_is_tchf() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6435 | return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or |
| 6436 | g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or |
| 6437 | g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or |
| 6438 | g_chan_nr == valueof(ts_RslChanNr_Bm(4))); |
| 6439 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6440 | private function f_g_chan_is_tchh() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6441 | return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or |
| 6442 | g_chan_nr == valueof(ts_RslChanNr_Lm(5,1))); |
| 6443 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6444 | private function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6445 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or |
| 6446 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or |
| 6447 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or |
| 6448 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3))); |
| 6449 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6450 | private function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6451 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or |
| 6452 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or |
| 6453 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or |
| 6454 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or |
| 6455 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or |
| 6456 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or |
| 6457 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or |
| 6458 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7))); |
| 6459 | } |
| 6460 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6461 | private function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6462 | var L1ctlDlMessage dl; |
| 6463 | var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 6464 | var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2); |
| 6465 | var GsmFrameNumber first_fn; |
| 6466 | var boolean is_first_frame := true; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6467 | var integer nfill_frames_sacch := 0; |
| 6468 | var integer nfill_frames_nonsacch := 0; |
| 6469 | var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */ |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6470 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6471 | var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 }; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6472 | const integer frame_dtx_tchf_mod := 104; |
| 6473 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6474 | * which operates in terms of blocks rather than frames. */ |
| 6475 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6476 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6477 | timer T := 5.0; |
| 6478 | |
| 6479 | f_l1_tune(L1CTL); |
| 6480 | RSL.clear; |
| 6481 | L1CTL.clear; |
| 6482 | |
| 6483 | /* activate TCHF signalling channel */ |
| 6484 | f_est_dchan(false); |
| 6485 | |
| 6486 | T.start; |
| 6487 | alt { |
| 6488 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6489 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
| 6490 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6491 | |
| 6492 | if (is_first_frame) { |
| 6493 | is_first_frame := false; |
| 6494 | first_fn := dl.dl_info.frame_nr; |
| 6495 | } |
| 6496 | |
| 6497 | if (dl.dl_info.link_id.c == SACCH) { |
| 6498 | l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */ |
| 6499 | if (not match(l2_fill_frame_sacch, l2)) { |
| 6500 | repeat; |
| 6501 | } |
| 6502 | } else if (not match(l2_fill_frame, l2)) { |
| 6503 | repeat; |
| 6504 | } |
| 6505 | |
| 6506 | if (dtxd) { |
| 6507 | if (not f_g_chan_is_tchf()) { |
| 6508 | T.stop; |
| 6509 | f_rsl_chan_deact(); |
| 6510 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6511 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6512 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6513 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6514 | T.stop; |
| 6515 | f_rsl_chan_deact(); |
| 6516 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6517 | |
| 6518 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. |
| 6519 | * 2 SACCH, 1 TCH/F */ |
| 6520 | expected_fill_frames := 3; |
| 6521 | |
| 6522 | if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) { |
| 6523 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6524 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6525 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6526 | } else { |
| 6527 | setverdict(pass); |
| 6528 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6529 | } else { |
| 6530 | if (dl.dl_info.link_id.c == SACCH) { |
| 6531 | nfill_frames_sacch := nfill_frames_sacch + 1; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6532 | repeat; |
| 6533 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6534 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6535 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6536 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6537 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6538 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6539 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
| 6540 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6541 | repeat; |
| 6542 | } |
| 6543 | } |
| 6544 | log("Received DTX TCH fill frame with bad frame number: ", fn, |
| 6545 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6546 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
| 6547 | f_rsl_chan_deact(); |
| 6548 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6550 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6551 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6552 | if (dl.dl_info.link_id.c == SACCH) { |
| 6553 | nfill_frames_sacch := nfill_frames_sacch + 1; |
| 6554 | } else { |
| 6555 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6556 | } |
| 6557 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6558 | T.stop; |
| 6559 | if (f_g_chan_is_tchf()) { |
| 6560 | /* Without DTX we can expect 25 fill frames for every 104 frames. |
| 6561 | * (24 FACCH + 1 SACCH filling) */ |
| 6562 | expected_fill_frames := 25; |
| 6563 | } else if (f_g_chan_is_tchh()) { |
| 6564 | /* We can expect 2 fill frames for every 104 frames. */ |
| 6565 | expected_fill_frames := 2; |
| 6566 | } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) { |
| 6567 | /* We can expect 5 fill frames for every 104 frames. */ |
| 6568 | expected_fill_frames := 5; |
| 6569 | } else { |
| 6570 | f_rsl_chan_deact(); |
| 6571 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6572 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6573 | } |
| 6574 | |
| 6575 | f_rsl_chan_deact(); |
| 6576 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6577 | |
| 6578 | if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6579 | setverdict(pass); |
| 6580 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6581 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6582 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6583 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6584 | } |
| 6585 | } else { |
| 6586 | repeat; |
| 6587 | } |
| 6588 | } |
| 6589 | } |
| 6590 | [] L1CTL.receive { repeat; } |
| 6591 | [] T.timeout { |
| 6592 | f_rsl_chan_deact(); |
| 6593 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6594 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6595 | } |
| 6596 | } |
| 6597 | } |
| 6598 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6599 | private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6600 | f_test_l2_fill_frames(false); |
| 6601 | } |
| 6602 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6603 | private function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6604 | f_test_l2_fill_frames(true); |
| 6605 | } |
| 6606 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6607 | private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6608 | var ConnHdlr vc_conn; |
| 6609 | var ConnHdlrPars pars; |
| 6610 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6611 | f_init(); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6612 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 6613 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd))); |
| 6614 | if (dtxd) { |
| 6615 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6616 | break; |
| 6617 | } |
| 6618 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6619 | } else { |
| 6620 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6621 | } |
| 6622 | vc_conn.done; |
| 6623 | } |
| 6624 | } |
| 6625 | |
| 6626 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6627 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6628 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6629 | f_tch_sign_l2_fill_frame(false); |
| 6630 | } |
| 6631 | |
| 6632 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6633 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6634 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6635 | f_tch_sign_l2_fill_frame(true); |
| 6636 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6637 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6638 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6639 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6640 | } |
| 6641 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6642 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6643 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6644 | } |
| 6645 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6646 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 6647 | /* protocol error as per 44.006 */ |
| 6648 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 6649 | /* repetition of SABM or DISC N200 times without ACK */ |
| 6650 | /* receptiom of SABM in multi-frame established state */ |
| 6651 | |
| 6652 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6653 | /* TODO Areas: |
| 6654 | |
| 6655 | * channel activation |
| 6656 | ** with BS_Power / MS_Power, bypassing power control loop |
| 6657 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6658 | ** with timing advance from initial activation on |
| 6659 | * mode modify |
| 6660 | ** encryption |
| 6661 | ** multirate |
| 6662 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6663 | ** unsupported algorithm |
| 6664 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6665 | * BS Power Control |
| 6666 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6667 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6668 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6669 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6670 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6671 | ** DATA_IND from BTS->PCU |
| 6672 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6673 | |
| 6674 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6675 | |
| 6676 | control { |
| 6677 | execute( TC_chan_act_stress() ); |
| 6678 | execute( TC_chan_act_react() ); |
| 6679 | execute( TC_chan_deact_not_active() ); |
| 6680 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 6681 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 6682 | execute( TC_sacch_filling() ); |
| 6683 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 6684 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 6685 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 6686 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 6687 | execute( TC_sacch_chan_act_ho_async() ); |
| 6688 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6689 | execute( TC_rach_content() ); |
| 6690 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 6691 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 6692 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 6693 | execute( TC_rach_load_idle_thresh0() ); |
| 6694 | execute( TC_rach_load_idle_below_thresh() ); |
| 6695 | execute( TC_rach_load_count() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6696 | execute( TC_meas_res_sign_tchf() ); |
| 6697 | execute( TC_meas_res_sign_tchh() ); |
| 6698 | execute( TC_meas_res_sign_sdcch4() ); |
| 6699 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 6700 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 6701 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 6702 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 6703 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 6704 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 6705 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 6706 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 6707 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 6708 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 6709 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 6710 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 6711 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 6712 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 6713 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 6714 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6715 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6716 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6717 | execute( TC_paging_imsi_80percent() ); |
| 6718 | execute( TC_paging_tmsi_80percent() ); |
| 6719 | execute( TC_paging_imsi_200percent() ); |
| 6720 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 6721 | execute( TC_rsl_protocol_error() ); |
| 6722 | execute( TC_rsl_mand_ie_error() ); |
| 6723 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6724 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 6725 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6726 | execute( TC_si_sched_2bis() ); |
| 6727 | execute( TC_si_sched_2ter() ); |
| 6728 | execute( TC_si_sched_2ter_2bis() ); |
| 6729 | execute( TC_si_sched_2quater() ); |
| 6730 | execute( TC_si_sched_13() ); |
| 6731 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 6732 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 6733 | execute( TC_ipa_crcx_twice_not_active() ); |
| 6734 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 6735 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 6736 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6737 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6738 | if (mp_pcu_socket != "") { |
| 6739 | execute( TC_pcu_act_req() ); |
| 6740 | execute( TC_pcu_act_req_wrong_ts() ); |
| 6741 | execute( TC_pcu_act_req_wrong_bts() ); |
| 6742 | execute( TC_pcu_act_req_wrong_trx() ); |
| 6743 | execute( TC_pcu_deact_req() ); |
| 6744 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 6745 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6746 | if (mp_l1_supports_gprs) { |
| 6747 | execute( TC_pcu_data_req_pdtch() ); |
| 6748 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 6749 | execute( TC_pcu_data_req_wrong_bts() ); |
| 6750 | execute( TC_pcu_data_req_wrong_trx() ); |
| 6751 | execute( TC_pcu_data_req_wrong_ts() ); |
| 6752 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6753 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 6754 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6755 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 6756 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6757 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 6758 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 6759 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 6760 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6761 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6762 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6763 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6764 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6765 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6766 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6767 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6768 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6769 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6770 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6771 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6772 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6773 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6774 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 6775 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 6776 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 6777 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 6778 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 6779 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6780 | } else { |
| 6781 | log("PCU socket path not available, skipping PCU tests"); |
| 6782 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6783 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6784 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6785 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 6786 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6787 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 6788 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6789 | |
| 6790 | execute( TC_rll_est_ind() ); |
| 6791 | execute( TC_rll_est_req_DCCH_3() ); |
| 6792 | execute( TC_rll_est_req_ACCH_3() ); |
| 6793 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 6794 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 6795 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 6796 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 6797 | execute( TC_rll_rel_req() ); |
| 6798 | execute( TC_rll_unit_data_req_DCCH() ); |
| 6799 | execute( TC_rll_unit_data_req_ACCH() ); |
| 6800 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 6801 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6802 | |
| 6803 | execute( TC_chan_act_a51() ); |
| 6804 | execute( TC_chan_act_a52() ); |
| 6805 | execute( TC_chan_act_a53() ); |
| 6806 | execute( TC_encr_cmd_a51() ); |
| 6807 | execute( TC_encr_cmd_a52() ); |
| 6808 | execute( TC_encr_cmd_a53() ); |
| 6809 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 6810 | execute( TC_err_rep_wrong_mdisc() ); |
| 6811 | execute( TC_err_rep_wrong_msg_type() ); |
| 6812 | execute( TC_err_rep_wrong_sequence() ); |
| 6813 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6814 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6815 | |
| 6816 | execute( TC_tch_sign_l2_fill_frame() ); |
| 6817 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6818 | |
| 6819 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6820 | execute( TC_chopped_ipa_payload() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6821 | } |
| 6822 | |
| 6823 | |
| 6824 | } |