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; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 38 | import from Native_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 39 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 40 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 41 | |
| 42 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 43 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 44 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 45 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 46 | import from RSL_Emulation all; |
| 47 | |
| 48 | import from IPL4asp_Types all; |
| 49 | import from TRXC_Types all; |
| 50 | import from TRXC_CodecPort all; |
| 51 | import from TRXC_CodecPort_CtrlFunct all; |
| 52 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 53 | import from PCUIF_Types all; |
| 54 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 55 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 56 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 57 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 58 | import from MobileL3_RRM_Types all; |
| 59 | import from MobileL3_Types all; |
| 60 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 61 | import from L3_Common all; |
| 62 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 63 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 64 | import from Osmocom_VTY_Functions all; |
| 65 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 66 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 67 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 68 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 69 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 70 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 71 | friend module BTS_Tests_perf; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 72 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 73 | /* The tests assume a BTS with the following timeslot configuration: |
| 74 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 75 | * TS1 : TCH/F |
| 76 | * TS2 : TCH/F |
| 77 | * TS3 : TCH/F_PDCH (IPA Style) |
| 78 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 79 | * TS5 : TCH/H |
| 80 | * TS6 : SDCCH/8 |
| 81 | * TS7 : PDCH |
| 82 | */ |
| 83 | |
| 84 | modulepar { |
| 85 | charstring mp_rsl_ip := "127.0.0.2"; |
| 86 | integer mp_rsl_port := 3003; |
| 87 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 88 | integer mp_trx1_arfcn := 873; |
| 89 | integer mp_trx2_arfcn := 875; |
| 90 | integer mp_trx3_arfcn := 877; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 91 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 92 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 93 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 94 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 95 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 96 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 97 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 98 | integer mp_tolerance_rxqual := 1; |
| 99 | integer mp_tolerance_rxlev := 3; |
| 100 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 101 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 102 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 103 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 104 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 105 | 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] | 106 | integer mp_ms_actual_ta_exp := 0; |
| 107 | integer mp_timing_offset_256syms_exp := 512; |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 108 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 109 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 110 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 111 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 112 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 113 | /* how many transceivers do we expect to connect */ |
| 114 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 115 | /* frequency hopping status */ |
| 116 | boolean mp_freq_hop_enabled := false; |
| 117 | /* frequency hopping parameters */ |
| 118 | FreqHopConfig mp_fh_config; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 119 | } |
| 120 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 121 | type record of RslChannelNr ChannelNrs; |
| 122 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 123 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 124 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 125 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 126 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 127 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 128 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 129 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 130 | |
| 131 | /* L1CTL port (for classic tests) */ |
| 132 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 133 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 134 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 135 | port TRXC_CODEC_PT BTS_TRXC; |
| 136 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 137 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 138 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 139 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 140 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 141 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 142 | /* PCU Interface of BTS */ |
| 143 | port PCUIF_CODEC_PT PCU; |
| 144 | var integer g_pcu_conn_id; |
| 145 | /* Last PCU INFO IND we received */ |
| 146 | var PCUIF_Message g_pcu_last_info; |
| 147 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 148 | /* SI configuration */ |
| 149 | var SystemInformationConfig si_cfg := { |
| 150 | bcch_extended := false, |
| 151 | si1_present := false, |
| 152 | si2bis_present := false, |
| 153 | si2ter_present := false, |
| 154 | si2quater_present := false, |
| 155 | si7_present := false, |
| 156 | si8_present := false, |
| 157 | si9_present := false, |
| 158 | si13_present := false, |
| 159 | si13alt_present := false, |
| 160 | si15_present := false, |
| 161 | si16_present := false, |
| 162 | si17_present := false, |
| 163 | si2n_present := false, |
| 164 | si21_present := false, |
| 165 | si22_present := false |
| 166 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 167 | |
| 168 | /* all logical channels available on the BTS */ |
| 169 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 170 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 174 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 175 | port L1CTL_PT L1CTL; |
| 176 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 177 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 178 | port TRXC_CODEC_PT BTS_TRXC; |
| 179 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 180 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 181 | /* port to be initialized optionally to access BSC VTY */ |
| 182 | port TELNETasp_PT BSCVTY; |
| 183 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 184 | timer g_Tguard; |
| 185 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 186 | |
| 187 | var ConnHdlrPars g_pars; |
| 188 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 189 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 190 | |
| 191 | /* PCU Interface of BTS */ |
| 192 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 193 | } |
| 194 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 195 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 196 | var bitstring trx_mask := '00000000'B; |
| 197 | var integer trx_count := 0; |
| 198 | var RSLEm_Event ev; |
| 199 | timer T; |
| 200 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 201 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 202 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 203 | |
| 204 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 205 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 206 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 207 | |
| 208 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 209 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 210 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 211 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 212 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 213 | T.start(mp_ipa_up_timeout); |
| 214 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 215 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 216 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 217 | /* Make sure that all transceivers use unique stream ID */ |
| 218 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 219 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 220 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 221 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 222 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 223 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 224 | RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ev.sid)); |
| 225 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 226 | trx_count := trx_count + 1; |
| 227 | |
| 228 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
| 229 | if (trx_count < mp_transceiver_num) { repeat; } |
| 230 | } |
| 231 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 232 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 233 | [] T.timeout { |
| 234 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 235 | "Timeout waiting for RSL bring up"); |
| 236 | } |
| 237 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 238 | } |
| 239 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 240 | friend type record FreqHopPars { |
| 241 | /* Whether frequency hopping is in use */ |
| 242 | boolean enabled, |
| 243 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 244 | MaioHsn maio_hsn, |
| 245 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 246 | MobileAllocationLV ma_map, |
| 247 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 248 | L1ctlMA ma |
| 249 | }; |
| 250 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 251 | type record ConnHdlrPars { |
| 252 | RslChannelNr chan_nr, |
| 253 | RSL_IE_ChannelMode chan_mode, |
| 254 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 255 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 256 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 257 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 258 | BtsBand bts0_band optional, |
| 259 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 260 | /* Frequency hopping parameters */ |
| 261 | FreqHopPars fhp |
| 262 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 263 | |
| 264 | /* Test-specific parameters */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 265 | private type union TestSpecUnion { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 266 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 267 | } |
| 268 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 269 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 270 | max_retrans := RACH_MAX_RETRANS_7, |
| 271 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 272 | cell_barr_access := false, |
| 273 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 274 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 275 | }; |
| 276 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 277 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 278 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 279 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 280 | acs := '0'B, |
| 281 | neci := true, |
| 282 | rxlev_access_min := 0 |
| 283 | } |
| 284 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 285 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 286 | mcc_mnc := '262F42'H, |
| 287 | lac := 42 |
| 288 | } |
| 289 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 290 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 291 | ra_colour := 0, |
| 292 | si13_pos := '0'B |
| 293 | } |
| 294 | |
| 295 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 296 | modifies ts_SI3RestOctets := { |
| 297 | gprs_ind := { |
| 298 | presence := CSN1_H, |
| 299 | ind := ts_GPRSIndicator_def |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 304 | modifies ts_SI4RestOctets := { |
| 305 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 306 | presence := CSN1_H, |
| 307 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 311 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 312 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 313 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 314 | payload := { |
| 315 | si3 := { |
| 316 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 317 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 318 | ctrl_chan_desc := { |
| 319 | msc_r99 := true, |
| 320 | att := true, |
| 321 | bs_ag_blks_res := 1, |
| 322 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 323 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 324 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 325 | spare := '00'B, |
| 326 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 327 | t3212 := 1 /* 6 minutes */ |
| 328 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 329 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 330 | dn_ind := false, |
| 331 | pwrc := false, |
| 332 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 333 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 334 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 335 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 336 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 337 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 341 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 342 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 343 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 344 | payload := { |
| 345 | si2 := { |
| 346 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 347 | ncc_permitted := '11111111'B, |
| 348 | rach_control := ts_RachCtrl_default |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 353 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 354 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 355 | payload := { |
| 356 | si4 := { |
| 357 | lai := ts_LAI_default, |
| 358 | cell_sel_par := ts_CellSelPar_default, |
| 359 | rach_control := ts_RachCtrl_default, |
| 360 | cbch_chan_desc := omit, |
| 361 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 362 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 367 | 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] | 368 | runs on test_CT { |
| 369 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 370 | 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] | 371 | } |
| 372 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 373 | 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] | 374 | runs on test_CT { |
| 375 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 376 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 377 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 378 | } |
| 379 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 380 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 381 | map(self:BTSVTY, system:BTSVTY); |
| 382 | f_vty_set_prompts(BTSVTY); |
| 383 | f_vty_transceive(BTSVTY, "enable"); |
| 384 | } |
| 385 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 386 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 387 | map(self:BSCVTY, system:BSCVTY); |
| 388 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 389 | f_vty_transceive(BSCVTY, "enable"); |
| 390 | } |
| 391 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 392 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 393 | map(self:BSCVTY, system:BSCVTY); |
| 394 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 395 | f_vty_transceive(BSCVTY, "enable"); |
| 396 | } |
| 397 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 398 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 399 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 400 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 401 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 402 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 403 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 404 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 405 | [] 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] | 406 | 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] | 407 | } |
| 408 | } |
| 409 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 410 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 411 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 412 | timer T := 2.0; |
| 413 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 414 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 415 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 416 | return; |
| 417 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 418 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 419 | |
| 420 | T.start; |
| 421 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 422 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 423 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 424 | 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] | 425 | } |
| 426 | } |
| 427 | } |
| 428 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 429 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 430 | out integer trxc_conn_id) { |
| 431 | var Result res; |
| 432 | |
| 433 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 434 | "", -1, -1, { udp := {} }, {}); |
| 435 | if (not ispresent(res.connId)) { |
| 436 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 437 | "Could not connect to the control (TRXC) interface " & |
| 438 | "of FakeTRX, check your configuration"); |
| 439 | } |
| 440 | trxc_conn_id := res.connId; |
| 441 | } |
| 442 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 443 | /* global init function */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 444 | friend function f_init() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 445 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 446 | g_AllChannels := { |
| 447 | /* TS 1..4: TCH/F */ |
| 448 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 449 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 450 | /* TS 5: TCH/H */ |
| 451 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 452 | /* TS 0: SDCCH/4 */ |
| 453 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 454 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 455 | /* TS 6: SDCCH/8 */ |
| 456 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 457 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 458 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 459 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 460 | }; |
| 461 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 462 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 463 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 464 | g_AllChanTypes := { |
| 465 | /* TS 1..4: TCH/F */ |
| 466 | valueof(ts_RslChanNr_Bm(1)), |
| 467 | /* TS 5: TCH/H */ |
| 468 | valueof(ts_RslChanNr_Lm(5,1)), |
| 469 | /* TS 0: SDCCH/4 */ |
| 470 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 471 | /* TS 6: SDCCH/8 */ |
| 472 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 473 | }; |
| 474 | } else { |
| 475 | g_AllChanTypes := { |
| 476 | /* TS 1..4: TCH/F */ |
| 477 | valueof(ts_RslChanNr_Bm(1)), |
| 478 | /* TS 0: SDCCH/4 */ |
| 479 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 480 | /* TS 6: SDCCH/8 */ |
| 481 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 482 | }; |
| 483 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 484 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 485 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 486 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 487 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 488 | |
| 489 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 490 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 491 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 492 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 493 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 494 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 495 | map(self:PCU, system:PCU); |
| 496 | 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] | 497 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 498 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 499 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 500 | |
| 501 | /* Init TRXC interface to FakeTRX */ |
| 502 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 503 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 504 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 505 | /* 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] | 506 | 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] | 507 | 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] | 508 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 509 | 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] | 510 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 511 | |
| 512 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 513 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 514 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 515 | } |
| 516 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 517 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 518 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 519 | map(self:L1CTL, system:L1CTL); |
| 520 | f_connect_reset(L1CTL); |
| 521 | } |
| 522 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 523 | private type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 524 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 525 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 526 | |
| 527 | private type record of FreqHopGroup FreqHopGroups; |
| 528 | private type record FreqHopGroup { |
| 529 | uint6_t hsn, |
| 530 | FreqHopGroupItems trx_maio |
| 531 | }; |
| 532 | |
| 533 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 534 | private type record FreqHopGroupItem { |
| 535 | uint8_t trx_nr, |
| 536 | uint6_t maio |
| 537 | }; |
| 538 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 539 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 540 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 541 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 542 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 543 | var integer i, j; |
| 544 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 545 | fhp.enabled := false; |
| 546 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 547 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 548 | var FreqHopGroup g := groups[i]; |
| 549 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 550 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 551 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 552 | fhp.maio_hsn.maio := gi.maio; |
| 553 | fhp.maio_hsn.hsn := g.hsn; |
| 554 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 555 | break; |
| 556 | } |
| 557 | } |
| 558 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 559 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 560 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 561 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 562 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 563 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 564 | |
| 565 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 566 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 567 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 568 | fhp.ma := fhp.ma & { l1ctl_ma_def[gi.trx_nr] }; |
| 569 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 570 | } |
| 571 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 572 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 573 | break; /* We're done */ |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 578 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 579 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 580 | boolean pcu_comp := false, |
| 581 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 582 | runs on test_CT return ConnHdlr { |
| 583 | var charstring id := testcasename(); |
| 584 | var ConnHdlr vc_conn; |
| 585 | |
| 586 | vc_conn := ConnHdlr.create(id); |
| 587 | /* connect to RSL Emulation main component */ |
| 588 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 589 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 590 | |
| 591 | /* The ConnHdlr component may want to talk to some ports directly, |
| 592 | * so we disconnect it from the test_CT and connect it to the component. |
| 593 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 594 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 595 | unmap(self:PCU, system:PCU); |
| 596 | map(vc_conn:PCU, system:PCU); |
| 597 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 598 | if (trxc_comp) { |
| 599 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 600 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 601 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 602 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 603 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 604 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 605 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 606 | } |
| 607 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 608 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 609 | return vc_conn; |
| 610 | } |
| 611 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 612 | private altstep as_Tguard() runs on ConnHdlr { |
| 613 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 614 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 618 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 619 | 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] | 620 | } |
| 621 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 622 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 623 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 624 | 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] | 625 | } |
| 626 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 627 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 628 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 629 | 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] | 630 | } |
| 631 | |
| 632 | /* first function started in ConnHdlr component */ |
| 633 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 634 | runs on ConnHdlr { |
| 635 | g_pars := pars; |
| 636 | g_chan_nr := pars.chan_nr; |
| 637 | |
| 638 | map(self:L1CTL, system:L1CTL); |
| 639 | f_connect_reset(L1CTL); |
| 640 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 641 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 642 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 643 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 644 | |
| 645 | g_Tguard.start(pars.t_guard); |
| 646 | activate(as_Tguard()); |
| 647 | |
| 648 | f_rslem_register(0, pars.chan_nr); |
| 649 | |
| 650 | /* call the user-supplied test case function */ |
| 651 | fn.apply(id); |
| 652 | } |
| 653 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 654 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 655 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 656 | runs on ConnHdlr return RSL_Message { |
| 657 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 658 | timer T := 3.0; |
| 659 | RSL.send(tx); |
| 660 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 661 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 662 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 663 | T.stop; |
| 664 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 665 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 666 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 667 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 668 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 669 | [not ignore_other] as_l1_sacch(); |
| 670 | [not ignore_other] as_meas_res(); |
| 671 | [not ignore_other] as_l1_dcch(); |
| 672 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 673 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 674 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 675 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 676 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 677 | return rx; |
| 678 | } |
| 679 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 680 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 681 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 682 | runs on ConnHdlr { |
| 683 | 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] | 684 | } |
| 685 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 686 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 687 | boolean encr_enable := false, |
| 688 | RSL_IE_List more_ies := {}, |
| 689 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 690 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 691 | 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] | 692 | if (encr_enable) { |
| 693 | /* append encryption related IEs, if requested */ |
| 694 | var RSL_IE_EncryptionInfo encr_info; |
| 695 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 696 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 697 | encr_info})) }; |
| 698 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 699 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 700 | 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] | 701 | } |
| 702 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 703 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 704 | 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] | 705 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 706 | } |
| 707 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 708 | /* Default Mobile Allocation to be used for frequency hopping */ |
| 709 | private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn }, |
| 710 | { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } }; |
| 711 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 712 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 713 | template RSL_IE_ChannelMode chan_mode, |
| 714 | float t_guard := 20.0) := { |
| 715 | chan_nr := valueof(chan_nr), |
| 716 | chan_mode := valueof(chan_mode), |
| 717 | t_guard := t_guard, |
| 718 | l1_pars := { |
| 719 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 720 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 721 | meas_ul := { |
| 722 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 723 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 724 | rxqual := 0 |
| 725 | }, |
| 726 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 727 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 728 | rxqual := 0 |
| 729 | } |
| 730 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 731 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 732 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 733 | ms_power_level := mp_ms_power_level_exp, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 734 | ms_actual_ta := mp_ms_actual_ta_exp |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 735 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 736 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 737 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 738 | bts0_band := omit, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 739 | fhp := { |
| 740 | enabled := false, |
| 741 | maio_hsn := ts_HsnMaio(0, 0), |
| 742 | ma_map := c_MA_null, |
| 743 | ma := l1ctl_ma_def |
| 744 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 745 | } |
| 746 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 747 | /*********************************************************************** |
| 748 | * Channel Activation / Deactivation |
| 749 | ***********************************************************************/ |
| 750 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 751 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 752 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 753 | for (var integer i := 0; i < 500; i := i+1) { |
| 754 | f_rsl_chan_act(g_pars.chan_mode); |
| 755 | f_rsl_chan_deact(); |
| 756 | } |
| 757 | setverdict(pass); |
| 758 | } |
| 759 | testcase TC_chan_act_stress() runs on test_CT { |
| 760 | var ConnHdlr vc_conn; |
| 761 | 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] | 762 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 763 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 764 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 765 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 769 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 770 | f_rsl_chan_act(g_pars.chan_mode); |
| 771 | /* attempt to activate the same lchan again -> expect reject */ |
| 772 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 773 | alt { |
| 774 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 775 | 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] | 776 | } |
| 777 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 778 | setverdict(pass); |
| 779 | } |
| 780 | } |
| 781 | f_rsl_chan_deact(); |
| 782 | } |
| 783 | testcase TC_chan_act_react() runs on test_CT { |
| 784 | var ConnHdlr vc_conn; |
| 785 | 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] | 786 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 787 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 788 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 789 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 793 | 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] | 794 | timer T := 3.0; |
| 795 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 796 | T.start; |
| 797 | alt { |
| 798 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 799 | setverdict(pass); |
| 800 | } |
| 801 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 802 | 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] | 803 | } |
| 804 | } |
| 805 | } |
| 806 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 807 | 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] | 808 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 809 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 810 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 811 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 815 | 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] | 816 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 817 | alt { |
| 818 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 819 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 820 | } |
| 821 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 822 | setverdict(pass); |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | private type record WrongChanNrCase { |
| 827 | RslChannelNr chan_nr, |
| 828 | charstring description |
| 829 | } |
| 830 | private type record of WrongChanNrCase WrongChanNrCases; |
| 831 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 832 | chan_nr := chan_nr, |
| 833 | description := desc |
| 834 | } |
| 835 | |
| 836 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 837 | var ConnHdlr vc_conn; |
| 838 | var ConnHdlrPars pars; |
| 839 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 840 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 841 | |
| 842 | var WrongChanNrCases wrong := { |
| 843 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 844 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 845 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 846 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 847 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 848 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 849 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 850 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 851 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 852 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 853 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 854 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 855 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 856 | }; |
| 857 | |
| 858 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 859 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 860 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 861 | vc_conn.done; |
| 862 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 863 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 864 | } |
| 865 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 866 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 867 | 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] | 868 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 869 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 870 | |
| 871 | /* test on each of the channels we have */ |
| 872 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 873 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 874 | |
| 875 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 876 | vc_conn := f_start_handler(fn, pars); |
| 877 | vc_conn.done; |
| 878 | } |
| 879 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 880 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 881 | } |
| 882 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 883 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 884 | * SACCH handling |
| 885 | ***********************************************************************/ |
| 886 | |
| 887 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 888 | timer T_sacch := 3.0; |
| 889 | T_sacch.start; |
| 890 | alt { |
| 891 | [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] | 892 | 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] | 893 | } |
| 894 | [not exp] T_sacch.timeout { |
| 895 | setverdict(pass); |
| 896 | } |
| 897 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 898 | setverdict(pass); |
| 899 | } |
| 900 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 901 | 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] | 902 | } |
| 903 | [] L1CTL.receive { repeat; } |
| 904 | [] RSL.receive { repeat; } |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 909 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 910 | f_l1_tune(L1CTL); |
| 911 | RSL.clear; |
| 912 | |
| 913 | /* activate the logical channel */ |
| 914 | f_est_dchan(); |
| 915 | L1CTL.clear; |
| 916 | |
| 917 | /* check that SACCH actually are received as expected */ |
| 918 | f_exp_sacch(true); |
| 919 | |
| 920 | /* deactivate SACCH on the logical channel */ |
| 921 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 922 | f_sleep(1.0); |
| 923 | L1CTL.clear; |
| 924 | |
| 925 | /* check that no SACCH are received anymore */ |
| 926 | f_exp_sacch(false); |
| 927 | |
| 928 | /* release the channel */ |
| 929 | f_rsl_chan_deact(); |
| 930 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 931 | } |
| 932 | testcase TC_deact_sacch() runs on test_CT { |
| 933 | var ConnHdlr vc_conn; |
| 934 | var ConnHdlrPars pars; |
| 935 | f_init(); |
| 936 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 937 | //for (var integer i := 0; i < 1; i := i+1) { |
| 938 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 939 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 940 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 941 | vc_conn.done; |
| 942 | } |
| 943 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 944 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 945 | } |
| 946 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 947 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 948 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 949 | var L1ctlDlMessage dl; |
| 950 | /* check that the specified SI5 value is actually sent */ |
| 951 | timer T_sacch := 3.0; |
| 952 | L1CTL.clear; |
| 953 | T_sacch.start; |
| 954 | alt { |
| 955 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 956 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 957 | if (match(l3, l3_exp)) { |
| 958 | setverdict(pass); |
| 959 | } else { |
| 960 | repeat; |
| 961 | } |
| 962 | } |
| 963 | [] L1CTL.receive { repeat; } |
| 964 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 965 | 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] | 966 | } |
| 967 | } |
| 968 | } |
| 969 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 970 | /* verify that given SACCH payload is not present */ |
| 971 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 972 | var L1ctlDlMessage dl; |
| 973 | /* check that the specified SI5 value is actually sent */ |
| 974 | timer T_sacch := 3.0; |
| 975 | L1CTL.clear; |
| 976 | T_sacch.start; |
| 977 | alt { |
| 978 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 979 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 980 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 981 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 982 | } else { |
| 983 | repeat; |
| 984 | } |
| 985 | } |
| 986 | [] L1CTL.receive { repeat; } |
| 987 | [] T_sacch.timeout { |
| 988 | setverdict(pass); |
| 989 | } |
| 990 | } |
| 991 | } |
| 992 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 993 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 994 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 995 | /* Set a known default SACCH filling for SI5 */ |
| 996 | var octetstring si5 := f_rnd_octstring(19); |
| 997 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 998 | |
| 999 | f_l1_tune(L1CTL); |
| 1000 | RSL.clear; |
| 1001 | |
| 1002 | /* activate the logical channel */ |
| 1003 | f_est_dchan(); |
| 1004 | |
| 1005 | /* check that the specified SI5 value is actually sent */ |
| 1006 | f_sacch_present(si5); |
| 1007 | |
| 1008 | /* release the channel */ |
| 1009 | RSL.clear; |
| 1010 | f_rsl_chan_deact(); |
| 1011 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1012 | } |
| 1013 | testcase TC_sacch_filling() runs on test_CT { |
| 1014 | var ConnHdlr vc_conn; |
| 1015 | var ConnHdlrPars pars; |
| 1016 | f_init(); |
| 1017 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1018 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1019 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1020 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1021 | vc_conn.done; |
| 1022 | } |
| 1023 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1024 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1025 | } |
| 1026 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1027 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1028 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1029 | /* Set a known default SACCH filling for SI5 */ |
| 1030 | var octetstring si5 := f_rnd_octstring(19); |
| 1031 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1032 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1033 | |
| 1034 | f_l1_tune(L1CTL); |
| 1035 | RSL.clear; |
| 1036 | |
| 1037 | log("Activating channel, expecting standard SI5"); |
| 1038 | /* activate the logical channel */ |
| 1039 | f_est_dchan(); |
| 1040 | /* check that the specified SI5 value is actually sent */ |
| 1041 | f_sacch_present(si5); |
| 1042 | |
| 1043 | /* set channel-specific different SI5 */ |
| 1044 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1045 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1046 | /* check that the specified lchan-specific value is now used */ |
| 1047 | f_sacch_present(si5_diff); |
| 1048 | |
| 1049 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1050 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1051 | f_rsl_chan_deact(); |
| 1052 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1053 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1054 | f_sacch_present(si5); |
| 1055 | |
| 1056 | /* release the channel */ |
| 1057 | RSL.clear; |
| 1058 | f_rsl_chan_deact(); |
| 1059 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1060 | } |
| 1061 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1062 | var ConnHdlr vc_conn; |
| 1063 | var ConnHdlrPars pars; |
| 1064 | f_init(); |
| 1065 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1066 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1067 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1068 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1069 | vc_conn.done; |
| 1070 | } |
| 1071 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1072 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1073 | } |
| 1074 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1075 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1076 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1077 | var octetstring si5 := f_rnd_octstring(19); |
| 1078 | var octetstring si5bis := f_rnd_octstring(19); |
| 1079 | var octetstring si5ter := f_rnd_octstring(19); |
| 1080 | var octetstring si6 := f_rnd_octstring(19); |
| 1081 | |
| 1082 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1083 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1084 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1085 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1086 | |
| 1087 | f_l1_tune(L1CTL); |
| 1088 | RSL.clear; |
| 1089 | |
| 1090 | /* activate the logical channel */ |
| 1091 | f_est_dchan(); |
| 1092 | L1CTL.clear; |
| 1093 | |
| 1094 | /* check that SACCH actually are received as expected */ |
| 1095 | f_sacch_present(si5); |
| 1096 | f_sacch_present(si5bis); |
| 1097 | f_sacch_present(si5ter); |
| 1098 | f_sacch_present(si6); |
| 1099 | |
| 1100 | /* release the channel */ |
| 1101 | f_rsl_chan_deact(); |
| 1102 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1103 | } |
| 1104 | testcase TC_sacch_multi() runs on test_CT { |
| 1105 | var ConnHdlr vc_conn; |
| 1106 | var ConnHdlrPars pars; |
| 1107 | f_init(); |
| 1108 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1109 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1110 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1111 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1112 | vc_conn.done; |
| 1113 | } |
| 1114 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1115 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1116 | } |
| 1117 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1118 | /* Test if SACH information is modified as expected */ |
| 1119 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1120 | var octetstring si5 := f_rnd_octstring(19); |
| 1121 | var octetstring si6 := f_rnd_octstring(19); |
| 1122 | |
| 1123 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1124 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1125 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1126 | |
| 1127 | f_l1_tune(L1CTL); |
| 1128 | RSL.clear; |
| 1129 | |
| 1130 | /* activate the logical channel */ |
| 1131 | f_est_dchan(); |
| 1132 | L1CTL.clear; |
| 1133 | |
| 1134 | /* check that SACCH actually are received as expected */ |
| 1135 | f_sacch_present(si5); |
| 1136 | f_sacch_present(si6); |
| 1137 | |
| 1138 | /* disable SI6 */ |
| 1139 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1140 | |
| 1141 | /* check that SI5 is still transmitted */ |
| 1142 | f_sacch_present(si5); |
| 1143 | /* check if SI6 is now gone */ |
| 1144 | f_sacch_missing(si6); |
| 1145 | |
| 1146 | /* release the channel */ |
| 1147 | f_rsl_chan_deact(); |
| 1148 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1149 | } |
| 1150 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1151 | var ConnHdlr vc_conn; |
| 1152 | var ConnHdlrPars pars; |
| 1153 | f_init(); |
| 1154 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1155 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1156 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1157 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1158 | vc_conn.done; |
| 1159 | } |
| 1160 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1161 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1162 | } |
| 1163 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1164 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1165 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1166 | var octetstring si5 := f_rnd_octstring(19); |
| 1167 | var octetstring si6 := f_rnd_octstring(19); |
| 1168 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1169 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1170 | |
| 1171 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1172 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1173 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1174 | |
| 1175 | f_l1_tune(L1CTL); |
| 1176 | RSL.clear; |
| 1177 | |
| 1178 | /* activate channel with different SACCH filling */ |
| 1179 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1180 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1181 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1182 | })); |
| 1183 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1184 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1185 | f_est_dchan(more_ies := addl_ies); |
| 1186 | |
| 1187 | /* check that SACCH actually are received as expected */ |
| 1188 | f_sacch_present(si5_specific); |
| 1189 | f_sacch_present(si6_specific); |
| 1190 | |
| 1191 | /* release the channel */ |
| 1192 | f_rsl_chan_deact(); |
| 1193 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1194 | } |
| 1195 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1196 | var ConnHdlr vc_conn; |
| 1197 | var ConnHdlrPars pars; |
| 1198 | f_init(); |
| 1199 | |
| 1200 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1201 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1202 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1203 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1204 | vc_conn.done; |
| 1205 | } |
| 1206 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1207 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1208 | } |
| 1209 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1210 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1211 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1212 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1213 | var octetstring si5 := f_rnd_octstring(19); |
| 1214 | |
| 1215 | f_l1_tune(L1CTL); |
| 1216 | RSL.clear; |
| 1217 | |
| 1218 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1219 | |
| 1220 | /* Activate channel on BTS side */ |
| 1221 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1222 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1223 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1224 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1225 | |
| 1226 | /* Verify that no DL SACCH is being received */ |
| 1227 | f_sacch_missing(?); |
| 1228 | |
| 1229 | f_rsl_chan_deact(); |
| 1230 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1231 | |
| 1232 | |
| 1233 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1234 | |
| 1235 | /* Activate channel on BTS side */ |
| 1236 | var RSL_IE_List addl_ies := { |
| 1237 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1238 | }; |
| 1239 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1240 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1241 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1242 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1243 | |
| 1244 | /* Verify that DL SACCH is being received */ |
| 1245 | f_sacch_present(si5); |
| 1246 | |
| 1247 | f_rsl_chan_deact(); |
| 1248 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1249 | } |
| 1250 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1251 | var ConnHdlr vc_conn; |
| 1252 | var ConnHdlrPars pars; |
| 1253 | f_init(); |
| 1254 | |
| 1255 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1256 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1257 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1258 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1259 | vc_conn.done; |
| 1260 | } |
| 1261 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1262 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1263 | } |
| 1264 | |
| 1265 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1266 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1267 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1268 | var octetstring si5 := f_rnd_octstring(19); |
| 1269 | var RSL_IE_List addl_ies; |
| 1270 | |
| 1271 | f_l1_tune(L1CTL); |
| 1272 | RSL.clear; |
| 1273 | |
| 1274 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1275 | |
| 1276 | /* Activate channel on BTS side */ |
| 1277 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1278 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1279 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1280 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1281 | |
| 1282 | /* Verify that no DL SACCH is being received */ |
| 1283 | f_sacch_missing(?); |
| 1284 | |
| 1285 | f_rsl_chan_deact(); |
| 1286 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1287 | |
| 1288 | |
| 1289 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1290 | |
| 1291 | /* Activate channel on BTS side */ |
| 1292 | addl_ies := { |
| 1293 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1294 | }; |
| 1295 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1296 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1297 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1298 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1299 | |
| 1300 | /* Verify that no DL SACCH is being received */ |
| 1301 | f_sacch_missing(?); |
| 1302 | |
| 1303 | f_rsl_chan_deact(); |
| 1304 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1305 | |
| 1306 | |
| 1307 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1308 | |
| 1309 | /* Activate channel on BTS side */ |
| 1310 | addl_ies := { |
| 1311 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1312 | }; |
| 1313 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1314 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1315 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1316 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1317 | |
| 1318 | /* Verify that no DL SACCH is being received */ |
| 1319 | f_sacch_missing(?); |
| 1320 | |
| 1321 | f_rsl_chan_deact(); |
| 1322 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1323 | |
| 1324 | |
| 1325 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1326 | |
| 1327 | /* Activate channel on BTS side */ |
| 1328 | addl_ies := { |
| 1329 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1330 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1331 | }; |
| 1332 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1333 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1334 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1335 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1336 | |
| 1337 | /* Verify that DL SACCH is being received */ |
| 1338 | f_sacch_present(si5); |
| 1339 | |
| 1340 | f_rsl_chan_deact(); |
| 1341 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1342 | } |
| 1343 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1344 | var ConnHdlr vc_conn; |
| 1345 | var ConnHdlrPars pars; |
| 1346 | f_init(); |
| 1347 | |
| 1348 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1349 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1350 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1351 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1352 | vc_conn.done; |
| 1353 | } |
| 1354 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1356 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1357 | |
| 1358 | |
| 1359 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1360 | * RACH Handling |
| 1361 | ***********************************************************************/ |
| 1362 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1363 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1364 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1365 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1366 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1367 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1368 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1369 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1370 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1371 | for (var integer i := 0; i < 1000; i := i+1) { |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1372 | var OCT1 ra := f_rnd_ra_emerg(); |
| 1373 | if (emerg == true) { |
| 1374 | ra := f_rnd_ra_emerg(); |
| 1375 | } else { |
| 1376 | ra := f_rnd_ra_cs(); |
| 1377 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1378 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1379 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1381 | } |
| 1382 | fn_last := fn; |
| 1383 | |
| 1384 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1385 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1386 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1387 | [] 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] | 1388 | T.stop; |
| 1389 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1390 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1391 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1392 | } |
| 1393 | [] RSL_CCHAN.receive { repeat; } |
| 1394 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1395 | test_failed := true; |
| 1396 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1397 | } |
| 1398 | } |
| 1399 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1400 | if (test_failed) { |
| 1401 | 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] | 1402 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1403 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1404 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1405 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1406 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1407 | /* Normal variant */ |
| 1408 | testcase TC_rach_content() runs on test_CT { |
| 1409 | f_TC_rach_content(emerg := false); |
| 1410 | } |
| 1411 | |
| 1412 | /* Emergency call variant */ |
| 1413 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1414 | f_TC_rach_content(emerg := true); |
| 1415 | } |
| 1416 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1417 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1418 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1419 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1420 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1421 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1422 | f_l1_tune(L1CTL); |
| 1423 | |
| 1424 | var GsmFrameNumber fn_last := 0; |
| 1425 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1426 | var OCT1 ra := f_rnd_ra_cs(); |
| 1427 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1428 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1429 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1430 | } |
| 1431 | fn_last := fn; |
| 1432 | } |
| 1433 | var integer rsl_chrqd := 0; |
| 1434 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1435 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1436 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1437 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1438 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1439 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1440 | repeat; |
| 1441 | } |
| 1442 | [] RSL_CCHAN.receive { repeat; } |
| 1443 | [] T.timeout { } |
| 1444 | } |
| 1445 | if (rsl_chrqd == 1000) { |
| 1446 | setverdict(pass); |
| 1447 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1448 | 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] | 1449 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1450 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1451 | } |
| 1452 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1453 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1454 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1455 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1456 | } |
| 1457 | |
| 1458 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1459 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1460 | |
| 1461 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1462 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1463 | var ASP_RSL_Unitdata rx_ud; |
| 1464 | |
| 1465 | f_init_vty_bsc(); |
| 1466 | /* send load indications even at 0% load */ |
| 1467 | f_vty_load_ind_thresh(0); |
| 1468 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1469 | f_sleep(2.0); |
| 1470 | |
| 1471 | f_init(); |
| 1472 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1473 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1474 | alt { |
| 1475 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1476 | [] RSL_CCHAN.receive { repeat } |
| 1477 | } |
| 1478 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1479 | timer T := 5.0; |
| 1480 | T.start; |
| 1481 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1482 | [] 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] | 1483 | setverdict(pass); |
| 1484 | repeat; |
| 1485 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1486 | [] 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] | 1487 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1488 | repeat; |
| 1489 | } |
| 1490 | [] RSL_CCHAN.receive { |
| 1491 | repeat; |
| 1492 | } |
| 1493 | [] T.timeout { } |
| 1494 | } |
| 1495 | |
| 1496 | f_vty_load_ind_thresh(10); |
| 1497 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1498 | } |
| 1499 | |
| 1500 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1501 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1502 | var ASP_RSL_Unitdata rx_ud; |
| 1503 | |
| 1504 | f_init_vty_bsc(); |
| 1505 | f_init(); |
| 1506 | |
| 1507 | timer T := 5.0; |
| 1508 | T.start; |
| 1509 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1510 | [] 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] | 1511 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1512 | repeat; |
| 1513 | } |
| 1514 | [] RSL_CCHAN.receive { |
| 1515 | repeat; |
| 1516 | } |
| 1517 | [] T.timeout { |
| 1518 | setverdict(pass); |
| 1519 | } |
| 1520 | } |
| 1521 | |
| 1522 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1523 | } |
| 1524 | |
| 1525 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1526 | testcase TC_rach_load_count() runs on test_CT { |
| 1527 | var ASP_RSL_Unitdata rx_ud; |
| 1528 | var integer load_access_count := 0; |
| 1529 | |
| 1530 | f_init_vty_bsc(); |
| 1531 | /* send load indications even at 0% load */ |
| 1532 | f_vty_load_ind_thresh(0); |
| 1533 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1534 | f_sleep(2.0); |
| 1535 | f_init(); |
| 1536 | |
| 1537 | f_init_l1ctl(); |
| 1538 | f_sleep(1.0); |
| 1539 | f_l1_tune(L1CTL); |
| 1540 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1541 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1542 | alt { |
| 1543 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1544 | [] RSL_CCHAN.receive { repeat } |
| 1545 | } |
| 1546 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1547 | var GsmFrameNumber fn_last := 0; |
| 1548 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1549 | var OCT1 ra := f_rnd_ra_cs(); |
| 1550 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1551 | if (fn == fn_last) { |
| 1552 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1553 | } |
| 1554 | fn_last := fn; |
| 1555 | } |
| 1556 | |
| 1557 | timer T := 5.0; |
| 1558 | T.start; |
| 1559 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1560 | [] 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] | 1561 | -> value rx_ud { |
| 1562 | var RSL_IE_Body ie; |
| 1563 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1564 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1565 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1566 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1567 | } |
| 1568 | repeat; |
| 1569 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1570 | [] 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] | 1571 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1572 | repeat; |
| 1573 | } |
| 1574 | [] RSL_CCHAN.receive { |
| 1575 | repeat; |
| 1576 | } |
| 1577 | [] T.timeout { } |
| 1578 | } |
| 1579 | if (load_access_count == 1000) { |
| 1580 | setverdict(pass); |
| 1581 | } else { |
| 1582 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1583 | } |
| 1584 | |
| 1585 | f_vty_load_ind_thresh(10); |
| 1586 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1587 | } |
| 1588 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1589 | 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] | 1590 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1591 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1592 | 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] | 1593 | f_sleep(0.5); |
| 1594 | |
| 1595 | /* Transmit RACH request + wait for confirmation */ |
| 1596 | var OCT1 ra := f_rnd_ra_cs(); |
| 1597 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1598 | |
| 1599 | /* Check for expected result */ |
| 1600 | timer T := 1.5; |
| 1601 | T.start; |
| 1602 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1603 | [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] | 1604 | setverdict(pass); |
| 1605 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1606 | [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] | 1607 | 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] | 1608 | } |
| 1609 | [] RSL_CCHAN.receive { repeat; } |
| 1610 | [not expect_pass] T.timeout { |
| 1611 | setverdict(pass); |
| 1612 | } |
| 1613 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1614 | 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] | 1615 | } |
| 1616 | } |
| 1617 | } |
| 1618 | |
| 1619 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1620 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1621 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1622 | f_init_l1ctl(); |
| 1623 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1624 | f_sleep(1.0); |
| 1625 | |
| 1626 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1627 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1628 | /* We allow early arrival up to 2 symbols */ |
| 1629 | f_rach_toffs(-1*256, true); |
| 1630 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1631 | f_rach_toffs(-10*256, false); |
| 1632 | |
| 1633 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1634 | f_rach_toffs(0, true); |
| 1635 | f_rach_toffs(32*256, true); |
| 1636 | f_rach_toffs(63*256, true); |
| 1637 | |
| 1638 | /* more than 63 bits is not legal / permitted */ |
| 1639 | f_rach_toffs(64*256, false); |
| 1640 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1641 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1642 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1643 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1644 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1645 | var GsmFrameNumber fn; |
| 1646 | var RSL_Message rm; |
| 1647 | |
| 1648 | f_l1_tune(L1CTL); |
| 1649 | RSL.clear; |
| 1650 | |
| 1651 | /* Generate a random Handover Reference */ |
| 1652 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1653 | |
| 1654 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1655 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1656 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1657 | |
| 1658 | /* Activate a channel on the BTS side (no encryption) */ |
| 1659 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1660 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1661 | |
| 1662 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1663 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1664 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1665 | |
| 1666 | /* Send handover Access Burst */ |
| 1667 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1668 | |
| 1669 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1670 | |
| 1671 | /* Wait for handover detection */ |
| 1672 | timer T := 3.0; |
| 1673 | T.start; |
| 1674 | alt { |
| 1675 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1676 | log("Handover RACH has been detected: ", rm); |
| 1677 | setverdict(pass); |
| 1678 | } |
| 1679 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1680 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1681 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1682 | } |
| 1683 | [] RSL.receive { repeat; } |
| 1684 | [] T.timeout { |
| 1685 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1686 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1687 | } |
| 1688 | } |
| 1689 | |
| 1690 | /* Release the channel */ |
| 1691 | f_rsl_chan_deact(); |
| 1692 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1693 | } |
| 1694 | |
| 1695 | /* Test handover RACH detection */ |
| 1696 | testcase TC_ho_rach() runs on test_CT { |
| 1697 | var ConnHdlrPars pars; |
| 1698 | var ConnHdlr vc_conn; |
| 1699 | |
| 1700 | f_init(); |
| 1701 | |
| 1702 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1703 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1704 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1705 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1706 | vc_conn.done; |
| 1707 | } |
| 1708 | |
| 1709 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1710 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1711 | } |
| 1712 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1713 | /*********************************************************************** |
| 1714 | * Measurement Processing / Reporting |
| 1715 | ***********************************************************************/ |
| 1716 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1717 | private template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1718 | spare := '0'B, |
| 1719 | lpd := 0, |
| 1720 | sapi := sapi, |
| 1721 | c_r := c_r, |
| 1722 | ea := true |
| 1723 | } |
| 1724 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1725 | 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] | 1726 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1727 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1728 | len := 0, /* overwritten */ |
| 1729 | m := false, |
| 1730 | el := 1, |
| 1731 | payload := pl |
| 1732 | } |
| 1733 | |
| 1734 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1735 | private altstep as_l1_sacch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1736 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1737 | [] 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] | 1738 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1739 | 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] | 1740 | 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] | 1741 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1742 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1743 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1744 | g_pars.l1_pars.ms_power_level, false, |
| 1745 | g_pars.l1_pars.ms_actual_ta); |
| 1746 | |
| 1747 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1748 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1749 | |
| 1750 | log("Sending Measurement Report: ", l1h, l2); |
| 1751 | 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] | 1752 | repeat; |
| 1753 | } |
| 1754 | } |
| 1755 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1756 | private altstep as_l1_dcch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1757 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1758 | [] 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] | 1759 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1760 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1761 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1762 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1763 | repeat; |
| 1764 | } |
| 1765 | } |
| 1766 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1767 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1768 | uint6_t rxlev, |
| 1769 | uint3_t rxqual |
| 1770 | } |
| 1771 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1772 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1773 | MeasElem full, |
| 1774 | MeasElem sub |
| 1775 | } |
| 1776 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1777 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1778 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1779 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1780 | MeasElemFS meas_ul, |
| 1781 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1782 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1783 | uint5_t ms_power_level, |
| 1784 | uint8_t ms_actual_ta |
| 1785 | } |
| 1786 | |
| 1787 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1788 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1789 | return 63 + (toffs256s/256); |
| 1790 | } |
| 1791 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1792 | private function f_max(integer a, integer b) return integer { |
| 1793 | if (a > b) { |
| 1794 | return a; |
| 1795 | } else { |
| 1796 | return b; |
| 1797 | } |
| 1798 | } |
| 1799 | |
| 1800 | private function f_min(integer a, integer b) return integer { |
| 1801 | if (a < b) { |
| 1802 | return a; |
| 1803 | } else { |
| 1804 | return b; |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1809 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1810 | val := val - tolerance; |
| 1811 | return f_max(val, min); |
| 1812 | } |
| 1813 | |
| 1814 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1815 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1816 | val := val + tolerance; |
| 1817 | return f_min(val, max); |
| 1818 | } |
| 1819 | |
| 1820 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1821 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1822 | return template integer { |
| 1823 | var template integer ret; |
| 1824 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1825 | return ret; |
| 1826 | } |
| 1827 | |
| 1828 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1829 | /* build a template for matching measurement results against */ |
| 1830 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1831 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1832 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1833 | len := 3, |
| 1834 | rfu := '0'B, |
| 1835 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1836 | 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] | 1837 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1838 | 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] | 1839 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1840 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1841 | 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] | 1842 | supp_meas_info := omit |
| 1843 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1844 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1845 | ul_meas.len := (3+8); |
| 1846 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1847 | 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] | 1848 | toa256_min := ?, |
| 1849 | toa256_max := ?, |
| 1850 | toa256_std_dev := ? |
| 1851 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1852 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1853 | var template RSL_IE_BS_Power bs_power := { |
| 1854 | reserved := 0, |
| 1855 | epc := false, |
| 1856 | fpc := false, |
| 1857 | power_level := l1p.bs_power_level |
| 1858 | }; |
| 1859 | var template RSL_IE_L1Info l1_info := { |
| 1860 | ms_power_lvl := l1p.ms_power_level, |
| 1861 | fpc := false, |
| 1862 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1863 | 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] | 1864 | }; |
| 1865 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1866 | 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] | 1867 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1868 | ?, t_toffs); |
| 1869 | } |
| 1870 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1871 | /* build a template for matching measurement results that do not contain any |
| 1872 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 1873 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 1874 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1875 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1876 | len := 3, |
| 1877 | rfu := '0'B, |
| 1878 | dtx_d := l1p.dtx_enabled, |
| 1879 | rxlev_f_u := ?, |
| 1880 | reserved1 := '00'B, |
| 1881 | rxlev_s_u := ?, |
| 1882 | reserved2 := '00'B, |
| 1883 | rxq_f_u := ?, |
| 1884 | rxq_s_u := ?, |
| 1885 | supp_meas_info := omit |
| 1886 | }; |
| 1887 | if (l1p.toa256_enabled) { |
| 1888 | ul_meas.len := (3+8); |
| 1889 | ul_meas.supp_meas_info := { |
| 1890 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 1891 | toa256_min := ?, |
| 1892 | toa256_max := ?, |
| 1893 | toa256_std_dev := ? |
| 1894 | } |
| 1895 | } |
| 1896 | var template RSL_IE_BS_Power bs_power := { |
| 1897 | reserved := 0, |
| 1898 | epc := false, |
| 1899 | fpc := false, |
| 1900 | power_level := l1p.bs_power_level |
| 1901 | }; |
| 1902 | |
| 1903 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 1904 | } |
| 1905 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1906 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1907 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1908 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1909 | var boolean chan_est := false; |
| 1910 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1911 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1912 | |
| 1913 | /* Receive osmocom specific measurement reports. This is the normal |
| 1914 | * case. Here we verify that the measurement reports we sent are |
| 1915 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1916 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1917 | /* increment counter of next to-be-expected meas rep */ |
| 1918 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1919 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1920 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1921 | |
| 1922 | /* The following two cases may only happen in the beginning |
| 1923 | * of the channel establishment phase. Once we have received |
| 1924 | * the "our" measurement report the first time, the channel |
| 1925 | * is established and empty or hardcoded TRXCON reports must |
| 1926 | * not occur anymore. */ |
| 1927 | chan_est := true; |
| 1928 | |
| 1929 | repeat; |
| 1930 | } |
| 1931 | |
| 1932 | /* When the BTS has established the channel, the MS might need slightly |
| 1933 | * more time to establish the channel and actually start sending. The |
| 1934 | * result is then a measurement report that just lacks the measurement |
| 1935 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 1936 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 1937 | /* increment counter of next to-be-expected meas rep */ |
| 1938 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1939 | /* Re-start the timer expecting the next MEAS RES */ |
| 1940 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1941 | repeat; |
| 1942 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1943 | |
| 1944 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 1945 | * measurements if the TTCN3 side does not supply measurement input in |
| 1946 | * time. In those cases TRXCON will either use a cached measurement |
| 1947 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 1948 | * report the templates above will not match. We tolerate this |
| 1949 | * behavior, but only once. */ |
| 1950 | [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] | 1951 | /* increment counter of next to-be-expected meas rep */ |
| 1952 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1953 | if (g_first_meas_res) { |
| 1954 | g_first_meas_res := false; |
| 1955 | repeat; |
| 1956 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1957 | 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] | 1958 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1959 | } |
| 1960 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1961 | 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] | 1962 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 1963 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1964 | 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] | 1965 | } |
| 1966 | } |
| 1967 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1968 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1969 | select (rsl_alg_id) { |
| 1970 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1971 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1972 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1973 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1974 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1975 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1976 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1977 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1978 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1979 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1980 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1981 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1982 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1983 | } |
| 1984 | } |
| 1985 | } |
| 1986 | |
| 1987 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1988 | select (rsl_alg_id) { |
| 1989 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1990 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1991 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1992 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1993 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1994 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1995 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1996 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1997 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1998 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1999 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2000 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2001 | } |
| 2002 | } |
| 2003 | } |
| 2004 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2005 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2006 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2007 | var GsmFrameNumber fn; |
| 2008 | timer T := 8.0; |
| 2009 | |
| 2010 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2011 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2012 | |
| 2013 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2014 | /* Send the actual RACH */ |
| 2015 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2016 | |
| 2017 | T.start; |
| 2018 | alt { |
| 2019 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2020 | [] T.timeout { |
| 2021 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2022 | } |
| 2023 | } |
| 2024 | T.stop |
| 2025 | return fn; |
| 2026 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2027 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2028 | /* Tune to a dedicated channel: L1CTL only */ |
| 2029 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2030 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2031 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, |
| 2032 | 7 /* TODO: mp_tsc */, |
| 2033 | mp_trx0_arfcn)); |
| 2034 | } else { |
| 2035 | pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, |
| 2036 | 7 /* TODO: mp_tsc */, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2037 | pars.fhp.maio_hsn.hsn, |
| 2038 | pars.fhp.maio_hsn.maio, |
| 2039 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2043 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2044 | 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] | 2045 | var GsmFrameNumber fn; |
| 2046 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2047 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2048 | var integer ra := 23; |
| 2049 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2050 | /* Send RACH request and wait for ChanReq */ |
| 2051 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2052 | |
| 2053 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2054 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2055 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2056 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2057 | if (g_pars.fhp.enabled) { |
| 2058 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2059 | } else { |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 2060 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx0_arfcn)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2061 | } |
| 2062 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2063 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2064 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2065 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 2066 | |
| 2067 | /* receive IMM.ASS on MS side */ |
| 2068 | var ImmediateAssignment ia_um; |
| 2069 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2070 | |
| 2071 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 2072 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 2073 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 2074 | } |
| 2075 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2076 | /* enable dedicated mode */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2077 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.fhp.ma); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2078 | /* enable encryption, if requested */ |
| 2079 | if (encr_enable) { |
| 2080 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2081 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2082 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2083 | |
| 2084 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2088 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2089 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2090 | RSL.clear; |
| 2091 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2092 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2093 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2094 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2095 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2096 | |
| 2097 | f_est_dchan(); |
| 2098 | |
| 2099 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2100 | * RSL measurement reports on Abis side */ |
| 2101 | timer T := 8.0; |
| 2102 | T.start; |
| 2103 | alt { |
| 2104 | [] as_l1_sacch(); |
| 2105 | [] as_meas_res(); |
| 2106 | [] as_l1_dcch(); |
| 2107 | [] L1CTL.receive { repeat; } |
| 2108 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2109 | /* 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] | 2110 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2111 | setverdict(pass); |
| 2112 | } |
| 2113 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2114 | 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] | 2115 | } |
| 2116 | } |
| 2117 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2118 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2119 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2120 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2121 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2122 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2123 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2124 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2125 | timer Tup := 10.0; |
| 2126 | Tup.start; |
| 2127 | alt { |
| 2128 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2129 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2130 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2131 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2132 | if (rx_lvl != max_rx_lvl) { |
| 2133 | repeat; |
| 2134 | } |
| 2135 | Tup.stop; |
| 2136 | } |
| 2137 | [] L1CTL.receive { repeat; } |
| 2138 | [] Tup.timeout { |
| 2139 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2140 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2141 | } |
| 2142 | } |
| 2143 | return max_rx_lvl; |
| 2144 | } |
| 2145 | |
| 2146 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2147 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2148 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2149 | var integer initial_rx_lvl := -1; |
| 2150 | var integer last_rx_lvl := -1; |
| 2151 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2152 | |
| 2153 | timer T := 2.0; |
| 2154 | alt { |
| 2155 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2156 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2157 | log("Received rx_level=", rx_lvl); |
| 2158 | if (initial_rx_lvl == -1) { |
| 2159 | initial_rx_lvl := rx_lvl; |
| 2160 | last_rx_lvl := rx_lvl; |
| 2161 | |
| 2162 | /* Expect a somehow low value during first received messages */ |
| 2163 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2164 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2165 | log2str("Detected high initial tx power during ramp up: ", |
| 2166 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2171 | if (rx_lvl > max_rx_lvl) { |
| 2172 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2173 | log2str("Detected Tx power higher than full power: ", |
| 2174 | rx_lvl , " > ", max_rx_lvl)); |
| 2175 | } |
| 2176 | |
| 2177 | /* Make sure it never decreases, since we are rumping up */ |
| 2178 | if (last_rx_lvl > rx_lvl) { |
| 2179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2180 | log2str("Detected Tx power decrease during ramp up: ", |
| 2181 | last_rx_lvl , " -> ", rx_lvl)); |
| 2182 | } |
| 2183 | |
| 2184 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2185 | /* We reached the maximum power, start timer and receive |
| 2186 | /* a few more to make sure we don't surpass it */ |
| 2187 | log("Reached full power, wating a bit more until success"); |
| 2188 | T.start; |
| 2189 | } |
| 2190 | |
| 2191 | last_rx_lvl := rx_lvl; |
| 2192 | repeat; |
| 2193 | } |
| 2194 | [] L1CTL.receive { repeat; } |
| 2195 | [] T.timeout { } |
| 2196 | } |
| 2197 | |
| 2198 | /* We didn't increase tx power during ramp up */ |
| 2199 | if (initial_rx_lvl < last_rx_lvl) { |
| 2200 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2201 | } else { |
| 2202 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2203 | log2str("No Tx power increase during whole ramp up: ", |
| 2204 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2205 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | /* verify BTS ramps power down to rx_level 0 */ |
| 2209 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2210 | var L1ctlDlMessage l1_dl; |
| 2211 | var integer last_rx_lvl := max_rx_lvl; |
| 2212 | |
| 2213 | timer Tdown := 5.0; |
| 2214 | Tdown.start; |
| 2215 | alt { |
| 2216 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2217 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2218 | log("Received rx_level=", rx_lvl); |
| 2219 | |
| 2220 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2221 | if (rx_lvl > max_rx_lvl) { |
| 2222 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2223 | log2str("Detected Tx power higher than full power: ", |
| 2224 | rx_lvl , " > ", max_rx_lvl)); |
| 2225 | } |
| 2226 | |
| 2227 | /* Make sure it never increases, since we are rumping down */ |
| 2228 | if (last_rx_lvl < rx_lvl) { |
| 2229 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2230 | log2str("Detected Tx power increase during ramp up: ", |
| 2231 | last_rx_lvl , " -> ", rx_lvl)); |
| 2232 | } |
| 2233 | |
| 2234 | last_rx_lvl := rx_lvl; |
| 2235 | if (last_rx_lvl != 0) { |
| 2236 | repeat; |
| 2237 | } |
| 2238 | /* we reached power level 0, we are done */ |
| 2239 | Tdown.stop; |
| 2240 | } |
| 2241 | [] L1CTL.receive { repeat; } |
| 2242 | [] Tdown.timeout { } |
| 2243 | } |
| 2244 | |
| 2245 | /* We didn't increase tx power during ramp down */ |
| 2246 | if (max_rx_lvl > last_rx_lvl) { |
| 2247 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2248 | } else { |
| 2249 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2250 | log2str("No Tx power decrease during whole ramp down: ", |
| 2251 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2252 | } |
| 2253 | } |
| 2254 | |
| 2255 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2256 | 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] | 2257 | f_l1_tune(L1CTL); |
| 2258 | RSL.clear; |
| 2259 | |
| 2260 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2261 | |
| 2262 | setverdict(pass); |
| 2263 | } |
| 2264 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2265 | var ConnHdlr vc_conn; |
| 2266 | var ConnHdlrPars pars; |
| 2267 | f_init(); |
| 2268 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2269 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2270 | pcu_comp := false, trxc_comp := true); |
| 2271 | vc_conn.done; |
| 2272 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2273 | } |
| 2274 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2275 | /* 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] | 2276 | 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] | 2277 | f_connhdlr_init_vty_bsc(); |
| 2278 | |
| 2279 | f_l1_tune(L1CTL); |
| 2280 | RSL.clear; |
| 2281 | |
| 2282 | /* Wait until BTS is started and at full power */ |
| 2283 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2284 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2285 | |
| 2286 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2287 | f_verify_ramp_down(max_rx_lvl); |
| 2288 | |
| 2289 | setverdict(pass); |
| 2290 | } |
| 2291 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2292 | var ConnHdlr vc_conn; |
| 2293 | var ConnHdlrPars pars; |
| 2294 | f_init(); |
| 2295 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2296 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2297 | pcu_comp := false, trxc_comp := true); |
| 2298 | vc_conn.done; |
| 2299 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2300 | } |
| 2301 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2302 | /* Verify Tx power: |
| 2303 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2304 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2305 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2306 | 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] | 2307 | var L1ctlDlMessage l1_dl; |
| 2308 | var integer last_rx_lvl; |
| 2309 | |
| 2310 | f_connhdlr_init_vty_bsc(); |
| 2311 | |
| 2312 | f_l1_tune(L1CTL); |
| 2313 | RSL.clear; |
| 2314 | |
| 2315 | /* Wait until BTS is started and at full power */ |
| 2316 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2317 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2318 | |
| 2319 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2320 | f_vty_enter_cfg_trx(BSCVTY); |
| 2321 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2322 | last_rx_lvl := max_rx_lvl; |
| 2323 | f_verify_ramp_down(max_rx_lvl); |
| 2324 | |
| 2325 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2326 | * anymore because scheduler has stopped after ramping down */ |
| 2327 | f_sleep(2.0); |
| 2328 | L1CTL.clear; |
| 2329 | timer Tlocked := 2.0; |
| 2330 | Tlocked.start; |
| 2331 | alt { |
| 2332 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2333 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2334 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2335 | } |
| 2336 | [] L1CTL.receive { repeat; } |
| 2337 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2338 | } |
| 2339 | |
| 2340 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2341 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2342 | f_verify_ramp_up(); |
| 2343 | setverdict(pass); |
| 2344 | } |
| 2345 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2346 | var ConnHdlr vc_conn; |
| 2347 | var ConnHdlrPars pars; |
| 2348 | f_init(); |
| 2349 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2350 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2351 | pcu_comp := false, trxc_comp := true); |
| 2352 | vc_conn.done; |
| 2353 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2354 | } |
| 2355 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2356 | 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] | 2357 | timer T := 8.0; |
| 2358 | T.start; |
| 2359 | var RSL_Message rsl; |
| 2360 | alt { |
| 2361 | [] as_l1_sacch(); |
| 2362 | [] L1CTL.receive { repeat; } |
| 2363 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2364 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2365 | setverdict(pass) |
| 2366 | } else { |
| 2367 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2368 | } |
| 2369 | } |
| 2370 | [] T.timeout { |
| 2371 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2372 | } |
| 2373 | } |
| 2374 | } |
| 2375 | |
| 2376 | /* see if the rsl meas res contains our expeced bs power level |
| 2377 | bs power set during assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2378 | 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] | 2379 | f_l1_tune(L1CTL); |
| 2380 | RSL.clear; |
| 2381 | |
| 2382 | if (mp_bts_trxc_port != -1) { |
| 2383 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2384 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2385 | } |
| 2386 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2387 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2388 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2389 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2390 | |
| 2391 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2392 | |
| 2393 | f_check_meas_bs_power_level(pwr_var); |
| 2394 | |
| 2395 | f_rsl_chan_deact(); |
| 2396 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2397 | } |
| 2398 | |
| 2399 | /* see if the rsl meas res contains our expeced bs power level |
| 2400 | bs power set after assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2401 | 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] | 2402 | f_l1_tune(L1CTL); |
| 2403 | RSL.clear; |
| 2404 | |
| 2405 | if (mp_bts_trxc_port != -1) { |
| 2406 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2407 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2408 | } |
| 2409 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2410 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2411 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2412 | |
| 2413 | f_est_dchan(); |
| 2414 | |
| 2415 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2416 | |
| 2417 | f_check_meas_bs_power_level(pwr_var); |
| 2418 | |
| 2419 | f_rsl_chan_deact(); |
| 2420 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2421 | } |
| 2422 | |
| 2423 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2424 | var ConnHdlr vc_conn; |
| 2425 | var ConnHdlrPars pars; |
| 2426 | f_init(); |
| 2427 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2428 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2429 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2430 | pcu_comp := false, trxc_comp := true); |
| 2431 | vc_conn.done; |
| 2432 | } |
| 2433 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2434 | } |
| 2435 | |
| 2436 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2437 | var ConnHdlr vc_conn; |
| 2438 | var ConnHdlrPars pars; |
| 2439 | f_init(); |
| 2440 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2441 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2442 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2443 | pcu_comp := false, trxc_comp := true); |
| 2444 | vc_conn.done; |
| 2445 | } |
| 2446 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2447 | } |
| 2448 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2449 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2450 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2451 | 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] | 2452 | 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] | 2453 | var uint5_t pwr_var := 7; |
| 2454 | var L1ctlDlMessage l1_dl; |
| 2455 | |
| 2456 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2457 | f_l1_tune(L1CTL); |
| 2458 | RSL.clear; |
| 2459 | |
| 2460 | var RSL_IE_List addl_ies; |
| 2461 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2462 | |
| 2463 | addl_ies := { |
| 2464 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2465 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2466 | }; |
| 2467 | |
| 2468 | /* establish with power parameters */ |
| 2469 | f_est_dchan(more_ies := addl_ies); |
| 2470 | |
| 2471 | /* set a high value to ensure L1 power control level increases */ |
| 2472 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2473 | |
| 2474 | timer T2 := 6.0; |
| 2475 | T2.start; |
| 2476 | alt { |
| 2477 | [] 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] | 2478 | /* Update sent MS power to follow what BTS requests */ |
| 2479 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2480 | if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2481 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2482 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2483 | T2.stop; |
| 2484 | } |
| 2485 | [] L1CTL.receive { repeat; } |
| 2486 | [] T2.timeout { |
| 2487 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2488 | "Power Level in L1 header has not increased sufficiently"); |
| 2489 | } |
| 2490 | } |
| 2491 | |
| 2492 | /* set a low value to ensure L1 power control level decreases */ |
| 2493 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2494 | |
| 2495 | timer T4 := 6.0; |
| 2496 | T4.start; |
| 2497 | alt { |
| 2498 | [] 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] | 2499 | /* Update sent MS power to follow what BTS requests */ |
| 2500 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2501 | if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2502 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2503 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2504 | T4.stop; |
| 2505 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2506 | } |
| 2507 | [] L1CTL.receive { repeat; } |
| 2508 | [] T4.timeout { |
| 2509 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2510 | "Power Level in L1 header has not decreased sufficiently"); |
| 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | f_rsl_chan_deact(); |
| 2515 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2516 | |
| 2517 | } |
| 2518 | |
| 2519 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2520 | 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] | 2521 | var uint5_t pwr_var := 7; |
| 2522 | var L1ctlDlMessage l1_dl; |
| 2523 | |
| 2524 | /* set a low value to ensure power increases */ |
| 2525 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2526 | f_l1_tune(L1CTL); |
| 2527 | RSL.clear; |
| 2528 | |
| 2529 | var RSL_IE_List addl_ies; |
| 2530 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2531 | |
| 2532 | addl_ies := { |
| 2533 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2534 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2535 | }; |
| 2536 | |
| 2537 | /* establish with power parameters */ |
| 2538 | f_est_dchan(more_ies := addl_ies); |
| 2539 | |
| 2540 | timer T1 := 10.0; |
| 2541 | T1.start; |
| 2542 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2543 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2544 | /* Update sent MS power to follow what BTS requests */ |
| 2545 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2546 | repeat; |
| 2547 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2548 | [] L1CTL.receive { repeat; } |
| 2549 | [] T1.timeout { |
| 2550 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2551 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2552 | } |
| 2553 | } |
| 2554 | } |
| 2555 | |
| 2556 | f_rsl_chan_deact(); |
| 2557 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2558 | |
| 2559 | } |
| 2560 | |
| 2561 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2562 | 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] | 2563 | var L1ctlDlMessage l1_dl; |
| 2564 | var uint5_t pwr_var := 15; |
| 2565 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2566 | |
| 2567 | /* set a low value to ensure power increases */ |
| 2568 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2569 | f_l1_tune(L1CTL); |
| 2570 | RSL.clear; |
| 2571 | |
| 2572 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2573 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2574 | |
| 2575 | /* establish with fixed power level */ |
| 2576 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2577 | |
| 2578 | /* check our initial power level */ |
| 2579 | f_wait_for_l1_power_level(pwr_var); |
| 2580 | |
| 2581 | /* update power param to enable power loop |
| 2582 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2583 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2584 | |
| 2585 | /* wait, then check that our power level was reduced */ |
| 2586 | timer T1 := 10.0; |
| 2587 | T1.start; |
| 2588 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2589 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2590 | /* Update sent MS power to follow what BTS requests */ |
| 2591 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2592 | repeat; |
| 2593 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2594 | [] L1CTL.receive { repeat; } |
| 2595 | [] T1.timeout { |
| 2596 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2597 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2598 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2599 | } else { |
| 2600 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2601 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2602 | } |
| 2603 | } |
| 2604 | } |
| 2605 | |
| 2606 | f_rsl_chan_deact(); |
| 2607 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2608 | |
| 2609 | } |
| 2610 | |
| 2611 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2612 | 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] | 2613 | var L1ctlDlMessage l1_dl; |
| 2614 | |
| 2615 | /* set a high value to ensure power decreases */ |
| 2616 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2617 | f_l1_tune(L1CTL); |
| 2618 | RSL.clear; |
| 2619 | |
| 2620 | var uint5_t pwr_var := 5; |
| 2621 | var uint5_t pwr_target_val := 15; |
| 2622 | |
| 2623 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2624 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2625 | |
| 2626 | /* establish with fixed power level */ |
| 2627 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2628 | |
| 2629 | /* check our initial power level */ |
| 2630 | f_wait_for_l1_power_level(pwr_var); |
| 2631 | |
| 2632 | /* update power param to enable power loop |
| 2633 | 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] | 2634 | 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] | 2635 | |
| 2636 | /* wait, then check that our power level was increased */ |
| 2637 | timer T1 := 10.0; |
| 2638 | T1.start; |
| 2639 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2640 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2641 | /* Update sent MS power to follow what BTS requests */ |
| 2642 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2643 | repeat; |
| 2644 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2645 | [] L1CTL.receive { repeat; } |
| 2646 | [] T1.timeout { |
| 2647 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2648 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2649 | } else { |
| 2650 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2651 | "Power level in L1 header NOT increased to lowest power value"); |
| 2652 | } |
| 2653 | } |
| 2654 | } |
| 2655 | |
| 2656 | f_rsl_chan_deact(); |
| 2657 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2658 | |
| 2659 | } |
| 2660 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2661 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2662 | rsl chan act WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2663 | 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] | 2664 | var L1ctlDlMessage l1_dl; |
| 2665 | |
| 2666 | /* set a high value to ensure power decreases */ |
| 2667 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2668 | f_l1_tune(L1CTL); |
| 2669 | RSL.clear; |
| 2670 | |
| 2671 | var uint5_t pwr_var := 5; |
| 2672 | |
| 2673 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2674 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2675 | |
| 2676 | /* establish with fixed power level */ |
| 2677 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2678 | |
| 2679 | /* check our initial power level */ |
| 2680 | f_wait_for_l1_power_level(pwr_var); |
| 2681 | |
| 2682 | /* wait, then check that our power level did not change */ |
| 2683 | timer T1 := 10.0; |
| 2684 | T1.start; |
| 2685 | alt { |
| 2686 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2687 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2688 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2689 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2690 | } |
| 2691 | repeat; |
| 2692 | } |
| 2693 | [] L1CTL.receive { repeat; } |
| 2694 | [] T1.timeout { setverdict(pass); } |
| 2695 | } |
| 2696 | |
| 2697 | f_rsl_chan_deact(); |
| 2698 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2699 | |
| 2700 | } |
| 2701 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2702 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2703 | ms power control WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2704 | 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] | 2705 | var L1ctlDlMessage l1_dl; |
| 2706 | |
| 2707 | /* set a high value to ensure power decreases */ |
| 2708 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2709 | f_l1_tune(L1CTL); |
| 2710 | RSL.clear; |
| 2711 | |
| 2712 | var uint5_t pwr_var := 5; |
| 2713 | |
| 2714 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2715 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2716 | |
| 2717 | /* establish with fixed power level */ |
| 2718 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2719 | |
| 2720 | /* check our initial power level */ |
| 2721 | f_wait_for_l1_power_level(pwr_var); |
| 2722 | |
| 2723 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2724 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2725 | |
| 2726 | /* wait, then check that our power level did not change */ |
| 2727 | timer T1 := 10.0; |
| 2728 | T1.start; |
| 2729 | alt { |
| 2730 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2731 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2732 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2733 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2734 | } |
| 2735 | repeat; |
| 2736 | } |
| 2737 | [] L1CTL.receive { repeat; } |
| 2738 | [] T1.timeout { setverdict(pass); } |
| 2739 | } |
| 2740 | |
| 2741 | f_rsl_chan_deact(); |
| 2742 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2743 | |
| 2744 | } |
| 2745 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2746 | 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] | 2747 | var L1ctlDlMessage l1_dl; |
| 2748 | timer T0 := 10.0; |
| 2749 | T0.start; |
| 2750 | alt { |
| 2751 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2752 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2753 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2754 | "Power level in L1 header != signaled (RSL) power level."); |
| 2755 | } |
| 2756 | } |
| 2757 | [] L1CTL.receive { repeat; } |
| 2758 | [] T0.timeout { |
| 2759 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2760 | "Timeout waiting for initial power level"); |
| 2761 | } |
| 2762 | } |
| 2763 | T0.stop; |
| 2764 | } |
| 2765 | |
| 2766 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2767 | var IntegerRecord min_dbm_level; |
| 2768 | var IntegerRecord max_dbm_level; |
| 2769 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2770 | |
| 2771 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2772 | if (min_dbm_level[i] == level) { |
| 2773 | return true; |
| 2774 | } |
| 2775 | } |
| 2776 | return false; |
| 2777 | } |
| 2778 | |
| 2779 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2780 | var IntegerRecord min_dbm_level; |
| 2781 | var IntegerRecord max_dbm_level; |
| 2782 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2783 | |
| 2784 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2785 | if (max_dbm_level[i] == level) { |
| 2786 | return true; |
| 2787 | } |
| 2788 | } |
| 2789 | return false; |
| 2790 | } |
| 2791 | |
| 2792 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2793 | var IntegerRecord min_dbm_level; |
| 2794 | var IntegerRecord max_dbm_level; |
| 2795 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2796 | return max_dbm_level[0]; |
| 2797 | } |
| 2798 | |
| 2799 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2800 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2801 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2802 | // 45.005 4.1.1 |
| 2803 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2804 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2805 | 2, 1, 0}; |
| 2806 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2807 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2808 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2809 | var IntegerRecord rv; |
| 2810 | |
| 2811 | select(band){ |
| 2812 | case (BtsBand_allGSM){ |
| 2813 | rv := gsm_power; |
| 2814 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2815 | max_dbm_level := {2, 1, 0}; |
| 2816 | } |
| 2817 | case("DCS1800"){ |
| 2818 | rv := dcs_power; |
| 2819 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2820 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2821 | } |
| 2822 | case("PCS1900"){ |
| 2823 | rv := pcs_power; |
| 2824 | min_dbm_level := {15}; |
| 2825 | max_dbm_level := {30}; |
| 2826 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 2827 | case else { |
| 2828 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 2829 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2830 | } |
| 2831 | |
| 2832 | return rv; |
| 2833 | } |
| 2834 | |
| 2835 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
Harald Welte | c935fad | 2020-10-11 21:02:54 +0200 | [diff] [blame] | 2836 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of*type* in band (\w+),*", 0); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2837 | } |
| 2838 | |
| 2839 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2840 | var ConnHdlr vc_conn; |
| 2841 | var ConnHdlrPars pars; |
| 2842 | f_init(); |
| 2843 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2844 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2845 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2846 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2847 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2848 | vc_conn.done; |
| 2849 | } |
| 2850 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2851 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2852 | } |
| 2853 | |
| 2854 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2855 | var ConnHdlr vc_conn; |
| 2856 | var ConnHdlrPars pars; |
| 2857 | f_init(); |
| 2858 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2859 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2860 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2861 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2862 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2863 | vc_conn.done; |
| 2864 | } |
| 2865 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2866 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2867 | } |
| 2868 | |
| 2869 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2870 | var ConnHdlr vc_conn; |
| 2871 | var ConnHdlrPars pars; |
| 2872 | f_init(); |
| 2873 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2874 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2875 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2876 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2877 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2878 | vc_conn.done; |
| 2879 | } |
| 2880 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2881 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2882 | } |
| 2883 | |
| 2884 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2885 | var ConnHdlr vc_conn; |
| 2886 | var ConnHdlrPars pars; |
| 2887 | f_init(); |
| 2888 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2889 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2890 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2891 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2892 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2893 | vc_conn.done; |
| 2894 | } |
| 2895 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2896 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2897 | } |
| 2898 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2899 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2900 | var ConnHdlr vc_conn; |
| 2901 | var ConnHdlrPars pars; |
| 2902 | f_init(); |
| 2903 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2904 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2905 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2906 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2907 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2908 | vc_conn.done; |
| 2909 | } |
| 2910 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2911 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2912 | } |
| 2913 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2914 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2915 | var ConnHdlr vc_conn; |
| 2916 | var ConnHdlrPars pars; |
| 2917 | f_init(); |
| 2918 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2919 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2920 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2921 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2922 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2923 | vc_conn.done; |
| 2924 | } |
| 2925 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2926 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2927 | } |
| 2928 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2929 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 2930 | var ConnHdlr vc_conn; |
| 2931 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2932 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2933 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2934 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2935 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2936 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2937 | vc_conn.done; |
| 2938 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2939 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2940 | } |
| 2941 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 2942 | var ConnHdlr vc_conn; |
| 2943 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2944 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2945 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2946 | 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] | 2947 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2948 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2949 | vc_conn.done; |
| 2950 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2951 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2952 | } |
| 2953 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 2954 | var ConnHdlr vc_conn; |
| 2955 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2956 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2957 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 2958 | 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] | 2959 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2960 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2961 | vc_conn.done; |
| 2962 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2963 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2964 | } |
| 2965 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 2966 | var ConnHdlr vc_conn; |
| 2967 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2968 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2969 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 2970 | 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] | 2971 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2972 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2973 | vc_conn.done; |
| 2974 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2976 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2977 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 2978 | var ConnHdlr vc_conn; |
| 2979 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2980 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2981 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 2982 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2983 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 2984 | pars.l1_pars.toa256_enabled := true; |
| 2985 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 2986 | vc_conn.done; |
| 2987 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2988 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2989 | } |
| 2990 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2991 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 2992 | * 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] | 2993 | 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] | 2994 | var L1ctlDlMessage l1_dl; |
| 2995 | var RSL_IE_MS_Power ms_power; |
| 2996 | var RSL_Message rsl; |
| 2997 | var uint5_t power_level := 0; |
| 2998 | |
| 2999 | f_l1_tune(L1CTL); |
| 3000 | RSL.clear; |
| 3001 | |
| 3002 | f_est_dchan(); |
| 3003 | |
| 3004 | ms_power.reserved := 0; |
| 3005 | ms_power.fpc_epc := false; |
| 3006 | |
| 3007 | /* Send the first power control command. This will disable any BTS/TRX |
| 3008 | * internal power control and switch the MS (which is not in scope of |
| 3009 | * this test) to a constant power level. We start with a power level |
| 3010 | * of 0 */ |
| 3011 | ms_power.power_level := power_level; |
| 3012 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3013 | RSL.send(rsl); |
| 3014 | |
| 3015 | alt { |
| 3016 | |
| 3017 | /* Pick all SACCH blocks for checking */ |
| 3018 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3019 | |
| 3020 | /* The first byte of the L1 header contains the power level. |
| 3021 | * The reserved bits and the fpc bit is set to 0, so we may |
| 3022 | * compare directly. */ |
| 3023 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 3024 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 3025 | } |
| 3026 | |
| 3027 | /* Signal a new power level via RSL for the next turn. */ |
| 3028 | if (power_level < 31) { |
| 3029 | power_level := power_level + 1; |
| 3030 | ms_power.power_level := power_level; |
| 3031 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3032 | RSL.send(rsl); |
| 3033 | repeat; |
| 3034 | } |
| 3035 | |
| 3036 | } |
| 3037 | |
| 3038 | /* Ignore all other blocks */ |
| 3039 | [] L1CTL.receive { repeat; } |
| 3040 | |
| 3041 | } |
| 3042 | |
| 3043 | f_rsl_chan_deact(); |
| 3044 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3045 | |
| 3046 | setverdict(pass); |
| 3047 | } |
| 3048 | |
| 3049 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3050 | var ConnHdlr vc_conn; |
| 3051 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3052 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3053 | |
| 3054 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3055 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3056 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3057 | vc_conn.done; |
| 3058 | } |
| 3059 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3060 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3061 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3062 | /* 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] | 3063 | 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] | 3064 | 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] | 3065 | var L1ctlDlMessage l1_dl; |
| 3066 | var uint5_t ta_to_test := 16; |
| 3067 | |
| 3068 | |
| 3069 | f_l1_tune(L1CTL); |
| 3070 | RSL.clear; |
| 3071 | |
| 3072 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3073 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3074 | |
| 3075 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3076 | |
| 3077 | |
| 3078 | alt { |
| 3079 | |
| 3080 | /* Pick all SACCH blocks for checking */ |
| 3081 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3082 | |
| 3083 | /* The second byte of the L1 header contains the TA. */ |
| 3084 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 3085 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3086 | } |
| 3087 | |
| 3088 | } |
| 3089 | |
| 3090 | /* Ignore all other blocks */ |
| 3091 | [] L1CTL.receive { repeat; } |
| 3092 | |
| 3093 | } |
| 3094 | |
| 3095 | f_rsl_chan_deact(); |
| 3096 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3097 | |
| 3098 | setverdict(pass); |
| 3099 | } |
| 3100 | |
| 3101 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3102 | var ConnHdlr vc_conn; |
| 3103 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3104 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3105 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3106 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3107 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3108 | vc_conn.done; |
| 3109 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3110 | } |
| 3111 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3112 | /* 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] | 3113 | 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] | 3114 | var L1ctlDlMessage l1_dl; |
| 3115 | var uint5_t ms_power_level := 7; |
| 3116 | |
| 3117 | var RSL_IE_MS_Power ms_power; |
| 3118 | ms_power.reserved := 0; |
| 3119 | ms_power.fpc_epc := false; |
| 3120 | ms_power.power_level := ms_power_level; |
| 3121 | |
| 3122 | f_l1_tune(L1CTL); |
| 3123 | RSL.clear; |
| 3124 | |
| 3125 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3126 | |
| 3127 | timer T := 1.0; |
| 3128 | T.start; |
| 3129 | alt { |
| 3130 | /* Pick all SACCH blocks for checking */ |
| 3131 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3132 | /* The first byte of the L1 header contains the power level.. */ |
| 3133 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 3134 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3135 | } |
| 3136 | } |
| 3137 | /* Ignore all other blocks */ |
| 3138 | [] L1CTL.receive { repeat; } |
| 3139 | [] T.timeout { |
| 3140 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3141 | } |
| 3142 | } |
| 3143 | |
| 3144 | f_rsl_chan_deact(); |
| 3145 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3146 | setverdict(pass); |
| 3147 | } |
| 3148 | |
| 3149 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3150 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3151 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3152 | } |
| 3153 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3154 | /* 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] | 3155 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3156 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3157 | RSL.clear; |
| 3158 | |
| 3159 | f_est_dchan(); |
| 3160 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3161 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3162 | |
| 3163 | timer T := 40.0; |
| 3164 | T.start; |
| 3165 | alt { |
| 3166 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3167 | setverdict(pass) |
| 3168 | } |
| 3169 | [] RSL.receive { repeat }; |
| 3170 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3171 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3172 | } |
| 3173 | } |
| 3174 | f_rsl_chan_deact(); |
| 3175 | } |
| 3176 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3177 | var ConnHdlr vc_conn; |
| 3178 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3179 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3180 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3181 | pars.t_guard := 60.0; |
| 3182 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3183 | vc_conn.done; |
| 3184 | } |
| 3185 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3186 | /*********************************************************************** |
| 3187 | * Paging |
| 3188 | ***********************************************************************/ |
| 3189 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3190 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3191 | if (tmsi == 'FFFFFFFF'O) { |
| 3192 | return true; |
| 3193 | } else { |
| 3194 | return false; |
| 3195 | } |
| 3196 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3197 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3198 | private type record allowedFn { integer frame_nr } |
| 3199 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3200 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3201 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3202 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3203 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3204 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3205 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3206 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3207 | 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] | 3208 | { |
| 3209 | var integer frame_nr_51; |
| 3210 | frame_nr_51 := frame_nr mod 51 |
| 3211 | |
| 3212 | var allowedFn fn_check; |
| 3213 | fn_check.frame_nr := frame_nr_51; |
| 3214 | |
| 3215 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3216 | 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] | 3217 | return; |
| 3218 | } |
| 3219 | |
| 3220 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3221 | return; |
| 3222 | } |
| 3223 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3224 | return; |
| 3225 | } |
| 3226 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3227 | return; |
| 3228 | } |
| 3229 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3230 | return; |
| 3231 | } |
| 3232 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3233 | return; |
| 3234 | } |
| 3235 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3236 | return; |
| 3237 | } |
| 3238 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3239 | return; |
| 3240 | } |
| 3241 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3242 | return; |
| 3243 | } |
| 3244 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3245 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3246 | return; |
| 3247 | } |
| 3248 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3249 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3250 | inout integer num_paging_rcv_ids, |
| 3251 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3252 | runs on test_CT { |
| 3253 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3254 | [] 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] | 3255 | repeat; |
| 3256 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3257 | [] 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] | 3258 | var octetstring without_plen := |
| 3259 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3260 | 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] | 3261 | |
| 3262 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3263 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3264 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3265 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3266 | * TODO: does it make sense to count them? */ |
| 3267 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3268 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3269 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3270 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3271 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3272 | } |
| 3273 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3274 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3275 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3276 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3277 | } |
| 3278 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3279 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3280 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3281 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3282 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3283 | } |
| 3284 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3285 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3286 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3287 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3288 | } |
| 3289 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3290 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3291 | } |
| 3292 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3293 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3294 | } |
| 3295 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3296 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3297 | } |
| 3298 | } |
| 3299 | repeat; |
| 3300 | } |
| 3301 | } |
| 3302 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3303 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3304 | boolean combined_ccch, |
| 3305 | integer bs_ag_blks_res, |
| 3306 | float load_factor, |
| 3307 | boolean exp_load_ind, |
| 3308 | boolean exp_overload, |
| 3309 | boolean use_tmsi |
| 3310 | } |
| 3311 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3312 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3313 | integer num_paging_sent, |
| 3314 | integer num_paging_rcv_msgs, |
| 3315 | integer num_paging_rcv_ids, |
| 3316 | integer num_overload |
| 3317 | } |
| 3318 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3319 | /* Helper function for paging related testing */ |
| 3320 | 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] | 3321 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3322 | f_init_l1ctl(); |
| 3323 | f_l1_tune(L1CTL); |
| 3324 | |
| 3325 | var PagingTestState st := { |
| 3326 | num_paging_sent := 0, |
| 3327 | num_paging_rcv_msgs := 0, |
| 3328 | num_paging_rcv_ids := 0, |
| 3329 | num_overload := 0 |
| 3330 | }; |
| 3331 | |
| 3332 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3333 | var float max_pch_imsi_per_sec; |
| 3334 | if (cfg.use_tmsi) { |
| 3335 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3336 | } else { |
| 3337 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3338 | } |
| 3339 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3340 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3341 | var float time_total := 20.0; |
| 3342 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3343 | 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] | 3344 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3345 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3346 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3347 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3348 | timer T_itv := 0.0; |
| 3349 | T_itv.start; |
| 3350 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3351 | alt { |
| 3352 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3353 | [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] | 3354 | st.num_overload := st.num_overload + 1; |
| 3355 | repeat; |
| 3356 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3357 | [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] | 3358 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3359 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3360 | [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] | 3361 | log("Rx LOAD_IND"); |
| 3362 | /* FIXME: analyze/verify interval + contents */ |
| 3363 | repeat; |
| 3364 | } |
| 3365 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3366 | [] 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] | 3367 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3368 | [] T_itv.timeout { |
| 3369 | /* Send paging cmds based on elapsed time */ |
| 3370 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3371 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3372 | var MobileIdentityV mi; |
| 3373 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3374 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3375 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3376 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3377 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3378 | 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] | 3379 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3380 | |
| 3381 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3382 | 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] | 3383 | |
| 3384 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3385 | } |
| 3386 | if (st.num_paging_sent < pkt_total) { |
| 3387 | /* Wait for interval to next PAGING COMMAND */ |
| 3388 | var float time_now := T_total.read; |
| 3389 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3390 | if (next_sched > time_now) { |
| 3391 | T_itv.start(next_sched - time_now); |
| 3392 | } else { |
| 3393 | T_itv.start(0.0); |
| 3394 | } |
| 3395 | } else { |
| 3396 | /* We are done, no need to keep counting */ |
| 3397 | T_total.stop; |
| 3398 | } |
| 3399 | } |
| 3400 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3401 | } |
| 3402 | } |
| 3403 | |
| 3404 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3405 | timer T_wait := 18.0; |
| 3406 | T_wait.start; |
| 3407 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3408 | [] 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] | 3409 | [] L1CTL.receive { repeat; } |
| 3410 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3411 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3412 | [] 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] | 3413 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3414 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3415 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3419 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3420 | return st; |
| 3421 | } |
| 3422 | |
| 3423 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3424 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3425 | * - that CCCH LOAD IND (PCH) are being generated |
| 3426 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3427 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3428 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3429 | var PagingTestCfg cfg := { |
| 3430 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3431 | 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] | 3432 | load_factor := 0.8, |
| 3433 | exp_load_ind := true, |
| 3434 | exp_overload := false, |
| 3435 | use_tmsi := false |
| 3436 | }; |
| 3437 | var PagingTestState st := f_TC_paging(cfg); |
| 3438 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3439 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3440 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3441 | } else { |
| 3442 | setverdict(pass); |
| 3443 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3444 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3445 | } |
| 3446 | |
| 3447 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3448 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3449 | * - that CCCH LOAD IND (PCH) are being generated |
| 3450 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3451 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3452 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3453 | var PagingTestCfg cfg := { |
| 3454 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3455 | 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] | 3456 | load_factor := 0.8, |
| 3457 | exp_load_ind := true, |
| 3458 | exp_overload := false, |
| 3459 | use_tmsi := true |
| 3460 | }; |
| 3461 | var PagingTestState st := f_TC_paging(cfg); |
| 3462 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3463 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3464 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3465 | } else { |
| 3466 | setverdict(pass); |
| 3467 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3468 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3469 | } |
| 3470 | |
| 3471 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3472 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3473 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3474 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3475 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3476 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3477 | var PagingTestCfg cfg := { |
| 3478 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3479 | 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] | 3480 | load_factor := 2.0, |
| 3481 | exp_load_ind := true, |
| 3482 | exp_overload := true, |
| 3483 | use_tmsi := false |
| 3484 | }; |
| 3485 | var PagingTestState st := f_TC_paging(cfg); |
| 3486 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3487 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3488 | 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] | 3489 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3490 | 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] | 3491 | } else { |
| 3492 | setverdict(pass); |
| 3493 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3494 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3495 | } |
| 3496 | |
| 3497 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3498 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3499 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3500 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3501 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3502 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3503 | var PagingTestCfg cfg := { |
| 3504 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3505 | 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] | 3506 | load_factor := 2.0, |
| 3507 | exp_load_ind := true, |
| 3508 | exp_overload := true, |
| 3509 | use_tmsi := true |
| 3510 | }; |
| 3511 | var PagingTestState st := f_TC_paging(cfg); |
| 3512 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3513 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3514 | 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] | 3515 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3516 | 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] | 3517 | } else { |
| 3518 | setverdict(pass); |
| 3519 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3520 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3521 | } |
| 3522 | |
| 3523 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3524 | /*********************************************************************** |
| 3525 | * Immediate Assignment / AGCH |
| 3526 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 3527 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3528 | len := 0, |
| 3529 | ma := ''B |
| 3530 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3531 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3532 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3533 | return int2str(num_tx) & " sent, " |
| 3534 | & int2str(num_rx) & " received, " |
| 3535 | & int2str(num_del) & " deleted"; |
| 3536 | } |
| 3537 | |
| 3538 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3539 | var L1ctlDlMessage l1_dl; |
| 3540 | timer T := 10.0; |
| 3541 | var integer num_tx := 0; |
| 3542 | var integer num_rx := 0; |
| 3543 | var integer num_del := 0; |
| 3544 | var charstring res_str; |
| 3545 | var float rx_ratio; |
| 3546 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3547 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3548 | f_init_l1ctl(); |
| 3549 | f_l1_tune(L1CTL); |
| 3550 | |
| 3551 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 3552 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(t_RslChanNr_SDCCH4(0, 0), mp_trx0_arfcn)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3553 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3554 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3555 | 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] | 3556 | num_tx := num_tx+1; |
| 3557 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3558 | } |
| 3559 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3560 | T.start; |
| 3561 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3562 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3563 | num_del := num_del+1; |
| 3564 | repeat; |
| 3565 | } |
| 3566 | [] RSL_CCHAN.receive { |
| 3567 | repeat; |
| 3568 | } |
| 3569 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3570 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3571 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3572 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3573 | //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] | 3574 | } else { |
| 3575 | num_rx := num_rx+1; |
| 3576 | } |
| 3577 | repeat; |
| 3578 | } |
| 3579 | [] L1CTL.receive { repeat; } |
| 3580 | [] T.timeout { } |
| 3581 | } |
| 3582 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3583 | log("AGCH test: " & res_str); |
| 3584 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3586 | } |
| 3587 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3588 | 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] | 3589 | 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] | 3590 | } else { |
| 3591 | setverdict(pass); |
| 3592 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3593 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3594 | } |
| 3595 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3596 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3597 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3598 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3599 | } |
| 3600 | |
| 3601 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3602 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3603 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3604 | } |
| 3605 | |
| 3606 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3607 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3608 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3609 | } |
| 3610 | |
| 3611 | |
| 3612 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3613 | /*********************************************************************** |
| 3614 | * BCCH |
| 3615 | ***********************************************************************/ |
| 3616 | |
| 3617 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3618 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3619 | GsmFrameNumber frame_number, |
| 3620 | SystemInformation si |
| 3621 | } |
| 3622 | |
| 3623 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3624 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3625 | |
| 3626 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3627 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3628 | |
| 3629 | /* 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] | 3630 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 3631 | RrMessageType key, |
| 3632 | boolean bcch_ext := false) |
| 3633 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3634 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3635 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3636 | if (not bcch_ext and fn_mod51 == 2 or |
| 3637 | bcch_ext and fn_mod51 == 6) { |
| 3638 | if (arr[i].si.header.message_type == key) { |
| 3639 | return true; |
| 3640 | } |
| 3641 | } |
| 3642 | } |
| 3643 | return false; |
| 3644 | } |
| 3645 | |
| 3646 | /* 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] | 3647 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3648 | integer tc, RrMessageType key, |
| 3649 | boolean ext_bcch := false) |
| 3650 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3651 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3652 | 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] | 3653 | } |
| 3654 | } |
| 3655 | |
| 3656 | /* 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] | 3657 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3658 | RrMessageType key) |
| 3659 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3660 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3661 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3662 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3663 | return true; |
| 3664 | } |
| 3665 | } |
| 3666 | return false; |
| 3667 | } |
| 3668 | |
| 3669 | /* 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] | 3670 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 3671 | RrMessageType key, |
| 3672 | boolean bcch_ext := false, |
| 3673 | integer n := 1, integer m := 4) |
| 3674 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3675 | var integer count := 0; |
| 3676 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 3677 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 3678 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3679 | } |
| 3680 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3681 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3682 | if (not bcch_ext and fn_mod51 == 2 or |
| 3683 | bcch_ext and fn_mod51 == 6) { |
| 3684 | if (arr[i].si.header.message_type == key) { |
| 3685 | count := count + 1; |
| 3686 | } |
| 3687 | } |
| 3688 | } |
| 3689 | if (count >= n) { |
| 3690 | return true; |
| 3691 | } else { |
| 3692 | return false; |
| 3693 | } |
| 3694 | } |
| 3695 | |
| 3696 | /* 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] | 3697 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 3698 | integer tc, RrMessageType key, |
| 3699 | boolean ext_bcch := false, |
| 3700 | integer n, integer m) |
| 3701 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3702 | 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] | 3703 | 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] | 3704 | } |
| 3705 | } |
| 3706 | |
| 3707 | /* 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] | 3708 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 3709 | RrMessageType key, |
| 3710 | boolean bcch_ext := false) |
| 3711 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3712 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3713 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3714 | if (not bcch_ext and fn_mod51 == 2 or |
| 3715 | bcch_ext and fn_mod51 == 6) { |
| 3716 | if (arr[i].si.header.message_type != key) { |
| 3717 | return false; |
| 3718 | } |
| 3719 | } |
| 3720 | } |
| 3721 | return true; |
| 3722 | } |
| 3723 | |
| 3724 | /* 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] | 3725 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 3726 | integer tc, RrMessageType key, |
| 3727 | boolean ext_bcch := false) |
| 3728 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3729 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3730 | 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] | 3731 | } |
| 3732 | } |
| 3733 | |
| 3734 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3735 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3736 | boolean bcch_extended, |
| 3737 | boolean si1_present, |
| 3738 | boolean si2bis_present, |
| 3739 | boolean si2ter_present, |
| 3740 | boolean si2quater_present, |
| 3741 | boolean si7_present, |
| 3742 | boolean si8_present, |
| 3743 | boolean si9_present, |
| 3744 | boolean si13_present, |
| 3745 | boolean si13alt_present, |
| 3746 | boolean si15_present, |
| 3747 | boolean si16_present, |
| 3748 | boolean si17_present, |
| 3749 | boolean si2n_present, |
| 3750 | boolean si21_present, |
| 3751 | boolean si22_present |
| 3752 | } |
| 3753 | |
| 3754 | /* 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] | 3755 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 3756 | SystemInformationVectorPerTc si_per_tc) |
| 3757 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3758 | var integer i; |
| 3759 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3760 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3761 | 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] | 3762 | } |
| 3763 | } |
| 3764 | if (cfg.si1_present) { |
| 3765 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3766 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3767 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3768 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3769 | /* make sure *ALL* contain SI1 */ |
| 3770 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3771 | } |
| 3772 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3773 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3774 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3775 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3776 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3777 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3778 | |
| 3779 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3780 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3781 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3782 | * consecutive occurrences of TC = 4. */ |
| 3783 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3784 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3785 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3786 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3787 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3788 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3789 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3790 | } |
| 3791 | |
| 3792 | if (cfg.si7_present or cfg.si8_present) { |
| 3793 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3794 | * if System Information type 4 does not contain all information needed for cell |
| 3795 | * selection and reselection. */ |
| 3796 | if (not cfg.bcch_extended) { |
| 3797 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3798 | } |
| 3799 | if (cfg.si7_present) { |
| 3800 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3801 | } |
| 3802 | if (cfg.si8_present) { |
| 3803 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3804 | } |
| 3805 | } |
| 3806 | |
| 3807 | if (cfg.si2quater_present) { |
| 3808 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3809 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3810 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3811 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3812 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3813 | if (not (cfg.bcch_extended)) { |
| 3814 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3815 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3816 | } else { |
| 3817 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3818 | } |
| 3819 | } else { |
| 3820 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3821 | } |
| 3822 | } |
| 3823 | if (cfg.si9_present) { |
| 3824 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3825 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3826 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3827 | } |
| 3828 | if (cfg.si13_present) { |
| 3829 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3830 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3831 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3832 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3833 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3834 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3835 | if (not cfg.bcch_extended) { |
| 3836 | log("not-bccch-extended"); |
| 3837 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3838 | } else { |
| 3839 | log("bccch-extended"); |
| 3840 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3841 | } |
| 3842 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3843 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3844 | } |
| 3845 | } |
| 3846 | if (cfg.si16_present or cfg.si17_present) { |
| 3847 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3848 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3849 | if (cfg.si22_present) { |
| 3850 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3851 | } |
| 3852 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3853 | 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] | 3854 | } |
| 3855 | if (not cfg.bcch_extended) { |
| 3856 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3857 | } |
| 3858 | if (cfg.si16_present) { |
| 3859 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3860 | } |
| 3861 | if (cfg.si17_present) { |
| 3862 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3863 | } |
| 3864 | } |
| 3865 | |
| 3866 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3867 | * broadcast information. The frequency with which they are sent is determined by the |
| 3868 | * system operator. System Information type 9 identifies the scheduling of System |
| 3869 | * Information type 18 and 20 messages. */ |
| 3870 | |
| 3871 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3872 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 3873 | * Information Type 9. */ |
| 3874 | |
| 3875 | if (cfg.si15_present) { |
| 3876 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 3877 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 3878 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 3879 | * 4 consecutive occurrences of TC = 1. */ |
| 3880 | if (not cfg.bcch_extended) { |
| 3881 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 3882 | } else { |
| 3883 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 3884 | } |
| 3885 | } |
| 3886 | if (cfg.si13alt_present) { |
| 3887 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 3888 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 3889 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 3890 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 3891 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 3892 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 3893 | * of TC = 4. */ |
| 3894 | if (cfg.si13_present) { |
| 3895 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 3896 | } |
| 3897 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3898 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3899 | } |
| 3900 | if (not cfg.bcch_extended) { |
| 3901 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 3902 | } else { |
| 3903 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 3904 | } |
| 3905 | } |
| 3906 | if (cfg.si2n_present) { |
| 3907 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 3908 | * as determined by the system operator. In the case that the message is sent on the |
| 3909 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 3910 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 3911 | * consecutive occurrences of TC = 4. */ |
| 3912 | if (not cfg.bcch_extended) { |
| 3913 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 3914 | } else { |
| 3915 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 3916 | } |
| 3917 | } |
| 3918 | if (cfg.si21_present) { |
| 3919 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 3920 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 3921 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 3922 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 3923 | * cell then this message shall only be sent on BCCH Ext. */ |
| 3924 | if (not cfg.bcch_extended) { |
| 3925 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 3926 | } else { |
| 3927 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 3928 | 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] | 3929 | 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] | 3930 | } |
| 3931 | } |
| 3932 | } |
| 3933 | if (cfg.si22_present) { |
| 3934 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 3935 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 3936 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 3937 | * =2 and TC=6. */ |
| 3938 | if (cfg.si16_present or cfg.si17_present) { |
| 3939 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3940 | } |
| 3941 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 3942 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3943 | 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] | 3944 | } |
| 3945 | if (not cfg.bcch_extended) { |
| 3946 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 3947 | } else { |
| 3948 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 3949 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 3950 | } |
| 3951 | } |
| 3952 | } |
| 3953 | |
| 3954 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3955 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 3956 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3957 | timer T := duration; |
| 3958 | var SystemInformationVectorPerTc si_per_tc; |
| 3959 | var L1ctlDlMessage l1_dl; |
| 3960 | |
| 3961 | /* initialize all per-TC vectors empty */ |
| 3962 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3963 | si_per_tc[i] := {}; |
| 3964 | } |
| 3965 | |
| 3966 | /* flush all previous L1 queued msgs */ |
| 3967 | pt.clear; |
| 3968 | |
| 3969 | T.start; |
| 3970 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3971 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 3972 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 3973 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 3974 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3975 | repeat; |
| 3976 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 3977 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3978 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 3979 | log("SI received at TC=", tc, ": ", sig.si); |
| 3980 | /* append to the per-TC bucket */ |
| 3981 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 3982 | repeat; |
| 3983 | } |
| 3984 | [] pt.receive { repeat; } |
| 3985 | [] T.timeout { } |
| 3986 | } |
| 3987 | |
| 3988 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3989 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 3990 | } |
| 3991 | log("si_per_tc=", si_per_tc); |
| 3992 | return si_per_tc; |
| 3993 | } |
| 3994 | |
| 3995 | /* helper function: Set given SI via RSL + validate scheduling. |
| 3996 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 3997 | private function f_TC_si_sched(float duration := 8.0) runs on test_CT { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3998 | var SystemInformationVectorPerTc si_per_tc; |
| 3999 | f_init_l1ctl(); |
| 4000 | f_l1_tune(L1CTL); |
| 4001 | |
| 4002 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4003 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4004 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4005 | |
| 4006 | setverdict(pass); |
| 4007 | } |
| 4008 | |
| 4009 | testcase TC_si_sched_default() runs on test_CT { |
| 4010 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4011 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4012 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4013 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4014 | } |
| 4015 | |
| 4016 | testcase TC_si_sched_1() runs on test_CT { |
| 4017 | f_init(); |
| 4018 | si_cfg.si1_present := true; |
| 4019 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4020 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4021 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4022 | } |
| 4023 | |
| 4024 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4025 | f_init(); |
| 4026 | si_cfg.si2bis_present := true; |
| 4027 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4028 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4029 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4030 | } |
| 4031 | |
| 4032 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4033 | f_init(); |
| 4034 | si_cfg.si2ter_present := true; |
| 4035 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4036 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4041 | f_init(); |
| 4042 | si_cfg.si2bis_present := true; |
| 4043 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4044 | si_cfg.si2ter_present := true; |
| 4045 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4046 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4047 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4048 | } |
| 4049 | |
| 4050 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4051 | f_init(); |
| 4052 | si_cfg.si2quater_present := true; |
| 4053 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4054 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4055 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4056 | } |
| 4057 | |
| 4058 | testcase TC_si_sched_13() runs on test_CT { |
| 4059 | f_init(); |
| 4060 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4061 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4062 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4063 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4064 | } |
| 4065 | |
| 4066 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 4067 | f_init(); |
| 4068 | si_cfg.si2bis_present := true; |
| 4069 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4070 | si_cfg.si2ter_present := true; |
| 4071 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4072 | si_cfg.si2quater_present := true; |
| 4073 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 4074 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4075 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4076 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4077 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4078 | } |
| 4079 | |
| 4080 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4081 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4082 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4083 | /* FIXME: enable / disable individual BCCH info */ |
| 4084 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4085 | /* expect no ERROR REPORT after either of them * |
| 4086 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4087 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4088 | } |
| 4089 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4090 | /*********************************************************************** |
| 4091 | * Low-Level Protocol Errors / ERROR REPORT |
| 4092 | ***********************************************************************/ |
| 4093 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4094 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4095 | timer T := 5.0; |
| 4096 | T.start; |
| 4097 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4098 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4099 | setverdict(pass); |
| 4100 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4101 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4102 | 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] | 4103 | } |
| 4104 | [] RSL_CCHAN.receive { |
| 4105 | repeat; |
| 4106 | } |
| 4107 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4108 | 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] | 4109 | } |
| 4110 | } |
| 4111 | } |
| 4112 | |
| 4113 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4114 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4115 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4116 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4117 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4118 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4119 | |
| 4120 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4121 | } |
| 4122 | |
| 4123 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4124 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4125 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4126 | |
| 4127 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4128 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4129 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4130 | |
| 4131 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4132 | } |
| 4133 | |
| 4134 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4135 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4136 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4137 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4138 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4139 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4140 | |
| 4141 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4142 | } |
| 4143 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4144 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4145 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4146 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4147 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4148 | RSL.send(rsl); |
| 4149 | f_rslem_unregister(0, g_chan_nr); |
| 4150 | } |
| 4151 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4152 | var ConnHdlr vc_conn; |
| 4153 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4154 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4155 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4156 | |
| 4157 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4158 | vc_conn.done; |
| 4159 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4160 | |
| 4161 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4162 | } |
| 4163 | |
| 4164 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4165 | 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] | 4166 | var template (value) RSL_Message rsl_tx; |
| 4167 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4168 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4169 | RSL.send(rsl_tx); |
| 4170 | f_rslem_unregister(0, g_chan_nr); |
| 4171 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4172 | 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] | 4173 | var template (value) RSL_Message rsl_tx; |
| 4174 | /* we first have to activate the dedicated channel */ |
| 4175 | f_rsl_chan_act(g_pars.chan_mode); |
| 4176 | /* ... to then send an invalid RLL message */ |
| 4177 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4178 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4179 | RSL.send(rsl_tx); |
| 4180 | f_rslem_unregister(0, g_chan_nr); |
| 4181 | } |
| 4182 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4183 | var ConnHdlr vc_conn; |
| 4184 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4185 | var template (value) RSL_Message rsl_tx; |
| 4186 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4187 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4188 | |
| 4189 | /* Common Channel with wrong message type */ |
| 4190 | RSL_CCHAN.clear; |
| 4191 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4192 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4193 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4194 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4195 | |
| 4196 | /* TRX Management */ |
| 4197 | RSL_CCHAN.clear; |
| 4198 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4199 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4200 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4201 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4202 | |
| 4203 | /* Dedicated Channel */ |
| 4204 | RSL_CCHAN.clear; |
| 4205 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4206 | vc_conn.done; |
| 4207 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4208 | |
| 4209 | /* RLL */ |
| 4210 | RSL_CCHAN.clear; |
| 4211 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4212 | vc_conn.done; |
| 4213 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4214 | } |
| 4215 | |
| 4216 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4217 | 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] | 4218 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4219 | f_rslem_unregister(0, g_chan_nr); |
| 4220 | } |
| 4221 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4222 | var ConnHdlr vc_conn; |
| 4223 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4224 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4225 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4226 | |
| 4227 | RSL_CCHAN.clear; |
| 4228 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4229 | vc_conn.done; |
| 4230 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4231 | } |
| 4232 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4233 | /*********************************************************************** |
| 4234 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4235 | ***********************************************************************/ |
| 4236 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4237 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4238 | 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] | 4239 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4240 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4241 | } |
| 4242 | testcase TC_ipa_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 | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4245 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4246 | vc_conn.done; |
| 4247 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4248 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4249 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4250 | 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] | 4251 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4252 | "IPA CRCX ACK"); |
| 4253 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4254 | "IPA CRCX NACK"); |
| 4255 | } |
| 4256 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4257 | 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] | 4258 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4259 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4260 | vc_conn.done; |
| 4261 | } |
| 4262 | |
| 4263 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4264 | 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] | 4265 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4266 | "IPA CRCX ACK"); |
| 4267 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4268 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4269 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4270 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4271 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4272 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4273 | "IPA MDCX ACK"); |
| 4274 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4275 | "IPA DLCX ACK"); |
| 4276 | } |
| 4277 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4278 | 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] | 4279 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4280 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4281 | vc_conn.done; |
| 4282 | } |
| 4283 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4284 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4285 | 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] | 4286 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4287 | "IPA CRCX ACK"); |
| 4288 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4289 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4290 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4291 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4292 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4293 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4294 | "IPA MDCX ACK"); |
| 4295 | /* Second MDCX */ |
| 4296 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4297 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4298 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4299 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4300 | "IPA MDCX ACK"); |
| 4301 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4302 | "IPA DLCX ACK"); |
| 4303 | } |
| 4304 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4305 | 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] | 4306 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4307 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4308 | vc_conn.done; |
| 4309 | } |
| 4310 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4311 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4312 | 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] | 4313 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4314 | "IPA CRCX NACK"); |
| 4315 | } |
| 4316 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4317 | var ConnHdlrPars pars; |
| 4318 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4319 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4320 | |
| 4321 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4322 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4323 | vc_conn.done; |
| 4324 | |
| 4325 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4326 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4327 | vc_conn.done; |
| 4328 | } |
| 4329 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4330 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4331 | /*********************************************************************** |
| 4332 | * PCU Socket related tests |
| 4333 | ***********************************************************************/ |
| 4334 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4335 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4336 | 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] | 4337 | runs on test_CT { |
| 4338 | timer T := 3.0; |
| 4339 | |
| 4340 | /* we don't expect any RTS.req before PDCH are active */ |
| 4341 | T.start; |
| 4342 | alt { |
| 4343 | [] 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] | 4344 | 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] | 4345 | } |
| 4346 | [] PCU.receive { repeat; } |
| 4347 | [] T.timeout { } |
| 4348 | } |
| 4349 | |
| 4350 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4351 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4352 | |
| 4353 | /* we now expect RTS.req for this timeslot (only) */ |
| 4354 | T.start; |
| 4355 | alt { |
| 4356 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4357 | setverdict(pass); |
| 4358 | } |
| 4359 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4360 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4361 | 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] | 4362 | } |
| 4363 | [] 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] | 4364 | 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] | 4365 | } |
| 4366 | [] PCU.receive { repeat; } |
| 4367 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4368 | 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] | 4369 | } |
| 4370 | [not exp_success] T.timeout { |
| 4371 | setverdict(pass); |
| 4372 | } |
| 4373 | } |
| 4374 | } |
| 4375 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4376 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4377 | 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] | 4378 | runs on test_CT { |
| 4379 | timer T := 3.0; |
| 4380 | |
| 4381 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4382 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
Harald Welte | c87d81f | 2020-10-11 18:17:25 +0200 | [diff] [blame] | 4383 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 4384 | * when it will actually have been executed in the BTS */ |
| 4385 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4386 | PCU.clear; |
| 4387 | /* we now expect no RTS.req for this timeslot */ |
| 4388 | T.start; |
| 4389 | alt { |
| 4390 | [] 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] | 4391 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4392 | } |
| 4393 | [] PCU.receive { repeat; } |
| 4394 | [] T.timeout { |
| 4395 | setverdict(pass); |
| 4396 | } |
| 4397 | } |
| 4398 | } |
| 4399 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4400 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4401 | f_init(); |
| 4402 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4403 | } |
| 4404 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4405 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4406 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4407 | f_init_pcu_test(); |
| 4408 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4409 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4410 | } |
| 4411 | |
| 4412 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4413 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4414 | f_init_pcu_test(); |
| 4415 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4416 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4417 | } |
| 4418 | |
| 4419 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4420 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4421 | f_init_pcu_test(); |
| 4422 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4423 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4424 | } |
| 4425 | |
| 4426 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4427 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4428 | f_init_pcu_test(); |
| 4429 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4430 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4431 | } |
| 4432 | |
| 4433 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4434 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4435 | f_init_pcu_test(); |
| 4436 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4437 | /* Activate PDCH */ |
| 4438 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4439 | f_sleep(1.0); |
| 4440 | /* and De-Activate again */ |
| 4441 | f_TC_pcu_deact_req(0, 0, 7); |
| 4442 | } |
| 4443 | |
| 4444 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4445 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4446 | f_init_pcu_test(); |
| 4447 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4448 | f_TC_pcu_deact_req(0, 0, 1); |
| 4449 | } |
| 4450 | |
| 4451 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4452 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4453 | const octetstring si13 := '00010203040506070909'O; |
| 4454 | var PCUIF_send_data sd; |
| 4455 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4456 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4457 | |
| 4458 | /* Set SI13 via RSL */ |
| 4459 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4460 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4461 | T.start; |
| 4462 | alt { |
| 4463 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4464 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4465 | setverdict(pass); |
| 4466 | } else { |
| 4467 | repeat; |
| 4468 | } |
| 4469 | } |
| 4470 | [] PCU.receive { repeat; } |
| 4471 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4472 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4473 | } |
| 4474 | } |
| 4475 | } |
| 4476 | |
| 4477 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4478 | |
| 4479 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4480 | 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] | 4481 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4482 | runs on test_CT |
| 4483 | { |
| 4484 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4485 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4486 | } |
| 4487 | |
| 4488 | /* 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] | 4489 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4490 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4491 | runs on test_CT |
| 4492 | { |
| 4493 | var PCUIF_send_data sd; |
| 4494 | |
| 4495 | timer T := 3.0; |
| 4496 | T.start; |
| 4497 | alt { |
| 4498 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4499 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4500 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4501 | sd.data.u.rts_req.fn, sapi, data); |
| 4502 | } |
| 4503 | [] PCU.receive { repeat; } |
| 4504 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4505 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4506 | } |
| 4507 | } |
| 4508 | } |
| 4509 | |
| 4510 | /* Send DATA.req on invalid BTS */ |
| 4511 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4512 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4513 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4514 | |
| 4515 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4516 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4517 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4518 | f_TfiUsfArrSet(tua, 7, 0); |
| 4519 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4520 | f_sleep(1.0); |
| 4521 | |
| 4522 | 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] | 4523 | } |
| 4524 | |
| 4525 | /* Send DATA.req on invalid TRX */ |
| 4526 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4527 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4528 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4529 | |
| 4530 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4531 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4532 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4533 | f_TfiUsfArrSet(tua, 7, 0); |
| 4534 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4535 | f_sleep(1.0); |
| 4536 | |
| 4537 | 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] | 4538 | } |
| 4539 | |
| 4540 | /* Send DATA.req on invalid timeslot */ |
| 4541 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4542 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4543 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4544 | |
| 4545 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4546 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4547 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4548 | f_TfiUsfArrSet(tua, 7, 0); |
| 4549 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4550 | f_sleep(1.0); |
| 4551 | |
| 4552 | 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] | 4553 | } |
| 4554 | |
| 4555 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4556 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4557 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4558 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4559 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4560 | f_virtphy_common(); |
| 4561 | |
| 4562 | f_TfiUsfArrSet(tua, 7, 0); |
| 4563 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4564 | f_sleep(1.0); |
| 4565 | |
| 4566 | 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] | 4567 | } |
| 4568 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4569 | 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] | 4570 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4571 | boolean wait_rts := true) |
| 4572 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4573 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4574 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4575 | |
| 4576 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4577 | if (wait_rts) { |
| 4578 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4579 | } else { |
| 4580 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4581 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4582 | |
| 4583 | T.start; |
| 4584 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4585 | [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] | 4586 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4587 | setverdict(pass); |
| 4588 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4589 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4590 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4591 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4592 | [] L1CTL.receive { |
| 4593 | repeat; |
| 4594 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4595 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4596 | setverdict(fail, "Timeout waiting for ", data); |
| 4597 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4598 | [not expect_data] T.timeout { |
| 4599 | setverdict(pass); |
| 4600 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4601 | } |
| 4602 | } |
| 4603 | |
| 4604 | private function f_disable_dynamic_ts() runs on test_CT |
| 4605 | { |
| 4606 | f_init_vty_bsc(); |
| 4607 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4608 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4609 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4610 | 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] | 4611 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4612 | } |
| 4613 | |
| 4614 | private function f_virtphy_common() runs on test_CT { |
| 4615 | f_disable_dynamic_ts(); |
| 4616 | f_init_l1ctl(); |
| 4617 | f_l1_tune(L1CTL); |
| 4618 | } |
| 4619 | |
| 4620 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4621 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4622 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4623 | |
| 4624 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4625 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4626 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4627 | f_TfiUsfArrSet(tua, 7, 0); |
| 4628 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4629 | f_sleep(1.0); |
| 4630 | |
| 4631 | 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] | 4632 | } |
| 4633 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4634 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4635 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4636 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4637 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4638 | |
| 4639 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4640 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4641 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4642 | f_TfiUsfArrSet(tua, 7, 0); |
| 4643 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4644 | f_sleep(1.0); |
| 4645 | |
| 4646 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4647 | } |
| 4648 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4649 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4650 | runs on test_CT { |
| 4651 | var template PCUIF_Message pcu_rach_ind; |
| 4652 | var PCUIF_send_data sd; |
| 4653 | var GsmFrameNumber fn; |
| 4654 | timer T; |
| 4655 | |
| 4656 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4657 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4658 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4659 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4660 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4661 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4662 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4663 | |
| 4664 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4665 | T.start(52.0 * 4.615 / 1000.0); |
| 4666 | alt { |
| 4667 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4668 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4669 | setverdict(pass); |
| 4670 | T.stop; |
| 4671 | } |
| 4672 | [] PCU.receive { repeat; } |
| 4673 | [] T.timeout { |
| 4674 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4675 | /* Keep going, that's not the end of the world */ |
| 4676 | } |
| 4677 | } |
| 4678 | } |
| 4679 | |
| 4680 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4681 | var L1ctlDlMessage dl; |
| 4682 | var octetstring data; |
| 4683 | timer T; |
| 4684 | |
| 4685 | f_init_pcu_test(); |
| 4686 | f_init_l1ctl(); |
| 4687 | f_l1_tune(L1CTL); |
| 4688 | |
| 4689 | /* Activate PDCH channel on TS7 */ |
| 4690 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4691 | |
| 4692 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4693 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | 13a29d5 | 2020-07-15 14:41:54 +0700 | [diff] [blame] | 4694 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 4695 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4696 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4697 | |
| 4698 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4699 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4700 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4701 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4702 | } |
| 4703 | |
| 4704 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4705 | data := f_rnd_octstring(23); |
| 4706 | |
| 4707 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4708 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4709 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4710 | |
| 4711 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4712 | * let's give it more time in case if we miss the beginning. */ |
| 4713 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4714 | alt { |
| 4715 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4716 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4717 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4718 | frame := data)) -> value dl { |
| 4719 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4720 | setverdict(pass); |
| 4721 | T.stop; |
| 4722 | } |
| 4723 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4724 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4725 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4726 | l2_data := data)) -> value dl { |
| 4727 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4728 | setverdict(pass); |
| 4729 | T.stop; |
| 4730 | } |
| 4731 | [] L1CTL.receive { repeat; } |
| 4732 | [] T.timeout { |
| 4733 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4734 | } |
| 4735 | } |
| 4736 | } |
| 4737 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4738 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4739 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4740 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4741 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4742 | f_init_l1ctl(); |
| 4743 | f_l1_tune(L1CTL); |
| 4744 | |
| 4745 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4746 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4747 | |
| 4748 | T.start; |
| 4749 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4750 | [] 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] | 4751 | setverdict(pass); |
| 4752 | } |
| 4753 | [] L1CTL.receive { repeat; } |
| 4754 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4755 | 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] | 4756 | } |
| 4757 | } |
| 4758 | } |
| 4759 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4760 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4761 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4762 | timer T := 3.0; |
| 4763 | f_init_pcu_test(); |
| 4764 | f_init_l1ctl(); |
| 4765 | f_l1_tune(L1CTL); |
| 4766 | |
| 4767 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4768 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4769 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4770 | |
| 4771 | T.start; |
| 4772 | alt { |
| 4773 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4774 | setverdict(pass); |
| 4775 | } |
| 4776 | [] L1CTL.receive { repeat; } |
| 4777 | [] T.timeout { |
| 4778 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4779 | } |
| 4780 | } |
| 4781 | } |
| 4782 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4783 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4784 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4785 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4786 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4787 | f_init_l1ctl(); |
| 4788 | f_l1_tune(L1CTL); |
| 4789 | |
| 4790 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4791 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4792 | |
| 4793 | timer T := 0.5; |
| 4794 | T.start; |
| 4795 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4796 | [] 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] | 4797 | /* TODO: verify paging group */ |
| 4798 | setverdict(pass); |
| 4799 | } |
| 4800 | [] L1CTL.receive { repeat; } |
| 4801 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4802 | 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] | 4803 | } |
| 4804 | } |
| 4805 | } |
| 4806 | |
| 4807 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4808 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4809 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4810 | f_init_l1ctl(); |
| 4811 | f_l1_tune(L1CTL); |
| 4812 | |
| 4813 | var GsmFrameNumber fn_last := 0; |
| 4814 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4815 | var OCT1 ra := f_rnd_ra_ps(); |
| 4816 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4817 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4818 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4819 | } |
| 4820 | fn_last := fn; |
| 4821 | |
| 4822 | timer T := 2.0; |
| 4823 | T.start; |
| 4824 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4825 | [] 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] | 4826 | T.stop; |
| 4827 | } |
| 4828 | [] 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] | 4829 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4830 | } |
| 4831 | [] PCU.receive { repeat; } |
| 4832 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4833 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4834 | } |
| 4835 | } |
| 4836 | } |
| 4837 | setverdict(pass); |
| 4838 | } |
| 4839 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4840 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4841 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4842 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4843 | var template PCUIF_Message pcu_rach_ind; |
| 4844 | var GsmFrameNumber fn_last := 0; |
| 4845 | var L1ctlRachSynchSeq synch_seq; |
| 4846 | var PCUIF_BurstType pcu_bt; |
| 4847 | var GsmFrameNumber fn; |
| 4848 | var BIT11 ra11; |
| 4849 | |
| 4850 | f_init_pcu_test(); |
| 4851 | f_init_l1ctl(); |
| 4852 | f_l1_tune(L1CTL); |
| 4853 | |
| 4854 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4855 | /* We need to test both TS1 & TS2 */ |
| 4856 | if (i rem 2 == 0) { |
| 4857 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4858 | pcu_bt := BURST_TYPE_1; |
| 4859 | } else { |
| 4860 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4861 | pcu_bt := BURST_TYPE_2; |
| 4862 | } |
| 4863 | |
| 4864 | ra11 := f_rnd_ra11_ps(); |
| 4865 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4866 | if (fn == fn_last) { |
| 4867 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4868 | "Two RACH in same FN?!?"); |
| 4869 | } |
| 4870 | fn_last := fn; |
| 4871 | |
| 4872 | /* Compose the expected message */ |
| 4873 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4874 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4875 | ra := bit2int(ra11), |
| 4876 | is_11bit := 1, |
| 4877 | burst_type := pcu_bt, |
| 4878 | fn := fn); |
| 4879 | |
| 4880 | timer T := 2.0; |
| 4881 | T.start; |
| 4882 | alt { |
| 4883 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 4884 | T.stop; |
| 4885 | } |
| 4886 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 4887 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 4888 | } |
| 4889 | [] PCU.receive { repeat; } |
| 4890 | [] T.timeout { |
| 4891 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 4892 | } |
| 4893 | } |
| 4894 | } |
| 4895 | setverdict(pass); |
| 4896 | } |
| 4897 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4898 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 4899 | runs on test_CT { |
| 4900 | var template PCUIF_send_data sdt; |
| 4901 | var PCUIF_send_data sd; |
| 4902 | var int16_t lqual_cb; |
| 4903 | timer T := 1.0; |
| 4904 | |
| 4905 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 4906 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 4907 | |
| 4908 | /* Send a random PDTCH frame over Um */ |
| 4909 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 4910 | '0000'O & f_rnd_octstring(21))); |
| 4911 | |
| 4912 | T.start; |
| 4913 | alt { |
| 4914 | /* If expected link quality is above the threshold */ |
| 4915 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 4916 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 4917 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 4918 | |
| 4919 | /* Make sure the actual link quality matches the expected value */ |
| 4920 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 4921 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 4922 | "expected value ", lqual_cb_exp)); |
| 4923 | } else { |
| 4924 | setverdict(pass); |
| 4925 | } |
| 4926 | } |
| 4927 | /* If expected link quality is below the threshold */ |
| 4928 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 4929 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4930 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 4931 | } |
| 4932 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 4933 | [] PCU.receive { repeat; } |
| 4934 | [lqual_cb_exp < thresh] T.timeout { |
| 4935 | log("Rx nothing, as expected"); |
| 4936 | setverdict(pass); |
| 4937 | } |
| 4938 | [lqual_cb_exp >= thresh] T.timeout { |
| 4939 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4940 | "Timeout waiting for PCUIF_DATA.ind"); |
| 4941 | } |
| 4942 | } |
| 4943 | } |
| 4944 | |
| 4945 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 4946 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 4947 | f_init_pcu_test(); |
| 4948 | PCU.clear; |
| 4949 | |
| 4950 | f_init_l1ctl(); |
| 4951 | f_l1_tune(L1CTL); |
| 4952 | |
| 4953 | /* Activate a PDCH channel on TS7 */ |
| 4954 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4955 | |
| 4956 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4957 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | 13a29d5 | 2020-07-15 14:41:54 +0700 | [diff] [blame] | 4958 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 4959 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4960 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4961 | |
| 4962 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 4963 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 4964 | var TrxcMessage ret; |
| 4965 | |
| 4966 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 4967 | valueof(ts_TRXC_FAKE_CI(i))); |
| 4968 | |
| 4969 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 4970 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 4971 | } |
| 4972 | } |
| 4973 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4974 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 4975 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4976 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4977 | |
| 4978 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4979 | var MobileIdentityLV mi_lv; |
| 4980 | var octetstring mi_lv_enc; |
| 4981 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4982 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4983 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4984 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4985 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4986 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4987 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4988 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4989 | |
| 4990 | /* Fancy encoding for PCUIF */ |
| 4991 | mi_lv := valueof(ts_MI_LV(mi)); |
| 4992 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 4993 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4994 | |
| 4995 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4996 | 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] | 4997 | T.start; |
| 4998 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4999 | [] 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] | 5000 | } |
| 5001 | [] 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] | 5002 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5003 | } |
| 5004 | [] PCU.receive { repeat; } |
| 5005 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5006 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5007 | } |
| 5008 | } |
| 5009 | } |
| 5010 | setverdict(pass); |
| 5011 | } |
| 5012 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5013 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5014 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5015 | var PCUIF_send_data pcu_sd; |
| 5016 | var integer num_time_ind := 0; |
| 5017 | var integer first_fn, last_fn; |
| 5018 | var float test_duration := 5.0; |
| 5019 | timer T; |
| 5020 | |
| 5021 | f_init_pcu_test(); |
| 5022 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5023 | |
| 5024 | PCU.clear; |
| 5025 | T.start(test_duration); |
| 5026 | alt { |
| 5027 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5028 | num_time_ind := num_time_ind + 1; |
| 5029 | if (not isbound(first_fn)) { |
| 5030 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5031 | } |
| 5032 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5033 | repeat; |
| 5034 | } |
| 5035 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5036 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5037 | repeat; |
| 5038 | } |
| 5039 | [] PCU.receive { |
| 5040 | repeat; |
| 5041 | } |
| 5042 | [] T.timeout {} |
| 5043 | } |
| 5044 | var integer fn_expired := last_fn - first_fn; |
| 5045 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5046 | |
| 5047 | /* verify the number of frames expired matches our expectation */ |
| 5048 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5049 | 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] | 5050 | 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] | 5051 | if (not match(fn_expired, t_fn_expected)) { |
| 5052 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5053 | } |
| 5054 | |
| 5055 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5056 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5057 | /* Add some tolerance */ |
| 5058 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5059 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5060 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5061 | } |
| 5062 | |
| 5063 | setverdict(pass); |
| 5064 | } |
| 5065 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5066 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5067 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5068 | var PCUIF_send_data pcu_sd; |
| 5069 | var integer first_fn, last_fn; |
| 5070 | var integer num_rts_pdtch := 0; |
| 5071 | var integer num_rts_ptcch := 0; |
| 5072 | var float test_duration := 5.0; |
| 5073 | timer T; |
| 5074 | |
| 5075 | f_init_pcu_test(); |
| 5076 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5077 | |
| 5078 | PCU.clear; |
| 5079 | T.start(test_duration); |
| 5080 | alt { |
| 5081 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5082 | -> value pcu_sd { |
| 5083 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5084 | if (not isbound(first_fn)) { |
| 5085 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5086 | } |
| 5087 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5088 | repeat; |
| 5089 | } |
| 5090 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5091 | -> value pcu_sd { |
| 5092 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5093 | if (not isbound(first_fn)) { |
| 5094 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5095 | } |
| 5096 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5097 | repeat; |
| 5098 | } |
| 5099 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5100 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5101 | repeat; |
| 5102 | } |
| 5103 | [] PCU.receive { |
| 5104 | repeat; |
| 5105 | } |
| 5106 | [] T.timeout {} |
| 5107 | } |
| 5108 | var integer fn_expired := last_fn - first_fn; |
| 5109 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5110 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5111 | |
| 5112 | /* verify the number of frames expired matches our expectation */ |
| 5113 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5114 | 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] | 5115 | 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] | 5116 | if (not match(fn_expired, t_fn_expected)) { |
| 5117 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5118 | } |
| 5119 | |
| 5120 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5121 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5122 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5123 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5124 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5125 | t_ptcch_exp); |
| 5126 | } |
| 5127 | |
| 5128 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5129 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5130 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5131 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5132 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5133 | t_pdtch_exp); |
| 5134 | } |
| 5135 | |
| 5136 | setverdict(pass); |
| 5137 | } |
| 5138 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5139 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5140 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5141 | var PCUIF_send_data pcu_sd; |
| 5142 | var integer num_time_ind := 0; |
| 5143 | var integer first_fn, last_fn; |
| 5144 | var float test_duration := 5.0; |
| 5145 | timer T; |
| 5146 | |
| 5147 | f_init_pcu_test(); |
| 5148 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5149 | |
| 5150 | /* re-connect CTRL port from BTS to BSC */ |
| 5151 | f_ipa_ctrl_stop(); |
| 5152 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 5153 | |
| 5154 | /* Send that OML Alert */ |
| 5155 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5156 | |
| 5157 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5158 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5159 | setverdict(pass); |
| 5160 | } |
| 5161 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5162 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5163 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5164 | var PCUIF_Message first_info; |
| 5165 | var integer pcu_conn_id := -1; |
| 5166 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5167 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5168 | var OCT4 tlli := '01020304'O; |
| 5169 | var OCT1 cause := '23'O; |
| 5170 | timer T := 5.0; |
| 5171 | |
| 5172 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5173 | |
| 5174 | f_l1_tune(L1CTL); |
| 5175 | RSL.clear; |
| 5176 | |
| 5177 | f_est_dchan(); |
| 5178 | L1CTL.clear; |
| 5179 | |
| 5180 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5181 | |
| 5182 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5183 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5184 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5185 | |
| 5186 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5187 | T.start; |
| 5188 | alt { |
| 5189 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5190 | setverdict(pass); |
| 5191 | } |
| 5192 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5193 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5194 | } |
| 5195 | [] PCU.receive { |
| 5196 | repeat; |
| 5197 | } |
| 5198 | [] T.timeout { |
| 5199 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5200 | } |
| 5201 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5202 | |
| 5203 | /* release the channel */ |
| 5204 | f_rsl_chan_deact(); |
| 5205 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5206 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5207 | } |
| 5208 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5209 | var ConnHdlrPars pars; |
| 5210 | var ConnHdlr vc_conn; |
| 5211 | |
| 5212 | f_init(); |
| 5213 | |
| 5214 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5215 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5216 | vc_conn.done; |
| 5217 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5218 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5219 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5220 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 5221 | timer T := 5.0; |
| 5222 | |
| 5223 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5224 | f_init(); |
| 5225 | |
| 5226 | /* try to establish a second connection, expect it to fail */ |
| 5227 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5228 | T.start; |
| 5229 | alt { |
| 5230 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 5231 | setverdict(pass); |
| 5232 | } |
| 5233 | [] PCU.receive(UD_connect_result:?) { |
| 5234 | setverdict(fail, "Unexpected unix domain connect result"); |
| 5235 | } |
| 5236 | [] T.timeout { |
| 5237 | setverdict(pass); |
| 5238 | } |
| 5239 | } |
| 5240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5241 | } |
| 5242 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5243 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5244 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5245 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5246 | f_init(); |
| 5247 | |
| 5248 | f_sleep(1.0); |
| 5249 | |
| 5250 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5251 | g_pcu_conn_id := -1; |
| 5252 | |
| 5253 | f_sleep(1.0); |
| 5254 | |
| 5255 | /* re-connect */ |
| 5256 | PCU.clear; |
| 5257 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5258 | setverdict(pass); |
| 5259 | |
| 5260 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5261 | } |
| 5262 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5263 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5264 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5265 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5266 | var L1ctlDlMessage l1_dl; |
| 5267 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5268 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5269 | timer T := 5.0; |
| 5270 | T.start; |
| 5271 | alt { |
| 5272 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5273 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 5274 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5275 | repeat; |
| 5276 | } |
| 5277 | } |
| 5278 | [] pt.receive { |
| 5279 | repeat; |
| 5280 | } |
| 5281 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5282 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5283 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5284 | } |
| 5285 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5286 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5287 | } |
| 5288 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5289 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5290 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5291 | runs on test_CT return boolean { |
| 5292 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5293 | |
| 5294 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5295 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5296 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5297 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5298 | } |
| 5299 | |
| 5300 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5301 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5302 | } |
| 5303 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5304 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5305 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5306 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5307 | /* don't call f_init() as this would connect PCU socket */ |
| 5308 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5309 | |
| 5310 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5311 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5312 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5313 | |
| 5314 | f_init_l1ctl(); |
| 5315 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5316 | f_sleep(2.0); |
| 5317 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5318 | |
| 5319 | if (f_si_has_gprs_indicator(si_type)) { |
| 5320 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5321 | } else { |
| 5322 | setverdict(pass); |
| 5323 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5324 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5325 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5326 | } |
| 5327 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5328 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5329 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5330 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5331 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5332 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5333 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5334 | } |
| 5335 | |
| 5336 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5337 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5338 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5339 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5340 | f_init(); |
| 5341 | f_init_l1ctl(); |
| 5342 | f_l1_tune(L1CTL); |
| 5343 | |
| 5344 | f_sleep(2.0); |
| 5345 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5346 | |
| 5347 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5348 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5349 | } else { |
| 5350 | setverdict(pass); |
| 5351 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5352 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5353 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5354 | } |
| 5355 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5356 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5357 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5358 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5359 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5360 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5361 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5362 | } |
| 5363 | |
| 5364 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5365 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5366 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5367 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5368 | f_init(); |
| 5369 | f_init_l1ctl(); |
| 5370 | f_l1_tune(L1CTL); |
| 5371 | |
| 5372 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5373 | g_pcu_conn_id := -1; |
| 5374 | |
| 5375 | f_sleep(1.0); |
| 5376 | |
| 5377 | /* re-connect */ |
| 5378 | PCU.clear; |
| 5379 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5380 | |
| 5381 | f_sleep(2.0); |
| 5382 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5383 | |
| 5384 | if (f_si_has_gprs_indicator(si_type)) { |
| 5385 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5386 | } else { |
| 5387 | setverdict(pass); |
| 5388 | } |
| 5389 | |
| 5390 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5391 | } |
| 5392 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5393 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5394 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5395 | } |
| 5396 | |
| 5397 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5398 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5399 | } |
| 5400 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5401 | /* 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) */ |
| 5402 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5403 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5404 | |
| 5405 | f_init(); |
| 5406 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 5407 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 5408 | * information */ |
| 5409 | timer T := 2.0; |
| 5410 | T.start; |
| 5411 | alt { |
| 5412 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 5413 | [] T.timeout {} |
| 5414 | } |
| 5415 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5416 | /* Verify cell_id */ |
| 5417 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5418 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5419 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5420 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5421 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5422 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5423 | } |
| 5424 | |
| 5425 | /* Verify LAC */ |
| 5426 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5427 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5428 | if (lac_si3 != lac_pcu) { |
| 5429 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5430 | } |
| 5431 | |
| 5432 | setverdict(pass); |
| 5433 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5434 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5435 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 5436 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 5437 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5438 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5439 | |
| 5440 | f_init(); |
| 5441 | |
| 5442 | info_ind := g_pcu_last_info.u.info_ind; |
| 5443 | |
| 5444 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 5445 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
| 5446 | if (info_ind.trx.v10[i].pdch_mask[tn] != '1'B) { |
| 5447 | /* Skip inactive timeslots */ |
| 5448 | continue; |
| 5449 | } |
| 5450 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5451 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 5452 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5453 | else |
| 5454 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5455 | |
| 5456 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5457 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5458 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5459 | hsn := fhp.maio_hsn.hsn, |
| 5460 | maio := fhp.maio_hsn.maio, |
| 5461 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 5462 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5463 | } else { |
| 5464 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 5465 | } |
| 5466 | |
| 5467 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[i].ts[tn]; |
| 5468 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 5469 | if (not match(ts, tr_ts)) { |
| 5470 | setverdict(fail, "Hopping parameters do not match: ", |
| 5471 | "received ", ts, " vs expected ", tr_ts); |
| 5472 | } else { |
| 5473 | setverdict(pass); |
| 5474 | } |
| 5475 | } |
| 5476 | } |
| 5477 | } |
| 5478 | |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5479 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5480 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 5481 | f_init_vty_bsc(); |
| 5482 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5483 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 5484 | |
| 5485 | f_init(); |
| 5486 | |
| 5487 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5488 | if (not ischosen(remote_addr.v10)) { |
| 5489 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5490 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5491 | } |
| 5492 | |
| 5493 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV4) { |
| 5494 | setverdict(fail, "Received address family is not IPv4"); |
| 5495 | } |
| 5496 | |
| 5497 | if (substr(remote_addr.v10.addr[0], 0, 4) != f_inet_addr("127.127.127.127")) { |
| 5498 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5499 | } |
| 5500 | |
| 5501 | setverdict(pass); |
| 5502 | } |
| 5503 | |
| 5504 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5505 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 5506 | f_init_vty_bsc(); |
| 5507 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 5508 | |
| 5509 | f_init(); |
| 5510 | |
| 5511 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5512 | if (not ischosen(remote_addr.v10)) { |
| 5513 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5514 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5515 | } |
| 5516 | |
| 5517 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV6) { |
| 5518 | setverdict(fail, "Received address family is not IPv6"); |
| 5519 | } |
| 5520 | |
| 5521 | if (remote_addr.v10.addr[0] != f_inet6_addr("fd00::ca:ff:ee")) { |
| 5522 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5523 | } |
| 5524 | |
| 5525 | setverdict(pass); |
| 5526 | } |
| 5527 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5528 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5529 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5530 | ***********************************************************************/ |
| 5531 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5532 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 5533 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5534 | runs on ConnHdlr { |
| 5535 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5536 | |
| 5537 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
Vadim Yanitskiy | 9e1206c | 2020-07-19 15:52:31 +0700 | [diff] [blame] | 5538 | var bitstring pdch_mask := f_PCUIF_ver_INFO_PDCHMask(sd.data.u.info_ind, trx_nr); |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5539 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 5540 | repeat; |
| 5541 | } |
| 5542 | } |
| 5543 | } |
| 5544 | |
| 5545 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5546 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5547 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5548 | PCU.clear; |
| 5549 | f_rsl_chan_act(g_pars.chan_mode); |
| 5550 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5551 | timer T_wait := 2.0; |
| 5552 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5553 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5554 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5555 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5556 | [] T_wait.timeout { |
| 5557 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5558 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5559 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5560 | } |
| 5561 | /* try to activate this PDCH from the PCU point of view */ |
| 5562 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5563 | /* FIXME: is there a response? */ |
| 5564 | } |
| 5565 | |
| 5566 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5567 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5568 | /* Send RSL CHAN REL (deactivate) */ |
| 5569 | PCU.clear; |
| 5570 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5571 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5572 | timer T_wait := 2.0; |
| 5573 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5574 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5575 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5576 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5577 | [] T_wait.timeout { |
| 5578 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5579 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5580 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5581 | } |
| 5582 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5583 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5584 | alt { |
| 5585 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5586 | setverdict(pass); |
| 5587 | } |
| 5588 | [] RSL.receive { repeat; } |
| 5589 | } |
| 5590 | } |
| 5591 | |
| 5592 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5593 | 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] | 5594 | var PCUIF_Message first_info; |
| 5595 | var integer ts_nr := g_chan_nr.tn; |
| 5596 | var integer trx_nr := 0; |
| 5597 | var integer bts_nr := 0; |
| 5598 | var integer pcu_conn_id := -1; |
| 5599 | |
| 5600 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5601 | |
| 5602 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5603 | f_sleep(3.0); |
| 5604 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5605 | setverdict(pass); |
| 5606 | } |
| 5607 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5608 | var ConnHdlrPars pars; |
| 5609 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5610 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5611 | |
| 5612 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5613 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5614 | vc_conn.done; |
| 5615 | } |
| 5616 | |
| 5617 | /* 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] | 5618 | 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] | 5619 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5620 | var integer pcu_conn_id := -1; |
| 5621 | |
| 5622 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5623 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5624 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5625 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5626 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5627 | setverdict(pass); |
| 5628 | } |
| 5629 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5630 | var ConnHdlrPars pars; |
| 5631 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5632 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5633 | |
| 5634 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5635 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5636 | vc_conn.done; |
| 5637 | } |
| 5638 | |
| 5639 | /* 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] | 5640 | 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] | 5641 | var PCUIF_Message first_info; |
| 5642 | var integer ts_nr := g_chan_nr.tn; |
| 5643 | var integer trx_nr := 0; |
| 5644 | var integer bts_nr := 0; |
| 5645 | var integer pcu_conn_id := -1; |
| 5646 | |
| 5647 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5648 | |
| 5649 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5650 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5651 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5652 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5653 | setverdict(pass); |
| 5654 | } |
| 5655 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5656 | var ConnHdlrPars pars; |
| 5657 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5658 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5659 | |
| 5660 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5661 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5662 | vc_conn.done; |
| 5663 | } |
| 5664 | |
| 5665 | /* 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] | 5666 | 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] | 5667 | var PCUIF_Message first_info; |
| 5668 | var integer ts_nr := g_chan_nr.tn; |
| 5669 | var integer trx_nr := 0; |
| 5670 | var integer bts_nr := 0; |
| 5671 | var integer pcu_conn_id := -1; |
| 5672 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5673 | |
| 5674 | /* register for the TCH/F channel number */ |
| 5675 | f_rslem_register(0, chan_nr); |
| 5676 | |
| 5677 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5678 | |
| 5679 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5680 | "RSL CHAN ACT"); |
| 5681 | setverdict(pass); |
| 5682 | } |
| 5683 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5684 | var ConnHdlrPars pars; |
| 5685 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5686 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5687 | |
| 5688 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5689 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5690 | vc_conn.done; |
| 5691 | } |
| 5692 | |
| 5693 | /* 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] | 5694 | 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] | 5695 | var PCUIF_Message first_info; |
| 5696 | var integer ts_nr := g_chan_nr.tn; |
| 5697 | var integer trx_nr := 0; |
| 5698 | var integer bts_nr := 0; |
| 5699 | var integer pcu_conn_id := -1; |
| 5700 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5701 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5702 | |
| 5703 | /* register for the TCH/H channel numbers */ |
| 5704 | f_rslem_register(0, chan_nr[0]); |
| 5705 | f_rslem_register(0, chan_nr[1]); |
| 5706 | |
| 5707 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5708 | |
| 5709 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5710 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5711 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5712 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5713 | setverdict(pass); |
| 5714 | } |
| 5715 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5716 | var ConnHdlrPars pars; |
| 5717 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5718 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5719 | |
| 5720 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5721 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5722 | vc_conn.done; |
| 5723 | } |
| 5724 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5725 | /*********************************************************************** |
| 5726 | * IPA Style Dynamic Timeslot Support |
| 5727 | ***********************************************************************/ |
| 5728 | |
| 5729 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5730 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5731 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5732 | PCU.clear; |
| 5733 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5734 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5735 | timer T_wait := 2.0; |
| 5736 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5737 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5738 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5739 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5740 | [] T_wait.timeout { |
| 5741 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5742 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5743 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5744 | } |
| 5745 | /* try to activate this PDCH from the PCU point of view */ |
| 5746 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5747 | /* FIXME: is there a response? */ |
| 5748 | |
| 5749 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5750 | } |
| 5751 | |
| 5752 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5753 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5754 | /* Send RSL CHAN REL (deactivate) */ |
| 5755 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5756 | PCU.clear; |
| 5757 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5758 | timer T_wait := 2.0; |
| 5759 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5760 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5761 | [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5762 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5763 | [] T_wait.timeout { |
| 5764 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5765 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5766 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5767 | } |
| 5768 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5769 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5770 | alt { |
| 5771 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5772 | setverdict(pass); |
| 5773 | } |
| 5774 | [] RSL.receive { repeat; } |
| 5775 | } |
| 5776 | } |
| 5777 | |
| 5778 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5779 | 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] | 5780 | var PCUIF_Message first_info; |
| 5781 | var integer ts_nr := g_chan_nr.tn; |
| 5782 | var integer trx_nr := 0; |
| 5783 | var integer bts_nr := 0; |
| 5784 | var integer pcu_conn_id := -1; |
| 5785 | |
| 5786 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5787 | |
| 5788 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5789 | f_sleep(3.0); |
| 5790 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5791 | |
| 5792 | setverdict(pass); |
| 5793 | |
| 5794 | } |
| 5795 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5796 | var ConnHdlrPars pars; |
| 5797 | var ConnHdlr vc_conn; |
| 5798 | f_init(); |
| 5799 | |
| 5800 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5801 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5802 | vc_conn.done; |
| 5803 | } |
| 5804 | |
| 5805 | /* 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] | 5806 | 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] | 5807 | var PCUIF_Message first_info; |
| 5808 | var integer ts_nr := g_chan_nr.tn; |
| 5809 | var integer trx_nr := 0; |
| 5810 | var integer bts_nr := 0; |
| 5811 | var integer pcu_conn_id := -1; |
| 5812 | |
| 5813 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5814 | |
| 5815 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5816 | "RSL CHAN ACT"); |
| 5817 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5818 | "RF CHAN REL", true); |
| 5819 | setverdict(pass); |
| 5820 | } |
| 5821 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5822 | var ConnHdlrPars pars; |
| 5823 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5824 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5825 | |
| 5826 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5827 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5828 | vc_conn.done; |
| 5829 | } |
| 5830 | |
| 5831 | /* 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] | 5832 | 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] | 5833 | var PCUIF_Message first_info; |
| 5834 | var integer ts_nr := g_chan_nr.tn; |
| 5835 | var integer trx_nr := 0; |
| 5836 | var integer bts_nr := 0; |
| 5837 | var integer pcu_conn_id := -1; |
| 5838 | |
| 5839 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5840 | |
| 5841 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5842 | "RSL CHAN ACT"); |
| 5843 | |
| 5844 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5845 | alt { |
| 5846 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5847 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5848 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5849 | } |
| 5850 | [] RSL.receive { repeat; } |
| 5851 | } |
| 5852 | |
| 5853 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5854 | "RF CHAN REL", true); |
| 5855 | setverdict(pass); |
| 5856 | } |
| 5857 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5858 | var ConnHdlrPars pars; |
| 5859 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5860 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5861 | |
| 5862 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5863 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5864 | vc_conn.done; |
| 5865 | } |
| 5866 | |
| 5867 | /* 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] | 5868 | 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] | 5869 | var PCUIF_Message first_info; |
| 5870 | var integer ts_nr := g_chan_nr.tn; |
| 5871 | var integer trx_nr := 0; |
| 5872 | var integer bts_nr := 0; |
| 5873 | var integer pcu_conn_id := -1; |
| 5874 | |
| 5875 | /* register for the TCH/F channel number */ |
| 5876 | f_rslem_register(0, g_chan_nr); |
| 5877 | |
| 5878 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5879 | |
| 5880 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5881 | |
| 5882 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5883 | "RSL CHAN ACT"); |
| 5884 | |
| 5885 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5886 | |
| 5887 | setverdict(pass); |
| 5888 | } |
| 5889 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 5890 | var ConnHdlrPars pars; |
| 5891 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5892 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5893 | |
| 5894 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5895 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 5896 | vc_conn.done; |
| 5897 | } |
| 5898 | |
| 5899 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5900 | /*********************************************************************** |
| 5901 | * LAPDm / RLL related |
| 5902 | ***********************************************************************/ |
| 5903 | |
| 5904 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 5905 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 5906 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5907 | var template (value) SacchL1Header l1h; |
| 5908 | |
| 5909 | /* 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] | 5910 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5911 | /* Compose dummy L1 header */ |
| 5912 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 5913 | 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] | 5914 | } else { |
| 5915 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5916 | 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] | 5917 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5918 | } |
| 5919 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 5920 | private type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5921 | uint3_t sapi, |
| 5922 | RslLinkId link_id, |
| 5923 | octetstring l3, |
| 5924 | boolean exp |
| 5925 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 5926 | private type record of RllTestCase RllTestCases; |
| 5927 | private template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, |
| 5928 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5929 | sapi := sapi, |
| 5930 | link_id := id, |
| 5931 | l3 := l3, |
| 5932 | exp := exp |
| 5933 | } |
| 5934 | |
| 5935 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 5936 | * variety of logical channels */ |
| 5937 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 5938 | var ConnHdlrPars pars; |
| 5939 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5940 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5941 | |
| 5942 | /* test on each of the channels we have */ |
| 5943 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 5944 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 5945 | |
| 5946 | /* test each of the test cases on the current channel */ |
| 5947 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 5948 | pars.spec.rll := tcs[j]; |
| 5949 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 5950 | vc_conn := f_start_handler(fn, pars); |
| 5951 | vc_conn.done; |
| 5952 | } |
| 5953 | } |
| 5954 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5955 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5956 | } |
| 5957 | |
| 5958 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 5959 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 5960 | var RllTestCase tc := g_pars.spec.rll; |
| 5961 | timer T := 3.0; |
| 5962 | |
| 5963 | f_l1_tune(L1CTL); |
| 5964 | RSL.clear; |
| 5965 | |
| 5966 | /* activate the logical channel */ |
| 5967 | f_est_dchan(); |
| 5968 | L1CTL.clear; |
| 5969 | |
| 5970 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 5971 | T.start; |
| 5972 | alt { |
| 5973 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5974 | if (tc.exp) { |
| 5975 | setverdict(pass); |
| 5976 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5977 | 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] | 5978 | } |
| 5979 | } |
| 5980 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 5981 | if (tc.exp) { |
| 5982 | setverdict(pass); |
| 5983 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5984 | 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] | 5985 | } |
| 5986 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5987 | /* We also expect to receive the measurements */ |
| 5988 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5989 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5990 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5991 | } |
| 5992 | [not tc.exp] T.timeout { |
| 5993 | setverdict(pass); |
| 5994 | } |
| 5995 | } |
| 5996 | |
| 5997 | f_rsl_chan_deact(); |
| 5998 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5999 | f_rslem_unregister(0, g_chan_nr); |
| 6000 | } |
| 6001 | testcase TC_rll_est_ind() runs on test_CT { |
| 6002 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6003 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6004 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6005 | /* normal SAPI0 establishment */ |
| 6006 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6007 | /* SAPI 3 doesn't support contention resolution */ |
| 6008 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 6009 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 6010 | /* normal SAPI3 establishment on main DCCH */ |
| 6011 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6012 | /* normal SAPI3 establishment on SACCH */ |
| 6013 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6014 | }; |
| 6015 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6016 | } |
| 6017 | |
| 6018 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6019 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6020 | var RllTestCase tc := g_pars.spec.rll; |
| 6021 | var L1ctlDlMessage dl; |
| 6022 | timer T := 3.0; |
| 6023 | |
| 6024 | f_l1_tune(L1CTL); |
| 6025 | RSL.clear; |
| 6026 | |
| 6027 | /* activate the logical channel */ |
| 6028 | f_est_dchan(); |
| 6029 | L1CTL.clear; |
| 6030 | |
| 6031 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6032 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 6033 | T.start; |
| 6034 | alt { |
| 6035 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6036 | var LapdmFrame lapdm; |
| 6037 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6038 | if (dl.dl_info.link_id.c == SACCH) { |
| 6039 | /* remove L1 header */ |
| 6040 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6041 | } |
| 6042 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6043 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 6044 | setverdict(pass); |
| 6045 | } else { |
| 6046 | repeat; |
| 6047 | } |
| 6048 | } |
| 6049 | [] L1CTL.receive { repeat; } |
| 6050 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6051 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6052 | } |
| 6053 | } |
| 6054 | |
| 6055 | f_rsl_chan_deact(); |
| 6056 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6057 | f_rslem_unregister(0, g_chan_nr); |
| 6058 | } |
| 6059 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 6060 | var RllTestCases tcs := { |
| 6061 | /* normal SAPI3 establishment on main DCCH */ |
| 6062 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 6063 | }; |
| 6064 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6065 | } |
| 6066 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 6067 | var RllTestCases tcs := { |
| 6068 | /* normal SAPI3 establishment on SACCH */ |
| 6069 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6070 | } |
| 6071 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6072 | } |
| 6073 | |
| 6074 | /* altstep to receive a LAPDm frame matching the given template */ |
| 6075 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 6076 | var L1ctlDlMessage dl; |
| 6077 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6078 | var LapdmFrame lapdm; |
| 6079 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6080 | if (dl.dl_info.link_id.c == SACCH) { |
| 6081 | /* remove L1 header */ |
| 6082 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6083 | } |
| 6084 | if (ischosen(exp.ab)) { |
| 6085 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6086 | } else if (ischosen(exp.b4)) { |
| 6087 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 6088 | } else if (ischosen(exp.bbis)) { |
| 6089 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 6090 | } |
| 6091 | log("Rx LAPDm ", lapdm); |
| 6092 | if (match(lapdm, exp)) { |
| 6093 | setverdict(pass); |
| 6094 | } else { |
| 6095 | repeat; |
| 6096 | } |
| 6097 | } |
| 6098 | [] L1CTL.receive { repeat; } |
| 6099 | } |
| 6100 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 6101 | timer T := t; |
| 6102 | T.start; |
| 6103 | alt { |
| 6104 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6105 | 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] | 6106 | } |
| 6107 | [] as_l1_exp_lapdm(exp); |
| 6108 | } |
| 6109 | } |
| 6110 | |
| 6111 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 6112 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 6113 | /* send SABM from MS -> BTS */ |
| 6114 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 6115 | /* expect RLL EST IND on Abis */ |
| 6116 | alt { |
| 6117 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 6118 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 6119 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6120 | 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] | 6121 | } |
| 6122 | [] RSL.receive { repeat; } |
| 6123 | } |
| 6124 | /* expect UA from BTS -> MS */ |
| 6125 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 6126 | } |
| 6127 | |
| 6128 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 6129 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 6130 | var RllTestCase tc := g_pars.spec.rll; |
| 6131 | |
| 6132 | f_l1_tune(L1CTL); |
| 6133 | RSL.clear; |
| 6134 | |
| 6135 | /* activate the logical channel */ |
| 6136 | f_est_dchan(); |
| 6137 | L1CTL.clear; |
| 6138 | |
| 6139 | /* first establish the link-layer */ |
| 6140 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6141 | |
| 6142 | /* then send the DISC */ |
| 6143 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 6144 | /* ... and expect the REL IND on the RSL side */ |
| 6145 | alt { |
| 6146 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 6147 | setverdict(pass); |
| 6148 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6149 | /* We also expect to receive the measurements */ |
| 6150 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6151 | } |
| 6152 | |
| 6153 | /* release the channel */ |
| 6154 | f_rsl_chan_deact(); |
| 6155 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6156 | f_rslem_unregister(0, g_chan_nr); |
| 6157 | } |
| 6158 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6159 | var RllTestCases tcs := { |
| 6160 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 6161 | }; |
| 6162 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6163 | } |
| 6164 | |
| 6165 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6166 | var RllTestCases tcs := { |
| 6167 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 6168 | }; |
| 6169 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6170 | } |
| 6171 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6172 | var RllTestCases tcs := { |
| 6173 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 6174 | }; |
| 6175 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6176 | } |
| 6177 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6178 | var RllTestCases tcs := { |
| 6179 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6180 | }; |
| 6181 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6182 | } |
| 6183 | |
| 6184 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6185 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6186 | var RllTestCase tc := g_pars.spec.rll; |
| 6187 | f_l1_tune(L1CTL); |
| 6188 | RSL.clear; |
| 6189 | |
| 6190 | /* activate the logical channel */ |
| 6191 | f_est_dchan(); |
| 6192 | L1CTL.clear; |
| 6193 | |
| 6194 | /* first establish the link-layer */ |
| 6195 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6196 | |
| 6197 | /* then send the REL REQ via RSL */ |
| 6198 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6199 | /* ... and expect the DISC on the Um side */ |
| 6200 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6201 | [] 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] | 6202 | /* FIXME: send a UA in resposne to the DISC */ |
| 6203 | } |
| 6204 | } |
| 6205 | |
| 6206 | /* release the channel */ |
| 6207 | f_rsl_chan_deact(); |
| 6208 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6209 | f_rslem_unregister(0, g_chan_nr); |
| 6210 | } |
| 6211 | testcase TC_rll_rel_req() runs on test_CT { |
| 6212 | var RllTestCases tcs := { |
| 6213 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 6214 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 6215 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6216 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6217 | }; |
| 6218 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6219 | } |
| 6220 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6221 | /* 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] | 6222 | testcase TC_rll_data_req() runs on test_CT { |
| 6223 | } |
| 6224 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6225 | /* 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] | 6226 | testcase TC_rll_data_ind() runs on test_CT { |
| 6227 | } |
| 6228 | |
| 6229 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6230 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6231 | var RllTestCase tc := g_pars.spec.rll; |
| 6232 | |
| 6233 | f_l1_tune(L1CTL); |
| 6234 | RSL.clear; |
| 6235 | |
| 6236 | f_est_dchan(); |
| 6237 | L1CTL.clear; |
| 6238 | |
| 6239 | /* Send UNITDATA REQ on RSL side */ |
| 6240 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6241 | /* Expect it to arrive on the other side */ |
| 6242 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6243 | 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] | 6244 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6245 | 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] | 6246 | } |
| 6247 | |
| 6248 | /* release the channel */ |
| 6249 | f_rsl_chan_deact(); |
| 6250 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6251 | f_rslem_unregister(0, g_chan_nr); |
| 6252 | } |
| 6253 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6254 | var octetstring l3 := f_rnd_octstring(15); |
| 6255 | var RllTestCases tcs := { |
| 6256 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6257 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6258 | }; |
| 6259 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6260 | } |
| 6261 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6262 | var octetstring l3 := f_rnd_octstring(19); |
| 6263 | var RllTestCases tcs := { |
| 6264 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6265 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6266 | }; |
| 6267 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6268 | } |
| 6269 | |
| 6270 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6271 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6272 | var RllTestCase tc := g_pars.spec.rll; |
| 6273 | |
| 6274 | f_l1_tune(L1CTL); |
| 6275 | RSL.clear; |
| 6276 | |
| 6277 | f_est_dchan(); |
| 6278 | L1CTL.clear; |
| 6279 | |
| 6280 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6281 | 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] | 6282 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6283 | alt { |
| 6284 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6285 | setverdict(pass); |
| 6286 | } |
| 6287 | [] RSL.receive { repeat; } |
| 6288 | } |
| 6289 | |
| 6290 | /* release the channel */ |
| 6291 | f_rsl_chan_deact(); |
| 6292 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6293 | f_rslem_unregister(0, g_chan_nr); |
| 6294 | } |
| 6295 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6296 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6297 | var RllTestCases tcs := { |
| 6298 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6299 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6300 | }; |
| 6301 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6302 | } |
| 6303 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6304 | var octetstring l3 := f_rnd_octstring(18); |
| 6305 | var RllTestCases tcs := { |
| 6306 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6307 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6308 | }; |
| 6309 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6310 | } |
| 6311 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6312 | /*********************************************************************** |
| 6313 | * Encryption Related |
| 6314 | ***********************************************************************/ |
| 6315 | |
| 6316 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6317 | 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] | 6318 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6319 | if (link_id.c == SACCH) { |
| 6320 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6321 | } else { |
| 6322 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6323 | } |
| 6324 | } |
| 6325 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6326 | /* Expect (or not expect) other kinds of messages */ |
| 6327 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6328 | [exp_any] RSL.receive { repeat; } |
| 6329 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6330 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6331 | } |
| 6332 | } |
| 6333 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6334 | /* 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] | 6335 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6336 | RslLinkId link_id, |
| 6337 | octetstring l3, |
| 6338 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6339 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6340 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6341 | timer T := 3.0; |
| 6342 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6343 | T.start; |
| 6344 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6345 | alt { |
| 6346 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6347 | setverdict(pass); |
| 6348 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6349 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6350 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6351 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6352 | 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] | 6353 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6354 | } |
| 6355 | } |
| 6356 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6357 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6358 | private function f_data_mo( |
| 6359 | RslLinkId link_id, |
| 6360 | boolean p, uint3_t nr, uint3_t ns, |
| 6361 | octetstring l3, |
| 6362 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6363 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6364 | ) runs on ConnHdlr { |
| 6365 | timer T := 3.0; |
| 6366 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6367 | T.start; |
| 6368 | /* Expect RLL DATA IND on RSL side */ |
| 6369 | alt { |
| 6370 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6371 | setverdict(pass); |
| 6372 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6373 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6374 | [] as_rsl_any_ind(exp_any); |
| 6375 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6376 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6377 | } |
| 6378 | } |
| 6379 | } |
| 6380 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6381 | /* 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] | 6382 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6383 | f_l1_tune(L1CTL); |
| 6384 | f_est_dchan(true); |
| 6385 | |
| 6386 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6387 | var L1ctlDlMessage dl; |
| 6388 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6389 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6390 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6391 | |
| 6392 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6393 | f_unitdata_mt(link_id, l3); |
| 6394 | |
| 6395 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6396 | f_unitdata_mo(link_id, l3); |
| 6397 | |
| 6398 | /* release the channel */ |
| 6399 | f_rsl_chan_deact(); |
| 6400 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6401 | f_rslem_unregister(0, g_chan_nr); |
| 6402 | } |
| 6403 | testcase TC_chan_act_a51() runs on test_CT { |
| 6404 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6405 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6406 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6407 | } |
| 6408 | testcase TC_chan_act_a52() runs on test_CT { |
| 6409 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6410 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6411 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6412 | } |
| 6413 | testcase TC_chan_act_a53() runs on test_CT { |
| 6414 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6415 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6416 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6417 | } |
| 6418 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6419 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6420 | 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] | 6421 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6422 | f_l1_tune(L1CTL); |
| 6423 | f_est_dchan(true); |
| 6424 | |
| 6425 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6426 | var L1ctlDlMessage dl; |
| 6427 | |
| 6428 | var octetstring l3 := f_rnd_octstring(20); |
| 6429 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6430 | |
| 6431 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6432 | f_unitdata_mt(link_id, l3); |
| 6433 | |
| 6434 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6435 | f_unitdata_mo(link_id, l3); |
| 6436 | |
| 6437 | var RSL_Message rsl; |
| 6438 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false)))); |
| 6439 | |
| 6440 | /* modify key to break proper encryption */ |
| 6441 | g_pars.encr.key := f_rnd_octstring(8); |
| 6442 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6443 | rsl.ies := rsl.ies & { ei }; |
| 6444 | RSL.send(rsl); |
| 6445 | |
| 6446 | timer T0 := 1.0; |
| 6447 | T0.start; |
| 6448 | /* Expect RSL MODIFY ACK */ |
| 6449 | alt { |
| 6450 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6451 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6452 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6453 | } |
| 6454 | [] T0.timeout { |
| 6455 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6456 | } |
| 6457 | } |
| 6458 | |
| 6459 | var octetstring l3msg := f_rnd_octstring(15); |
| 6460 | timer T1 := 3.0; |
| 6461 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6462 | due to broken encryption */ |
| 6463 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6464 | T1.start; |
| 6465 | alt { |
| 6466 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6467 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6468 | } |
| 6469 | [] T1.timeout { |
| 6470 | setverdict(pass); |
| 6471 | } |
| 6472 | } |
| 6473 | |
| 6474 | /* release the channel */ |
| 6475 | f_rsl_chan_deact(); |
| 6476 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6477 | f_rslem_unregister(0, g_chan_nr); |
| 6478 | } |
| 6479 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6480 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6481 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6482 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6483 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6484 | |
| 6485 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6486 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6487 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6488 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6489 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6490 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6491 | |
| 6492 | f_l1_tune(L1CTL); |
| 6493 | |
| 6494 | /* first establish a dedicated channel in the clear */ |
| 6495 | f_est_dchan(false); |
| 6496 | |
| 6497 | /* Establish ABM */ |
| 6498 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6499 | |
| 6500 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6501 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6502 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6503 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6504 | |
| 6505 | /* configure L1 to apply ciphering */ |
| 6506 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6507 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6508 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6509 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6510 | 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] | 6511 | |
| 6512 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6513 | * and hence enable encryption also on the downlink */ |
| 6514 | |
| 6515 | /* expect bi-directional communication work in encrypted mode */ |
| 6516 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6517 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6518 | |
| 6519 | /* release the channel */ |
| 6520 | f_rsl_chan_deact(); |
| 6521 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6522 | f_rslem_unregister(0, g_chan_nr); |
| 6523 | } |
| 6524 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6525 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6526 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6527 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6528 | } |
| 6529 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6530 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6531 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6532 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6533 | } |
| 6534 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6535 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6536 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6537 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6538 | } |
| 6539 | |
| 6540 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6541 | var LapdmFrame lf; |
| 6542 | var octetstring reenc; |
| 6543 | |
| 6544 | /* decode the LAPDm frame */ |
| 6545 | if (ischosen(exp_match.ab)) { |
| 6546 | lf.ab := dec_LapdmFrameAB(enc); |
| 6547 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6548 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6549 | } |
| 6550 | |
| 6551 | /* check if decoder result matches expectation */ |
| 6552 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6553 | 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] | 6554 | } else { |
| 6555 | log(name, ": matched"); |
| 6556 | setverdict(pass); |
| 6557 | } |
| 6558 | |
| 6559 | /* test if re-encoded frame equals original input */ |
| 6560 | reenc := enc_LapdmFrame(lf); |
| 6561 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6562 | 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] | 6563 | } else { |
| 6564 | setverdict(pass); |
| 6565 | } |
| 6566 | } |
| 6567 | |
| 6568 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6569 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6570 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6571 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6572 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6573 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6574 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6575 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6576 | } |
| 6577 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6578 | /*********************************************************************** |
| 6579 | * DTX Related (see GSM 05.08, section 8.3) |
| 6580 | ***********************************************************************/ |
| 6581 | |
| 6582 | /* 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] | 6583 | private function f_g_chan_is_tchf() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6584 | return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or |
| 6585 | g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or |
| 6586 | g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or |
| 6587 | g_chan_nr == valueof(ts_RslChanNr_Bm(4))); |
| 6588 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6589 | private function f_g_chan_is_tchh() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6590 | return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or |
| 6591 | g_chan_nr == valueof(ts_RslChanNr_Lm(5,1))); |
| 6592 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6593 | private function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6594 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or |
| 6595 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or |
| 6596 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or |
| 6597 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3))); |
| 6598 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6599 | private function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6600 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or |
| 6601 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or |
| 6602 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or |
| 6603 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or |
| 6604 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or |
| 6605 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or |
| 6606 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or |
| 6607 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7))); |
| 6608 | } |
| 6609 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6610 | private function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6611 | var L1ctlDlMessage dl; |
| 6612 | var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 6613 | var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2); |
| 6614 | var GsmFrameNumber first_fn; |
| 6615 | var boolean is_first_frame := true; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6616 | var integer nfill_frames_sacch := 0; |
| 6617 | var integer nfill_frames_nonsacch := 0; |
| 6618 | 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] | 6619 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6620 | 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] | 6621 | const integer frame_dtx_tchf_mod := 104; |
| 6622 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6623 | * which operates in terms of blocks rather than frames. */ |
| 6624 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6625 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6626 | timer T := 5.0; |
| 6627 | |
| 6628 | f_l1_tune(L1CTL); |
| 6629 | RSL.clear; |
| 6630 | L1CTL.clear; |
| 6631 | |
| 6632 | /* activate TCHF signalling channel */ |
| 6633 | f_est_dchan(false); |
| 6634 | |
| 6635 | T.start; |
| 6636 | alt { |
| 6637 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6638 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
| 6639 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6640 | |
| 6641 | if (is_first_frame) { |
| 6642 | is_first_frame := false; |
| 6643 | first_fn := dl.dl_info.frame_nr; |
| 6644 | } |
| 6645 | |
| 6646 | if (dl.dl_info.link_id.c == SACCH) { |
| 6647 | l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */ |
| 6648 | if (not match(l2_fill_frame_sacch, l2)) { |
| 6649 | repeat; |
| 6650 | } |
| 6651 | } else if (not match(l2_fill_frame, l2)) { |
| 6652 | repeat; |
| 6653 | } |
| 6654 | |
| 6655 | if (dtxd) { |
| 6656 | if (not f_g_chan_is_tchf()) { |
| 6657 | T.stop; |
| 6658 | f_rsl_chan_deact(); |
| 6659 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6660 | 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] | 6661 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6662 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6663 | T.stop; |
| 6664 | f_rsl_chan_deact(); |
| 6665 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6666 | |
| 6667 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. |
| 6668 | * 2 SACCH, 1 TCH/F */ |
| 6669 | expected_fill_frames := 3; |
| 6670 | |
| 6671 | if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) { |
| 6672 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6673 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6674 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6675 | } else { |
| 6676 | setverdict(pass); |
| 6677 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6678 | } else { |
| 6679 | if (dl.dl_info.link_id.c == SACCH) { |
| 6680 | nfill_frames_sacch := nfill_frames_sacch + 1; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6681 | repeat; |
| 6682 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6683 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6684 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6685 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6686 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6687 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6688 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
| 6689 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6690 | repeat; |
| 6691 | } |
| 6692 | } |
| 6693 | log("Received DTX TCH fill frame with bad frame number: ", fn, |
| 6694 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6695 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
| 6696 | f_rsl_chan_deact(); |
| 6697 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6698 | 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] | 6699 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6700 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6701 | if (dl.dl_info.link_id.c == SACCH) { |
| 6702 | nfill_frames_sacch := nfill_frames_sacch + 1; |
| 6703 | } else { |
| 6704 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6705 | } |
| 6706 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6707 | T.stop; |
| 6708 | if (f_g_chan_is_tchf()) { |
| 6709 | /* Without DTX we can expect 25 fill frames for every 104 frames. |
| 6710 | * (24 FACCH + 1 SACCH filling) */ |
| 6711 | expected_fill_frames := 25; |
| 6712 | } else if (f_g_chan_is_tchh()) { |
| 6713 | /* We can expect 2 fill frames for every 104 frames. */ |
| 6714 | expected_fill_frames := 2; |
| 6715 | } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) { |
| 6716 | /* We can expect 5 fill frames for every 104 frames. */ |
| 6717 | expected_fill_frames := 5; |
| 6718 | } else { |
| 6719 | f_rsl_chan_deact(); |
| 6720 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6721 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6722 | } |
| 6723 | |
| 6724 | f_rsl_chan_deact(); |
| 6725 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6726 | |
| 6727 | if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6728 | setverdict(pass); |
| 6729 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6730 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6731 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6732 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6733 | } |
| 6734 | } else { |
| 6735 | repeat; |
| 6736 | } |
| 6737 | } |
| 6738 | } |
| 6739 | [] L1CTL.receive { repeat; } |
| 6740 | [] T.timeout { |
| 6741 | f_rsl_chan_deact(); |
| 6742 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6743 | 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] | 6744 | } |
| 6745 | } |
| 6746 | } |
| 6747 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6748 | 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] | 6749 | f_test_l2_fill_frames(false); |
| 6750 | } |
| 6751 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6752 | 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] | 6753 | f_test_l2_fill_frames(true); |
| 6754 | } |
| 6755 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6756 | 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] | 6757 | var ConnHdlr vc_conn; |
| 6758 | var ConnHdlrPars pars; |
| 6759 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6760 | f_init(); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6761 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 6762 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd))); |
| 6763 | if (dtxd) { |
| 6764 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6765 | break; |
| 6766 | } |
| 6767 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6768 | } else { |
| 6769 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6770 | } |
| 6771 | vc_conn.done; |
| 6772 | } |
| 6773 | } |
| 6774 | |
| 6775 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6776 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6777 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6778 | f_tch_sign_l2_fill_frame(false); |
| 6779 | } |
| 6780 | |
| 6781 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6782 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6783 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6784 | f_tch_sign_l2_fill_frame(true); |
| 6785 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6786 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6787 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6788 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6789 | } |
| 6790 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6791 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6792 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6793 | } |
| 6794 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6795 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 6796 | /* protocol error as per 44.006 */ |
| 6797 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 6798 | /* repetition of SABM or DISC N200 times without ACK */ |
| 6799 | /* receptiom of SABM in multi-frame established state */ |
| 6800 | |
| 6801 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6802 | /* TODO Areas: |
| 6803 | |
| 6804 | * channel activation |
| 6805 | ** with BS_Power / MS_Power, bypassing power control loop |
| 6806 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6807 | ** with timing advance from initial activation on |
| 6808 | * mode modify |
| 6809 | ** encryption |
| 6810 | ** multirate |
| 6811 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6812 | ** unsupported algorithm |
| 6813 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6814 | * BS Power Control |
| 6815 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6816 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6817 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6818 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6819 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6820 | ** DATA_IND from BTS->PCU |
| 6821 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6822 | |
| 6823 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6824 | |
| 6825 | control { |
| 6826 | execute( TC_chan_act_stress() ); |
| 6827 | execute( TC_chan_act_react() ); |
| 6828 | execute( TC_chan_deact_not_active() ); |
| 6829 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 6830 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 6831 | execute( TC_sacch_filling() ); |
| 6832 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 6833 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 6834 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 6835 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 6836 | execute( TC_sacch_chan_act_ho_async() ); |
| 6837 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6838 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 6839 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6840 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 6841 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 6842 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 6843 | execute( TC_rach_load_idle_thresh0() ); |
| 6844 | execute( TC_rach_load_idle_below_thresh() ); |
| 6845 | execute( TC_rach_load_count() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6846 | execute( TC_meas_res_sign_tchf() ); |
| 6847 | execute( TC_meas_res_sign_tchh() ); |
| 6848 | execute( TC_meas_res_sign_sdcch4() ); |
| 6849 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 6850 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 6851 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 6852 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 6853 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 6854 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 6855 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 6856 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 6857 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 6858 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 6859 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 6860 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 6861 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 6862 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 6863 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 6864 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6865 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6866 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6867 | execute( TC_paging_imsi_80percent() ); |
| 6868 | execute( TC_paging_tmsi_80percent() ); |
| 6869 | execute( TC_paging_imsi_200percent() ); |
| 6870 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 6871 | execute( TC_rsl_protocol_error() ); |
| 6872 | execute( TC_rsl_mand_ie_error() ); |
| 6873 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6874 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 6875 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6876 | execute( TC_si_sched_2bis() ); |
| 6877 | execute( TC_si_sched_2ter() ); |
| 6878 | execute( TC_si_sched_2ter_2bis() ); |
| 6879 | execute( TC_si_sched_2quater() ); |
| 6880 | execute( TC_si_sched_13() ); |
| 6881 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 6882 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 6883 | execute( TC_ipa_crcx_twice_not_active() ); |
| 6884 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 6885 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 6886 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6887 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6888 | if (mp_pcu_socket != "") { |
| 6889 | execute( TC_pcu_act_req() ); |
| 6890 | execute( TC_pcu_act_req_wrong_ts() ); |
| 6891 | execute( TC_pcu_act_req_wrong_bts() ); |
| 6892 | execute( TC_pcu_act_req_wrong_trx() ); |
| 6893 | execute( TC_pcu_deact_req() ); |
| 6894 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 6895 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6896 | if (mp_l1_supports_gprs) { |
| 6897 | execute( TC_pcu_data_req_pdtch() ); |
| 6898 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 6899 | execute( TC_pcu_data_req_wrong_bts() ); |
| 6900 | execute( TC_pcu_data_req_wrong_trx() ); |
| 6901 | execute( TC_pcu_data_req_wrong_ts() ); |
| 6902 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6903 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 6904 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6905 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 6906 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6907 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 6908 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 6909 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 6910 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6911 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6912 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6913 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6914 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6915 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6916 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6917 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6918 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6919 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6920 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6921 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6922 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6923 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6924 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 6925 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 6926 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 6927 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 6928 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 6929 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6930 | if (PCUIF_Types.mp_pcuif_version >= 10) { |
| 6931 | execute( TC_pcu_info_ind_fh_params() ); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6932 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 6933 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6934 | } |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6935 | } else { |
| 6936 | log("PCU socket path not available, skipping PCU tests"); |
| 6937 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6938 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6939 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6940 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 6941 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6942 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 6943 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6944 | |
| 6945 | execute( TC_rll_est_ind() ); |
| 6946 | execute( TC_rll_est_req_DCCH_3() ); |
| 6947 | execute( TC_rll_est_req_ACCH_3() ); |
| 6948 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 6949 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 6950 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 6951 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 6952 | execute( TC_rll_rel_req() ); |
| 6953 | execute( TC_rll_unit_data_req_DCCH() ); |
| 6954 | execute( TC_rll_unit_data_req_ACCH() ); |
| 6955 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 6956 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6957 | |
| 6958 | execute( TC_chan_act_a51() ); |
| 6959 | execute( TC_chan_act_a52() ); |
| 6960 | execute( TC_chan_act_a53() ); |
| 6961 | execute( TC_encr_cmd_a51() ); |
| 6962 | execute( TC_encr_cmd_a52() ); |
| 6963 | execute( TC_encr_cmd_a53() ); |
| 6964 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 6965 | execute( TC_err_rep_wrong_mdisc() ); |
| 6966 | execute( TC_err_rep_wrong_msg_type() ); |
| 6967 | execute( TC_err_rep_wrong_sequence() ); |
| 6968 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6969 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6970 | |
| 6971 | execute( TC_tch_sign_l2_fill_frame() ); |
| 6972 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6973 | |
| 6974 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6975 | execute( TC_chopped_ipa_payload() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6976 | } |
| 6977 | |
| 6978 | |
| 6979 | } |