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; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 87 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 88 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 89 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 90 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 91 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 92 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 93 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 94 | integer mp_tolerance_rxqual := 1; |
| 95 | integer mp_tolerance_rxlev := 3; |
| 96 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 97 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 98 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 99 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 100 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 101 | 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] | 102 | integer mp_ms_actual_ta_exp := 0; |
| 103 | integer mp_timing_offset_256syms_exp := 512; |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 104 | integer mp_uplink_power_target := -75; |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 105 | integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */ |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 106 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 107 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 108 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 109 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 110 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 111 | /* how many transceivers do we expect to connect */ |
| 112 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 113 | /* frequency hopping status */ |
| 114 | boolean mp_freq_hop_enabled := false; |
| 115 | /* frequency hopping parameters */ |
| 116 | FreqHopConfig mp_fh_config; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 117 | /* configuration for each individual transceiver */ |
| 118 | TrxPars mp_trx_pars; /* see BTS_Tests.default */ |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 119 | /* default Training Sequence Code */ |
| 120 | GsmTsc mp_tsc_def := 7; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 121 | } |
| 122 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 123 | type record of RslChannelNr ChannelNrs; |
| 124 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 125 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 126 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 127 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 128 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 129 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 130 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 131 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 132 | |
| 133 | /* L1CTL port (for classic tests) */ |
| 134 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 135 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 136 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 137 | port TRXC_CODEC_PT BTS_TRXC; |
| 138 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 139 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 140 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 141 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 142 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 143 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 144 | /* PCU Interface of BTS */ |
| 145 | port PCUIF_CODEC_PT PCU; |
| 146 | var integer g_pcu_conn_id; |
| 147 | /* Last PCU INFO IND we received */ |
| 148 | var PCUIF_Message g_pcu_last_info; |
| 149 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 150 | /* SI configuration */ |
| 151 | var SystemInformationConfig si_cfg := { |
| 152 | bcch_extended := false, |
| 153 | si1_present := false, |
| 154 | si2bis_present := false, |
| 155 | si2ter_present := false, |
| 156 | si2quater_present := false, |
| 157 | si7_present := false, |
| 158 | si8_present := false, |
| 159 | si9_present := false, |
| 160 | si13_present := false, |
| 161 | si13alt_present := false, |
| 162 | si15_present := false, |
| 163 | si16_present := false, |
| 164 | si17_present := false, |
| 165 | si2n_present := false, |
| 166 | si21_present := false, |
| 167 | si22_present := false |
| 168 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 169 | |
| 170 | /* all logical channels available on the BTS */ |
| 171 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 172 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 176 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 177 | port L1CTL_PT L1CTL; |
| 178 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 179 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 180 | port TRXC_CODEC_PT BTS_TRXC; |
| 181 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 182 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 183 | /* port to be initialized optionally to access BSC VTY */ |
| 184 | port TELNETasp_PT BSCVTY; |
| 185 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 186 | timer g_Tguard; |
| 187 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 188 | |
| 189 | var ConnHdlrPars g_pars; |
| 190 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 191 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 192 | |
| 193 | /* PCU Interface of BTS */ |
| 194 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 195 | } |
| 196 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 197 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 198 | var bitstring trx_mask := '00000000'B; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 199 | var bitstring rfind_mask := '00000000'B; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 200 | var integer trx_count := 0; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 201 | var integer rfind_count := 0; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 202 | var RSLEm_Event ev; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 203 | var ASP_RSL_Unitdata rx_ud; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 204 | timer T; |
| 205 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 206 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 207 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 208 | |
| 209 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 210 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 211 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 212 | |
| 213 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 214 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 215 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 216 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 217 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 218 | T.start(mp_ipa_up_timeout); |
| 219 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 220 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 221 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 222 | /* Make sure that all transceivers use unique stream ID */ |
| 223 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 224 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 225 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 226 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 227 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 228 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 229 | trx_count := trx_count + 1; |
| 230 | |
| 231 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 232 | repeat; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 233 | } |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 234 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 235 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud { |
| 236 | if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) { |
| 237 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 238 | log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")")); |
| 239 | } |
| 240 | if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) { |
| 241 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 242 | log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")")); |
| 243 | } |
| 244 | |
| 245 | rfind_mask[enum2int(rx_ud.streamId)] := '1'B; |
| 246 | rfind_count := rfind_count + 1; |
| 247 | log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received"); |
| 248 | if (rfind_count < mp_transceiver_num) { repeat; } |
| 249 | } |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 250 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 251 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 252 | [] T.timeout { |
| 253 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 254 | "Timeout waiting for RSL bring up"); |
| 255 | } |
| 256 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 259 | friend type record length(1 .. 256) of TrxParsItem TrxPars; |
| 260 | friend type record TrxParsItem { |
| 261 | GsmArfcn arfcn, |
| 262 | TrxTsPars ts |
| 263 | }; |
| 264 | |
| 265 | friend type record length(8) of TrxTsParsItem TrxTsPars; |
| 266 | friend type record TrxTsParsItem { |
| 267 | PchanConfig config |
| 268 | }; |
| 269 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 270 | friend type record FreqHopPars { |
| 271 | /* Whether frequency hopping is in use */ |
| 272 | boolean enabled, |
| 273 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 274 | MaioHsn maio_hsn, |
| 275 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 276 | MobileAllocationLV ma_map, |
| 277 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 278 | L1ctlMA ma |
| 279 | }; |
| 280 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 281 | type record ConnHdlrPars { |
| 282 | RslChannelNr chan_nr, |
| 283 | RSL_IE_ChannelMode chan_mode, |
| 284 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 285 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 286 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 287 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 288 | BtsBand bts0_band optional, |
| 289 | |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 290 | /* Training Sequence Code */ |
| 291 | GsmTsc tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 292 | /* Frequency hopping parameters */ |
| 293 | FreqHopPars fhp |
| 294 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 295 | |
| 296 | /* Test-specific parameters */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 297 | private type union TestSpecUnion { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 298 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 299 | } |
| 300 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 301 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 302 | max_retrans := RACH_MAX_RETRANS_7, |
| 303 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 304 | cell_barr_access := false, |
| 305 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 306 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 307 | }; |
| 308 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 309 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 310 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 311 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 312 | acs := '0'B, |
| 313 | neci := true, |
| 314 | rxlev_access_min := 0 |
| 315 | } |
| 316 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 317 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 318 | mcc_mnc := '262F42'H, |
| 319 | lac := 42 |
| 320 | } |
| 321 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 322 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 323 | ra_colour := 0, |
| 324 | si13_pos := '0'B |
| 325 | } |
| 326 | |
| 327 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 328 | modifies ts_SI3RestOctets := { |
| 329 | gprs_ind := { |
| 330 | presence := CSN1_H, |
| 331 | ind := ts_GPRSIndicator_def |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 336 | modifies ts_SI4RestOctets := { |
| 337 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 338 | presence := CSN1_H, |
| 339 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 343 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 344 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 345 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 346 | payload := { |
| 347 | si3 := { |
| 348 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 349 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 350 | ctrl_chan_desc := { |
| 351 | msc_r99 := true, |
| 352 | att := true, |
| 353 | bs_ag_blks_res := 1, |
| 354 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 355 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 356 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 357 | spare := '00'B, |
| 358 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 359 | t3212 := 1 /* 6 minutes */ |
| 360 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 361 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 362 | dn_ind := false, |
| 363 | pwrc := false, |
| 364 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 365 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 366 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 367 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 368 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 369 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 373 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 374 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 375 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 376 | payload := { |
| 377 | si2 := { |
| 378 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 379 | ncc_permitted := '11111111'B, |
| 380 | rach_control := ts_RachCtrl_default |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 385 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 386 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 387 | payload := { |
| 388 | si4 := { |
| 389 | lai := ts_LAI_default, |
| 390 | cell_sel_par := ts_CellSelPar_default, |
| 391 | rach_control := ts_RachCtrl_default, |
| 392 | cbch_chan_desc := omit, |
| 393 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 394 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 399 | 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] | 400 | runs on test_CT { |
| 401 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 402 | 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] | 403 | } |
| 404 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 405 | 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] | 406 | runs on test_CT { |
| 407 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 408 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 409 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 410 | } |
| 411 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 412 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 413 | map(self:BTSVTY, system:BTSVTY); |
| 414 | f_vty_set_prompts(BTSVTY); |
| 415 | f_vty_transceive(BTSVTY, "enable"); |
| 416 | } |
| 417 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 418 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 419 | map(self:BSCVTY, system:BSCVTY); |
| 420 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 421 | f_vty_transceive(BSCVTY, "enable"); |
| 422 | } |
| 423 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 424 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 425 | map(self:BSCVTY, system:BSCVTY); |
| 426 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 427 | f_vty_transceive(BSCVTY, "enable"); |
| 428 | } |
| 429 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 430 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 431 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 432 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 433 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 434 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 435 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 436 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 437 | [] 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] | 438 | 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] | 439 | } |
| 440 | } |
| 441 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 442 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 443 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 444 | timer T := 2.0; |
| 445 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 446 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 447 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 448 | return; |
| 449 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 450 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 451 | |
| 452 | T.start; |
| 453 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 454 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 455 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 456 | 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] | 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 461 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 462 | out integer trxc_conn_id) { |
| 463 | var Result res; |
| 464 | |
| 465 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 466 | "", -1, -1, { udp := {} }, {}); |
| 467 | if (not ispresent(res.connId)) { |
| 468 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 469 | "Could not connect to the control (TRXC) interface " & |
| 470 | "of FakeTRX, check your configuration"); |
| 471 | } |
| 472 | trxc_conn_id := res.connId; |
| 473 | } |
| 474 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 475 | /* global init function (without PCUIF connection) */ |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 476 | friend function f_init(uint8_t trx_nr := 0) |
| 477 | runs on test_CT |
| 478 | { |
| 479 | var TrxParsItem trx_pars := mp_trx_pars[trx_nr]; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 480 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 481 | |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 482 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653. |
| 483 | * TODO: also generate this list dynamically from module parameters. */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 484 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 485 | g_AllChanTypes := { |
| 486 | /* TS 1..4: TCH/F */ |
| 487 | valueof(ts_RslChanNr_Bm(1)), |
| 488 | /* TS 5: TCH/H */ |
| 489 | valueof(ts_RslChanNr_Lm(5,1)), |
| 490 | /* TS 0: SDCCH/4 */ |
| 491 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 492 | /* TS 6: SDCCH/8 */ |
| 493 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 494 | }; |
| 495 | } else { |
| 496 | g_AllChanTypes := { |
| 497 | /* TS 1..4: TCH/F */ |
| 498 | valueof(ts_RslChanNr_Bm(1)), |
| 499 | /* TS 0: SDCCH/4 */ |
| 500 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 501 | /* TS 6: SDCCH/8 */ |
| 502 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 503 | }; |
| 504 | } |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 505 | |
| 506 | g_AllChannels := { }; |
| 507 | |
| 508 | /* Generate list of all logical channels from module parameters */ |
| 509 | for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) { |
| 510 | select (trx_pars.ts[tn].config) { |
| 511 | case (GSM_PCHAN_CCCH_SDCCH4) { |
| 512 | g_AllChannels := g_AllChannels & |
| 513 | { valueof(ts_RslChanNr_SDCCH4(tn, 0)), |
| 514 | valueof(ts_RslChanNr_SDCCH4(tn, 1)), |
| 515 | valueof(ts_RslChanNr_SDCCH4(tn, 2)), |
| 516 | valueof(ts_RslChanNr_SDCCH4(tn, 3)) }; |
| 517 | } |
| 518 | case (GSM_PCHAN_SDCCH8) { |
| 519 | g_AllChannels := g_AllChannels & |
| 520 | { valueof(ts_RslChanNr_SDCCH8(tn, 0)), |
| 521 | valueof(ts_RslChanNr_SDCCH8(tn, 1)), |
| 522 | valueof(ts_RslChanNr_SDCCH8(tn, 2)), |
| 523 | valueof(ts_RslChanNr_SDCCH8(tn, 3)), |
| 524 | valueof(ts_RslChanNr_SDCCH8(tn, 4)), |
| 525 | valueof(ts_RslChanNr_SDCCH8(tn, 5)), |
| 526 | valueof(ts_RslChanNr_SDCCH8(tn, 6)), |
| 527 | valueof(ts_RslChanNr_SDCCH8(tn, 7)) }; |
| 528 | } |
| 529 | case (GSM_PCHAN_TCHH_TCHF_PDCH) { |
| 530 | g_AllChannels := g_AllChannels & |
| 531 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 532 | valueof(ts_RslChanNr_Lm(tn, 1)), |
| 533 | valueof(ts_RslChanNr_Bm(tn)) }; |
| 534 | } |
| 535 | case (GSM_PCHAN_TCHH) { |
| 536 | g_AllChannels := g_AllChannels & |
| 537 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 538 | valueof(ts_RslChanNr_Lm(tn, 1)) }; |
| 539 | } |
| 540 | case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) { |
| 541 | g_AllChannels := g_AllChannels & |
| 542 | { valueof(ts_RslChanNr_Bm(tn)) }; |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 547 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 548 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 549 | f_init_vty(id); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 550 | f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 551 | |
| 552 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 553 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 554 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 555 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 556 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 557 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 558 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 559 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 560 | |
| 561 | /* Init TRXC interface to FakeTRX */ |
| 562 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 563 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 564 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 565 | /* 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] | 566 | 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] | 567 | 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] | 568 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 569 | 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] | 570 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 571 | |
| 572 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 573 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 574 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 575 | } |
| 576 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 577 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 578 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 579 | map(self:L1CTL, system:L1CTL); |
| 580 | f_connect_reset(L1CTL); |
| 581 | } |
| 582 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 583 | private type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 584 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 585 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 586 | |
| 587 | private type record of FreqHopGroup FreqHopGroups; |
| 588 | private type record FreqHopGroup { |
| 589 | uint6_t hsn, |
| 590 | FreqHopGroupItems trx_maio |
| 591 | }; |
| 592 | |
| 593 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 594 | private type record FreqHopGroupItem { |
| 595 | uint8_t trx_nr, |
| 596 | uint6_t maio |
| 597 | }; |
| 598 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 599 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 600 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 601 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 602 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 603 | var integer i, j; |
| 604 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 605 | fhp.enabled := false; |
| 606 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 607 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 608 | var FreqHopGroup g := groups[i]; |
| 609 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 610 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 611 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 612 | fhp.maio_hsn.maio := gi.maio; |
| 613 | fhp.maio_hsn.hsn := g.hsn; |
| 614 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 615 | break; |
| 616 | } |
| 617 | } |
| 618 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 619 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 620 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 621 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 622 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 623 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 624 | |
| 625 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 626 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 627 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 628 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 629 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 630 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 631 | } |
| 632 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 633 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 634 | break; /* We're done */ |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 639 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 640 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 641 | boolean pcu_comp := false, |
| 642 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 643 | runs on test_CT return ConnHdlr { |
| 644 | var charstring id := testcasename(); |
| 645 | var ConnHdlr vc_conn; |
| 646 | |
| 647 | vc_conn := ConnHdlr.create(id); |
| 648 | /* connect to RSL Emulation main component */ |
| 649 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 650 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 651 | |
| 652 | /* The ConnHdlr component may want to talk to some ports directly, |
| 653 | * so we disconnect it from the test_CT and connect it to the component. |
| 654 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 655 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 656 | unmap(self:PCU, system:PCU); |
| 657 | map(vc_conn:PCU, system:PCU); |
| 658 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 659 | if (trxc_comp) { |
| 660 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 661 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 662 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 663 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 664 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 665 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 666 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 667 | } |
| 668 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 669 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 670 | return vc_conn; |
| 671 | } |
| 672 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 673 | private altstep as_Tguard() runs on ConnHdlr { |
| 674 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 675 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 676 | } |
| 677 | } |
| 678 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 679 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 680 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 681 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 682 | } |
| 683 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 684 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 685 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 686 | 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] | 687 | } |
| 688 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 689 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 690 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 691 | 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] | 692 | } |
| 693 | |
| 694 | /* first function started in ConnHdlr component */ |
| 695 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 696 | runs on ConnHdlr { |
| 697 | g_pars := pars; |
| 698 | g_chan_nr := pars.chan_nr; |
| 699 | |
| 700 | map(self:L1CTL, system:L1CTL); |
| 701 | f_connect_reset(L1CTL); |
| 702 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 703 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 704 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 705 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 706 | |
| 707 | g_Tguard.start(pars.t_guard); |
| 708 | activate(as_Tguard()); |
| 709 | |
| 710 | f_rslem_register(0, pars.chan_nr); |
| 711 | |
| 712 | /* call the user-supplied test case function */ |
| 713 | fn.apply(id); |
| 714 | } |
| 715 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 716 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 717 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 718 | runs on ConnHdlr return RSL_Message { |
| 719 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 720 | timer T := 3.0; |
| 721 | RSL.send(tx); |
| 722 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 723 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 724 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 725 | T.stop; |
| 726 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 727 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 728 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 729 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 730 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 731 | [not ignore_other] as_l1_sacch(); |
| 732 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 733 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 734 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 735 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 736 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 737 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 738 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 739 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 740 | return rx; |
| 741 | } |
| 742 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 743 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 744 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 745 | runs on ConnHdlr { |
| 746 | 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] | 747 | } |
| 748 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 749 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 750 | boolean encr_enable := false, |
| 751 | RSL_IE_List more_ies := {}, |
| 752 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 753 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 754 | 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] | 755 | if (encr_enable) { |
| 756 | /* append encryption related IEs, if requested */ |
| 757 | var RSL_IE_EncryptionInfo encr_info; |
| 758 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 759 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 760 | encr_info})) }; |
| 761 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 762 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 763 | 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] | 764 | } |
| 765 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 766 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 767 | 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] | 768 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 769 | } |
| 770 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 771 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 772 | template RSL_IE_ChannelMode chan_mode, |
| 773 | float t_guard := 20.0) := { |
| 774 | chan_nr := valueof(chan_nr), |
| 775 | chan_mode := valueof(chan_mode), |
| 776 | t_guard := t_guard, |
| 777 | l1_pars := { |
| 778 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 779 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 780 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 781 | meas_ul := { |
| 782 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 783 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 784 | rxqual := 0 |
| 785 | }, |
| 786 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 787 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 788 | rxqual := 0 |
| 789 | } |
| 790 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 791 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 792 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 793 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 794 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 795 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 796 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 797 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 798 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 799 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 800 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 801 | fhp := { |
| 802 | enabled := false, |
| 803 | maio_hsn := ts_HsnMaio(0, 0), |
| 804 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 805 | ma := { } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 806 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 807 | } |
| 808 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 809 | /*********************************************************************** |
| 810 | * Channel Activation / Deactivation |
| 811 | ***********************************************************************/ |
| 812 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 813 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 814 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 815 | for (var integer i := 0; i < 500; i := i+1) { |
| 816 | f_rsl_chan_act(g_pars.chan_mode); |
| 817 | f_rsl_chan_deact(); |
| 818 | } |
| 819 | setverdict(pass); |
| 820 | } |
| 821 | testcase TC_chan_act_stress() runs on test_CT { |
| 822 | var ConnHdlr vc_conn; |
| 823 | 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] | 824 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 825 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 826 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 827 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 831 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 832 | f_rsl_chan_act(g_pars.chan_mode); |
| 833 | /* attempt to activate the same lchan again -> expect reject */ |
| 834 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 835 | alt { |
| 836 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 837 | 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] | 838 | } |
| 839 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 840 | setverdict(pass); |
| 841 | } |
| 842 | } |
| 843 | f_rsl_chan_deact(); |
| 844 | } |
| 845 | testcase TC_chan_act_react() runs on test_CT { |
| 846 | var ConnHdlr vc_conn; |
| 847 | 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] | 848 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 849 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 850 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 851 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 855 | 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] | 856 | timer T := 3.0; |
| 857 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 858 | T.start; |
| 859 | alt { |
| 860 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 861 | setverdict(pass); |
| 862 | } |
| 863 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 864 | 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] | 865 | } |
| 866 | } |
| 867 | } |
| 868 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 869 | 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] | 870 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 871 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 872 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 873 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 877 | 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] | 878 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 879 | alt { |
| 880 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 881 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 882 | } |
| 883 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 884 | setverdict(pass); |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | private type record WrongChanNrCase { |
| 889 | RslChannelNr chan_nr, |
| 890 | charstring description |
| 891 | } |
| 892 | private type record of WrongChanNrCase WrongChanNrCases; |
| 893 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 894 | chan_nr := chan_nr, |
| 895 | description := desc |
| 896 | } |
| 897 | |
| 898 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 899 | var ConnHdlr vc_conn; |
| 900 | var ConnHdlrPars pars; |
| 901 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 902 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 903 | |
| 904 | var WrongChanNrCases wrong := { |
| 905 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 906 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 907 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 908 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 909 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 910 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 911 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 912 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 913 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 914 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 915 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 916 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 917 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 918 | }; |
| 919 | |
| 920 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 921 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 922 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 923 | vc_conn.done; |
| 924 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 925 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 926 | } |
| 927 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 928 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 929 | 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] | 930 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 931 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 932 | |
| 933 | /* test on each of the channels we have */ |
| 934 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 935 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 936 | |
| 937 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 938 | vc_conn := f_start_handler(fn, pars); |
| 939 | vc_conn.done; |
| 940 | } |
| 941 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 942 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 943 | } |
| 944 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 945 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 946 | * SACCH handling |
| 947 | ***********************************************************************/ |
| 948 | |
| 949 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 950 | timer T_sacch := 3.0; |
| 951 | T_sacch.start; |
| 952 | alt { |
| 953 | [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] | 954 | 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] | 955 | } |
| 956 | [not exp] T_sacch.timeout { |
| 957 | setverdict(pass); |
| 958 | } |
| 959 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 960 | setverdict(pass); |
| 961 | } |
| 962 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 963 | 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] | 964 | } |
| 965 | [] L1CTL.receive { repeat; } |
| 966 | [] RSL.receive { repeat; } |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 971 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 972 | f_l1_tune(L1CTL); |
| 973 | RSL.clear; |
| 974 | |
| 975 | /* activate the logical channel */ |
| 976 | f_est_dchan(); |
| 977 | L1CTL.clear; |
| 978 | |
| 979 | /* check that SACCH actually are received as expected */ |
| 980 | f_exp_sacch(true); |
| 981 | |
| 982 | /* deactivate SACCH on the logical channel */ |
| 983 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 984 | f_sleep(1.0); |
| 985 | L1CTL.clear; |
| 986 | |
| 987 | /* check that no SACCH are received anymore */ |
| 988 | f_exp_sacch(false); |
| 989 | |
| 990 | /* release the channel */ |
| 991 | f_rsl_chan_deact(); |
| 992 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 993 | } |
| 994 | testcase TC_deact_sacch() runs on test_CT { |
| 995 | var ConnHdlr vc_conn; |
| 996 | var ConnHdlrPars pars; |
| 997 | f_init(); |
| 998 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 999 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1000 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1001 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1002 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1003 | vc_conn.done; |
| 1004 | } |
| 1005 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1006 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1007 | } |
| 1008 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1009 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1010 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 1011 | var L1ctlDlMessage dl; |
| 1012 | /* check that the specified SI5 value is actually sent */ |
| 1013 | timer T_sacch := 3.0; |
| 1014 | L1CTL.clear; |
| 1015 | T_sacch.start; |
| 1016 | alt { |
| 1017 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1018 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1019 | if (match(l3, l3_exp)) { |
| 1020 | setverdict(pass); |
| 1021 | } else { |
| 1022 | repeat; |
| 1023 | } |
| 1024 | } |
| 1025 | [] L1CTL.receive { repeat; } |
| 1026 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1027 | 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] | 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1032 | /* verify that given SACCH payload is not present */ |
| 1033 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1034 | var L1ctlDlMessage dl; |
| 1035 | /* check that the specified SI5 value is actually sent */ |
| 1036 | timer T_sacch := 3.0; |
| 1037 | L1CTL.clear; |
| 1038 | T_sacch.start; |
| 1039 | alt { |
| 1040 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1041 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1042 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1043 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1044 | } else { |
| 1045 | repeat; |
| 1046 | } |
| 1047 | } |
| 1048 | [] L1CTL.receive { repeat; } |
| 1049 | [] T_sacch.timeout { |
| 1050 | setverdict(pass); |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1055 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1056 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1057 | /* Set a known default SACCH filling for SI5 */ |
| 1058 | var octetstring si5 := f_rnd_octstring(19); |
| 1059 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1060 | |
| 1061 | f_l1_tune(L1CTL); |
| 1062 | RSL.clear; |
| 1063 | |
| 1064 | /* activate the logical channel */ |
| 1065 | f_est_dchan(); |
| 1066 | |
| 1067 | /* check that the specified SI5 value is actually sent */ |
| 1068 | f_sacch_present(si5); |
| 1069 | |
| 1070 | /* release the channel */ |
| 1071 | RSL.clear; |
| 1072 | f_rsl_chan_deact(); |
| 1073 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1074 | } |
| 1075 | testcase TC_sacch_filling() runs on test_CT { |
| 1076 | var ConnHdlr vc_conn; |
| 1077 | var ConnHdlrPars pars; |
| 1078 | f_init(); |
| 1079 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1080 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1081 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1082 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1083 | vc_conn.done; |
| 1084 | } |
| 1085 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1086 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1087 | } |
| 1088 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1089 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1090 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1091 | /* Set a known default SACCH filling for SI5 */ |
| 1092 | var octetstring si5 := f_rnd_octstring(19); |
| 1093 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1094 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1095 | |
| 1096 | f_l1_tune(L1CTL); |
| 1097 | RSL.clear; |
| 1098 | |
| 1099 | log("Activating channel, expecting standard SI5"); |
| 1100 | /* activate the logical channel */ |
| 1101 | f_est_dchan(); |
| 1102 | /* check that the specified SI5 value is actually sent */ |
| 1103 | f_sacch_present(si5); |
| 1104 | |
| 1105 | /* set channel-specific different SI5 */ |
| 1106 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1107 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1108 | /* check that the specified lchan-specific value is now used */ |
| 1109 | f_sacch_present(si5_diff); |
| 1110 | |
| 1111 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1112 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1113 | f_rsl_chan_deact(); |
| 1114 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1115 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1116 | f_sacch_present(si5); |
| 1117 | |
| 1118 | /* release the channel */ |
| 1119 | RSL.clear; |
| 1120 | f_rsl_chan_deact(); |
| 1121 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1122 | } |
| 1123 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1124 | var ConnHdlr vc_conn; |
| 1125 | var ConnHdlrPars pars; |
| 1126 | f_init(); |
| 1127 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1128 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1129 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1130 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1131 | vc_conn.done; |
| 1132 | } |
| 1133 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1134 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1135 | } |
| 1136 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1137 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1138 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1139 | var octetstring si5 := f_rnd_octstring(19); |
| 1140 | var octetstring si5bis := f_rnd_octstring(19); |
| 1141 | var octetstring si5ter := f_rnd_octstring(19); |
| 1142 | var octetstring si6 := f_rnd_octstring(19); |
| 1143 | |
| 1144 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1145 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1146 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1147 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1148 | |
| 1149 | f_l1_tune(L1CTL); |
| 1150 | RSL.clear; |
| 1151 | |
| 1152 | /* activate the logical channel */ |
| 1153 | f_est_dchan(); |
| 1154 | L1CTL.clear; |
| 1155 | |
| 1156 | /* check that SACCH actually are received as expected */ |
| 1157 | f_sacch_present(si5); |
| 1158 | f_sacch_present(si5bis); |
| 1159 | f_sacch_present(si5ter); |
| 1160 | f_sacch_present(si6); |
| 1161 | |
| 1162 | /* release the channel */ |
| 1163 | f_rsl_chan_deact(); |
| 1164 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1165 | } |
| 1166 | testcase TC_sacch_multi() runs on test_CT { |
| 1167 | var ConnHdlr vc_conn; |
| 1168 | var ConnHdlrPars pars; |
| 1169 | f_init(); |
| 1170 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1171 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1172 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1173 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1174 | vc_conn.done; |
| 1175 | } |
| 1176 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1177 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1178 | } |
| 1179 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1180 | /* Test if SACH information is modified as expected */ |
| 1181 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1182 | var octetstring si5 := f_rnd_octstring(19); |
| 1183 | var octetstring si6 := f_rnd_octstring(19); |
| 1184 | |
| 1185 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1186 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1187 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1188 | |
| 1189 | f_l1_tune(L1CTL); |
| 1190 | RSL.clear; |
| 1191 | |
| 1192 | /* activate the logical channel */ |
| 1193 | f_est_dchan(); |
| 1194 | L1CTL.clear; |
| 1195 | |
| 1196 | /* check that SACCH actually are received as expected */ |
| 1197 | f_sacch_present(si5); |
| 1198 | f_sacch_present(si6); |
| 1199 | |
| 1200 | /* disable SI6 */ |
| 1201 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1202 | |
| 1203 | /* check that SI5 is still transmitted */ |
| 1204 | f_sacch_present(si5); |
| 1205 | /* check if SI6 is now gone */ |
| 1206 | f_sacch_missing(si6); |
| 1207 | |
| 1208 | /* release the channel */ |
| 1209 | f_rsl_chan_deact(); |
| 1210 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1211 | } |
| 1212 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1213 | var ConnHdlr vc_conn; |
| 1214 | var ConnHdlrPars pars; |
| 1215 | f_init(); |
| 1216 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1217 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1218 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1219 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1220 | vc_conn.done; |
| 1221 | } |
| 1222 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1223 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1224 | } |
| 1225 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1226 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1227 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1228 | var octetstring si5 := f_rnd_octstring(19); |
| 1229 | var octetstring si6 := f_rnd_octstring(19); |
| 1230 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1231 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1232 | |
| 1233 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1234 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1235 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1236 | |
| 1237 | f_l1_tune(L1CTL); |
| 1238 | RSL.clear; |
| 1239 | |
| 1240 | /* activate channel with different SACCH filling */ |
| 1241 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1242 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1243 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1244 | })); |
| 1245 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1246 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1247 | f_est_dchan(more_ies := addl_ies); |
| 1248 | |
| 1249 | /* check that SACCH actually are received as expected */ |
| 1250 | f_sacch_present(si5_specific); |
| 1251 | f_sacch_present(si6_specific); |
| 1252 | |
| 1253 | /* release the channel */ |
| 1254 | f_rsl_chan_deact(); |
| 1255 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1256 | } |
| 1257 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1258 | var ConnHdlr vc_conn; |
| 1259 | var ConnHdlrPars pars; |
| 1260 | f_init(); |
| 1261 | |
| 1262 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1263 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1264 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1265 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1266 | vc_conn.done; |
| 1267 | } |
| 1268 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1269 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1270 | } |
| 1271 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1272 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1273 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1274 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1275 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1276 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1277 | |
| 1278 | f_l1_tune(L1CTL); |
| 1279 | RSL.clear; |
| 1280 | |
| 1281 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1282 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1283 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1284 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1285 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1286 | var RSL_IE_List addl_ies := { |
| 1287 | ho_ref_ie |
| 1288 | }; |
| 1289 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1290 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1291 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1292 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1293 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1294 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1295 | |
| 1296 | /* Verify that no DL SACCH is being received */ |
| 1297 | f_sacch_missing(?); |
| 1298 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1299 | /* Send handover Access Burst and expect SACCH to start */ |
| 1300 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1301 | |
| 1302 | f_sacch_present(si5); |
| 1303 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1304 | f_rsl_chan_deact(); |
| 1305 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1306 | |
| 1307 | |
| 1308 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1309 | |
| 1310 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1311 | addl_ies := { |
| 1312 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1313 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1314 | }; |
| 1315 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1316 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1317 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1318 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1319 | |
| 1320 | /* Verify that DL SACCH is being received */ |
| 1321 | f_sacch_present(si5); |
| 1322 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1323 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1324 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1325 | |
| 1326 | f_sacch_present(si5); |
| 1327 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1328 | f_rsl_chan_deact(); |
| 1329 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1330 | } |
| 1331 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1332 | var ConnHdlr vc_conn; |
| 1333 | var ConnHdlrPars pars; |
| 1334 | f_init(); |
| 1335 | |
| 1336 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1337 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1338 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1339 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1340 | vc_conn.done; |
| 1341 | } |
| 1342 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1343 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1344 | } |
| 1345 | |
| 1346 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1347 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1348 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1349 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1350 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1351 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1352 | var RSL_IE_List addl_ies; |
| 1353 | |
| 1354 | f_l1_tune(L1CTL); |
| 1355 | RSL.clear; |
| 1356 | |
| 1357 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1358 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1359 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1360 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1361 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1362 | addl_ies := { |
| 1363 | ho_ref_ie |
| 1364 | }; |
| 1365 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1366 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1367 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1368 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1369 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1370 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1371 | |
| 1372 | /* Verify that no DL SACCH is being received */ |
| 1373 | f_sacch_missing(?); |
| 1374 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1375 | /* Send handover Access Burst and expect SACCH to start */ |
| 1376 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1377 | |
| 1378 | f_sacch_present(si5); |
| 1379 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1380 | f_rsl_chan_deact(); |
| 1381 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1382 | |
| 1383 | |
| 1384 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1385 | |
| 1386 | /* Activate channel on BTS side */ |
| 1387 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1388 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1389 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1390 | }; |
| 1391 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1392 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1393 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1394 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1395 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1396 | /* Verify that DL SACCH is being received, because MS Power IE was sent */ |
| 1397 | f_sacch_present(si5); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1398 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1399 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1400 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1401 | |
| 1402 | f_sacch_present(si5); |
| 1403 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1404 | f_rsl_chan_deact(); |
| 1405 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1406 | |
| 1407 | |
| 1408 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1409 | |
| 1410 | /* Activate channel on BTS side */ |
| 1411 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1412 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1413 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1414 | }; |
| 1415 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1416 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1417 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1418 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1419 | |
| 1420 | /* Verify that no DL SACCH is being received */ |
| 1421 | f_sacch_missing(?); |
| 1422 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1423 | /* Send handover Access Burst and expect SACCH to start */ |
| 1424 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1425 | |
| 1426 | f_sacch_present(si5); |
| 1427 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1428 | f_rsl_chan_deact(); |
| 1429 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1430 | |
| 1431 | |
| 1432 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1433 | |
| 1434 | /* Activate channel on BTS side */ |
| 1435 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1436 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1437 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1438 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1439 | }; |
| 1440 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1441 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1442 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1443 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1444 | |
| 1445 | /* Verify that DL SACCH is being received */ |
| 1446 | f_sacch_present(si5); |
| 1447 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1448 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1449 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1450 | |
| 1451 | f_sacch_present(si5); |
| 1452 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1453 | f_rsl_chan_deact(); |
| 1454 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1455 | } |
| 1456 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1457 | var ConnHdlr vc_conn; |
| 1458 | var ConnHdlrPars pars; |
| 1459 | f_init(); |
| 1460 | |
| 1461 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1462 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1463 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1464 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1465 | vc_conn.done; |
| 1466 | } |
| 1467 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1468 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1469 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1470 | |
| 1471 | |
| 1472 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1473 | * RACH Handling |
| 1474 | ***********************************************************************/ |
| 1475 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1476 | /* 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] | 1477 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1478 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1479 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1480 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1481 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1482 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1483 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1484 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1485 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1486 | if (emerg == true) { |
| 1487 | ra := f_rnd_ra_emerg(); |
| 1488 | } else { |
| 1489 | ra := f_rnd_ra_cs(); |
| 1490 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1491 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1492 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1493 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1494 | } |
| 1495 | fn_last := fn; |
| 1496 | |
| 1497 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1498 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1499 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1500 | [] 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] | 1501 | T.stop; |
| 1502 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1503 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1504 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1505 | } |
| 1506 | [] RSL_CCHAN.receive { repeat; } |
| 1507 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1508 | test_failed := true; |
| 1509 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1510 | } |
| 1511 | } |
| 1512 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1513 | if (test_failed) { |
| 1514 | 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] | 1515 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1516 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1518 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1519 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1520 | /* Normal variant */ |
| 1521 | testcase TC_rach_content() runs on test_CT { |
| 1522 | f_TC_rach_content(emerg := false); |
| 1523 | } |
| 1524 | |
| 1525 | /* Emergency call variant */ |
| 1526 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1527 | f_TC_rach_content(emerg := true); |
| 1528 | } |
| 1529 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1530 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1531 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1532 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1533 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1534 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1535 | f_l1_tune(L1CTL); |
| 1536 | |
| 1537 | var GsmFrameNumber fn_last := 0; |
| 1538 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1539 | var OCT1 ra := f_rnd_ra_cs(); |
| 1540 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1541 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1542 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1543 | } |
| 1544 | fn_last := fn; |
| 1545 | } |
| 1546 | var integer rsl_chrqd := 0; |
| 1547 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1548 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1549 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1550 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1551 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1552 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1553 | repeat; |
| 1554 | } |
| 1555 | [] RSL_CCHAN.receive { repeat; } |
| 1556 | [] T.timeout { } |
| 1557 | } |
| 1558 | if (rsl_chrqd == 1000) { |
| 1559 | setverdict(pass); |
| 1560 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1561 | 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] | 1562 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1563 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1564 | } |
| 1565 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1566 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1567 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1568 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1569 | } |
| 1570 | |
| 1571 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1572 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1573 | |
| 1574 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1575 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1576 | var ASP_RSL_Unitdata rx_ud; |
| 1577 | |
| 1578 | f_init_vty_bsc(); |
| 1579 | /* send load indications even at 0% load */ |
| 1580 | f_vty_load_ind_thresh(0); |
| 1581 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1582 | f_sleep(2.0); |
| 1583 | |
| 1584 | f_init(); |
| 1585 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1586 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1587 | alt { |
| 1588 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1589 | [] RSL_CCHAN.receive { repeat } |
| 1590 | } |
| 1591 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1592 | timer T := 5.0; |
| 1593 | T.start; |
| 1594 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1595 | [] 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] | 1596 | setverdict(pass); |
| 1597 | repeat; |
| 1598 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1599 | [] 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] | 1600 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1601 | repeat; |
| 1602 | } |
| 1603 | [] RSL_CCHAN.receive { |
| 1604 | repeat; |
| 1605 | } |
| 1606 | [] T.timeout { } |
| 1607 | } |
| 1608 | |
| 1609 | f_vty_load_ind_thresh(10); |
| 1610 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1611 | } |
| 1612 | |
| 1613 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1614 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1615 | var ASP_RSL_Unitdata rx_ud; |
| 1616 | |
| 1617 | f_init_vty_bsc(); |
| 1618 | f_init(); |
| 1619 | |
| 1620 | timer T := 5.0; |
| 1621 | T.start; |
| 1622 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1623 | [] 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] | 1624 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1625 | repeat; |
| 1626 | } |
| 1627 | [] RSL_CCHAN.receive { |
| 1628 | repeat; |
| 1629 | } |
| 1630 | [] T.timeout { |
| 1631 | setverdict(pass); |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1636 | } |
| 1637 | |
| 1638 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1639 | testcase TC_rach_load_count() runs on test_CT { |
| 1640 | var ASP_RSL_Unitdata rx_ud; |
| 1641 | var integer load_access_count := 0; |
| 1642 | |
| 1643 | f_init_vty_bsc(); |
| 1644 | /* send load indications even at 0% load */ |
| 1645 | f_vty_load_ind_thresh(0); |
| 1646 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1647 | f_sleep(2.0); |
| 1648 | f_init(); |
| 1649 | |
| 1650 | f_init_l1ctl(); |
| 1651 | f_sleep(1.0); |
| 1652 | f_l1_tune(L1CTL); |
| 1653 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1654 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1655 | alt { |
| 1656 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1657 | [] RSL_CCHAN.receive { repeat } |
| 1658 | } |
| 1659 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1660 | var GsmFrameNumber fn_last := 0; |
| 1661 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1662 | var OCT1 ra := f_rnd_ra_cs(); |
| 1663 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1664 | if (fn == fn_last) { |
| 1665 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1666 | } |
| 1667 | fn_last := fn; |
| 1668 | } |
| 1669 | |
| 1670 | timer T := 5.0; |
| 1671 | T.start; |
| 1672 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1673 | [] 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] | 1674 | -> value rx_ud { |
| 1675 | var RSL_IE_Body ie; |
| 1676 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1677 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1678 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1679 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1680 | } |
| 1681 | repeat; |
| 1682 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1683 | [] 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] | 1684 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1685 | repeat; |
| 1686 | } |
| 1687 | [] RSL_CCHAN.receive { |
| 1688 | repeat; |
| 1689 | } |
| 1690 | [] T.timeout { } |
| 1691 | } |
| 1692 | if (load_access_count == 1000) { |
| 1693 | setverdict(pass); |
| 1694 | } else { |
| 1695 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1696 | } |
| 1697 | |
| 1698 | f_vty_load_ind_thresh(10); |
| 1699 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1700 | } |
| 1701 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1702 | 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] | 1703 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1704 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1705 | 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] | 1706 | f_sleep(0.5); |
| 1707 | |
| 1708 | /* Transmit RACH request + wait for confirmation */ |
| 1709 | var OCT1 ra := f_rnd_ra_cs(); |
| 1710 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1711 | |
| 1712 | /* Check for expected result */ |
| 1713 | timer T := 1.5; |
| 1714 | T.start; |
| 1715 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1716 | [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] | 1717 | setverdict(pass); |
| 1718 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1719 | [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] | 1720 | 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] | 1721 | } |
| 1722 | [] RSL_CCHAN.receive { repeat; } |
| 1723 | [not expect_pass] T.timeout { |
| 1724 | setverdict(pass); |
| 1725 | } |
| 1726 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1727 | 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] | 1728 | } |
| 1729 | } |
| 1730 | } |
| 1731 | |
| 1732 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1733 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1734 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1735 | f_init_l1ctl(); |
| 1736 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1737 | f_sleep(1.0); |
| 1738 | |
| 1739 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1740 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1741 | /* We allow early arrival up to 2 symbols */ |
| 1742 | f_rach_toffs(-1*256, true); |
| 1743 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1744 | f_rach_toffs(-10*256, false); |
| 1745 | |
| 1746 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1747 | f_rach_toffs(0, true); |
| 1748 | f_rach_toffs(32*256, true); |
| 1749 | f_rach_toffs(63*256, true); |
| 1750 | |
| 1751 | /* more than 63 bits is not legal / permitted */ |
| 1752 | f_rach_toffs(64*256, false); |
| 1753 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1754 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1755 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1756 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1757 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1758 | var GsmFrameNumber fn; |
| 1759 | var RSL_Message rm; |
| 1760 | |
| 1761 | f_l1_tune(L1CTL); |
| 1762 | RSL.clear; |
| 1763 | |
| 1764 | /* Generate a random Handover Reference */ |
| 1765 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1766 | |
| 1767 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1768 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1769 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1770 | |
| 1771 | /* Activate a channel on the BTS side (no encryption) */ |
| 1772 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1773 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1774 | |
| 1775 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1776 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1777 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1778 | |
| 1779 | /* Send handover Access Burst */ |
| 1780 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1781 | |
| 1782 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1783 | |
| 1784 | /* Wait for handover detection */ |
| 1785 | timer T := 3.0; |
| 1786 | T.start; |
| 1787 | alt { |
| 1788 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1789 | log("Handover RACH has been detected: ", rm); |
| 1790 | setverdict(pass); |
| 1791 | } |
| 1792 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1793 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1794 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1795 | } |
| 1796 | [] RSL.receive { repeat; } |
| 1797 | [] T.timeout { |
| 1798 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1799 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1800 | } |
| 1801 | } |
| 1802 | |
| 1803 | /* Release the channel */ |
| 1804 | f_rsl_chan_deact(); |
| 1805 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1806 | } |
| 1807 | |
| 1808 | /* Test handover RACH detection */ |
| 1809 | testcase TC_ho_rach() runs on test_CT { |
| 1810 | var ConnHdlrPars pars; |
| 1811 | var ConnHdlr vc_conn; |
| 1812 | |
| 1813 | f_init(); |
| 1814 | |
| 1815 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1816 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1817 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1818 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1819 | vc_conn.done; |
| 1820 | } |
| 1821 | |
| 1822 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1823 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1824 | } |
| 1825 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1826 | /*********************************************************************** |
| 1827 | * Measurement Processing / Reporting |
| 1828 | ***********************************************************************/ |
| 1829 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1830 | private template (value) LapdmAddressField |
| 1831 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 1832 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1833 | spare := '0'B, |
| 1834 | lpd := 0, |
| 1835 | sapi := sapi, |
| 1836 | c_r := c_r, |
| 1837 | ea := true |
| 1838 | } |
| 1839 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1840 | private template (value) LapdmFrameAB |
| 1841 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 1842 | template (value) GsmRrL3Message l3, |
| 1843 | template (value) boolean c_r := false, |
| 1844 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1845 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1846 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1847 | len := 0, /* overwritten */ |
| 1848 | m := false, |
| 1849 | el := 1, |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1850 | payload := enc_GsmRrL3Message(valueof(l3)) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1851 | } |
| 1852 | |
| 1853 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1854 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1855 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1856 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1857 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1858 | [] 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] | 1859 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 1860 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 1861 | lb := ts_LAPDm_AB(0, ts_MEAS_REP(g_pars.l1_pars.meas_valid, |
Vadim Yanitskiy | cb57c1b | 2020-11-11 20:57:15 +0700 | [diff] [blame] | 1862 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 1863 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 1864 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 1865 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1866 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1867 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1868 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1869 | g_pars.l1_pars.ms_power_level, false, |
| 1870 | g_pars.l1_pars.ms_actual_ta); |
| 1871 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 1872 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 1873 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '00'O); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1874 | |
| 1875 | log("Sending Measurement Report: ", l1h, l2); |
| 1876 | 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] | 1877 | repeat; |
| 1878 | } |
| 1879 | } |
| 1880 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 1881 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 1882 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 1883 | boolean do_apply := true) |
| 1884 | runs on ConnHdlr |
| 1885 | { |
| 1886 | var L1ctlDlMessage l1_dl; |
| 1887 | |
| 1888 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 1889 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 1890 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 1891 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 1892 | |
| 1893 | if (do_apply) { |
| 1894 | /* Update TA and MS power to follow what BTS requests */ |
| 1895 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 1896 | } |
| 1897 | } |
| 1898 | } |
| 1899 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 1900 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1901 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1902 | [] 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] | 1903 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1904 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1905 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1906 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1907 | repeat; |
| 1908 | } |
| 1909 | } |
| 1910 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1911 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 1912 | var L1ctlDlMessage l1_dl; |
| 1913 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 1914 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1915 | |
| 1916 | /* occasionaly inject FACCH frames into the uplink */ |
| 1917 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 1918 | var octetstring pl := '010301'O; |
| 1919 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1920 | f_pad_oct(pl, 23, '2B'O))); |
| 1921 | } else { |
| 1922 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 1923 | l1_dl.payload.traffic_ind.data)); |
| 1924 | } |
| 1925 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1926 | repeat; |
| 1927 | } |
| 1928 | } |
| 1929 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1930 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1931 | uint6_t rxlev, |
| 1932 | uint3_t rxqual |
| 1933 | } |
| 1934 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1935 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1936 | MeasElem full, |
| 1937 | MeasElem sub |
| 1938 | } |
| 1939 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1940 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1941 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1942 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 1943 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1944 | MeasElemFS meas_ul, |
| 1945 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1946 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1947 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1948 | uint8_t ms_actual_ta, |
| 1949 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1953 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1954 | return 63 + (toffs256s/256); |
| 1955 | } |
| 1956 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1957 | private function f_max(integer a, integer b) return integer { |
| 1958 | if (a > b) { |
| 1959 | return a; |
| 1960 | } else { |
| 1961 | return b; |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | private function f_min(integer a, integer b) return integer { |
| 1966 | if (a < b) { |
| 1967 | return a; |
| 1968 | } else { |
| 1969 | return b; |
| 1970 | } |
| 1971 | } |
| 1972 | |
| 1973 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1974 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1975 | val := val - tolerance; |
| 1976 | return f_max(val, min); |
| 1977 | } |
| 1978 | |
| 1979 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1980 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1981 | val := val + tolerance; |
| 1982 | return f_min(val, max); |
| 1983 | } |
| 1984 | |
| 1985 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1986 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1987 | return template integer { |
| 1988 | var template integer ret; |
| 1989 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1990 | return ret; |
| 1991 | } |
| 1992 | |
| 1993 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1994 | /* build a template for matching measurement results against */ |
| 1995 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1996 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1997 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1998 | len := 3, |
| 1999 | rfu := '0'B, |
| 2000 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2001 | 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] | 2002 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2003 | 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] | 2004 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2005 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2006 | 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] | 2007 | supp_meas_info := omit |
| 2008 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2009 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2010 | ul_meas.len := (3+8); |
| 2011 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2012 | 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] | 2013 | toa256_min := ?, |
| 2014 | toa256_max := ?, |
| 2015 | toa256_std_dev := ? |
| 2016 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2017 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2018 | var template RSL_IE_BS_Power bs_power := { |
| 2019 | reserved := 0, |
| 2020 | epc := false, |
| 2021 | fpc := false, |
| 2022 | power_level := l1p.bs_power_level |
| 2023 | }; |
| 2024 | var template RSL_IE_L1Info l1_info := { |
| 2025 | ms_power_lvl := l1p.ms_power_level, |
| 2026 | fpc := false, |
| 2027 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2028 | 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] | 2029 | }; |
| 2030 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2031 | 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] | 2032 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2033 | ?, t_toffs); |
| 2034 | } |
| 2035 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2036 | /* build a template for matching measurement results that do not contain any |
| 2037 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2038 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2039 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2040 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2041 | len := 3, |
| 2042 | rfu := '0'B, |
| 2043 | dtx_d := l1p.dtx_enabled, |
| 2044 | rxlev_f_u := ?, |
| 2045 | reserved1 := '00'B, |
| 2046 | rxlev_s_u := ?, |
| 2047 | reserved2 := '00'B, |
| 2048 | rxq_f_u := ?, |
| 2049 | rxq_s_u := ?, |
| 2050 | supp_meas_info := omit |
| 2051 | }; |
| 2052 | if (l1p.toa256_enabled) { |
| 2053 | ul_meas.len := (3+8); |
| 2054 | ul_meas.supp_meas_info := { |
| 2055 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2056 | toa256_min := ?, |
| 2057 | toa256_max := ?, |
| 2058 | toa256_std_dev := ? |
| 2059 | } |
| 2060 | } |
| 2061 | var template RSL_IE_BS_Power bs_power := { |
| 2062 | reserved := 0, |
| 2063 | epc := false, |
| 2064 | fpc := false, |
| 2065 | power_level := l1p.bs_power_level |
| 2066 | }; |
| 2067 | |
| 2068 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2069 | } |
| 2070 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2071 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2072 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2073 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2074 | var boolean chan_est := false; |
| 2075 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2076 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2077 | |
| 2078 | /* Receive osmocom specific measurement reports. This is the normal |
| 2079 | * case. Here we verify that the measurement reports we sent are |
| 2080 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2081 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2082 | /* increment counter of next to-be-expected meas rep */ |
| 2083 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2084 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2085 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2086 | |
| 2087 | /* The following two cases may only happen in the beginning |
| 2088 | * of the channel establishment phase. Once we have received |
| 2089 | * the "our" measurement report the first time, the channel |
| 2090 | * is established and empty or hardcoded TRXCON reports must |
| 2091 | * not occur anymore. */ |
| 2092 | chan_est := true; |
| 2093 | |
| 2094 | repeat; |
| 2095 | } |
| 2096 | |
| 2097 | /* When the BTS has established the channel, the MS might need slightly |
| 2098 | * more time to establish the channel and actually start sending. The |
| 2099 | * result is then a measurement report that just lacks the measurement |
| 2100 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2101 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2102 | /* increment counter of next to-be-expected meas rep */ |
| 2103 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2104 | /* Re-start the timer expecting the next MEAS RES */ |
| 2105 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2106 | repeat; |
| 2107 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2108 | |
| 2109 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2110 | * measurements if the TTCN3 side does not supply measurement input in |
| 2111 | * time. In those cases TRXCON will either use a cached measurement |
| 2112 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2113 | * report the templates above will not match. We tolerate this |
| 2114 | * behavior, but only once. */ |
| 2115 | [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] | 2116 | /* increment counter of next to-be-expected meas rep */ |
| 2117 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2118 | if (g_first_meas_res) { |
| 2119 | g_first_meas_res := false; |
| 2120 | repeat; |
| 2121 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2122 | 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] | 2123 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2124 | } |
| 2125 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2126 | 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] | 2127 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2128 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2129 | 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] | 2130 | } |
| 2131 | } |
| 2132 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2133 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2134 | select (rsl_alg_id) { |
| 2135 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2136 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2137 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2138 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2139 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2140 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2141 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2142 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2143 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2144 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2145 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2146 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2147 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2148 | } |
| 2149 | } |
| 2150 | } |
| 2151 | |
| 2152 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2153 | select (rsl_alg_id) { |
| 2154 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2155 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2156 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2157 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2158 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2159 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2160 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2161 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2162 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2163 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2164 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2165 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2170 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2171 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2172 | var GsmFrameNumber fn; |
| 2173 | timer T := 8.0; |
| 2174 | |
| 2175 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2176 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2177 | |
| 2178 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2179 | /* Send the actual RACH */ |
| 2180 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2181 | |
| 2182 | T.start; |
| 2183 | alt { |
| 2184 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2185 | [] T.timeout { |
| 2186 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2187 | } |
| 2188 | } |
| 2189 | T.stop |
| 2190 | return fn; |
| 2191 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2192 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2193 | /* Tune to a dedicated channel: L1CTL only */ |
| 2194 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2195 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2196 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 2197 | mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2198 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2199 | pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2200 | pars.fhp.maio_hsn.hsn, |
| 2201 | pars.fhp.maio_hsn.maio, |
| 2202 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2203 | } |
| 2204 | } |
| 2205 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2206 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2207 | 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] | 2208 | var GsmFrameNumber fn; |
| 2209 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2210 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2211 | var integer ra := 23; |
| 2212 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2213 | /* Send RACH request and wait for ChanReq */ |
| 2214 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2215 | |
| 2216 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2217 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2218 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2219 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2220 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2221 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2222 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2223 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2224 | } |
| 2225 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2226 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2227 | 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] | 2228 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 2229 | |
| 2230 | /* receive IMM.ASS on MS side */ |
| 2231 | var ImmediateAssignment ia_um; |
| 2232 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2233 | |
| 2234 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 2235 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 2236 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 2237 | } |
| 2238 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2239 | /* enable dedicated mode */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2240 | 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] | 2241 | /* enable encryption, if requested */ |
| 2242 | if (encr_enable) { |
| 2243 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2244 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2245 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2246 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2247 | /* Send TCH Mode Request to the L1 if needed */ |
| 2248 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2249 | var L1ctlTchMode tch_mode; |
| 2250 | |
| 2251 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2252 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2253 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2254 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2255 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2256 | case else { |
| 2257 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2258 | " is not supported by the L1, falling back to signalling"); |
| 2259 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2260 | } |
| 2261 | } |
| 2262 | |
| 2263 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2264 | } |
| 2265 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2266 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2270 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2271 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2272 | RSL.clear; |
| 2273 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2274 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2275 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2276 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2277 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2278 | |
| 2279 | f_est_dchan(); |
| 2280 | |
| 2281 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2282 | * RSL measurement reports on Abis side */ |
| 2283 | timer T := 8.0; |
| 2284 | T.start; |
| 2285 | alt { |
| 2286 | [] as_l1_sacch(); |
| 2287 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2288 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2289 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2290 | [] L1CTL.receive { repeat; } |
| 2291 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2292 | /* 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] | 2293 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2294 | setverdict(pass); |
| 2295 | } |
| 2296 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2297 | 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] | 2298 | } |
| 2299 | } |
| 2300 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2301 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2302 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2303 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2304 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2305 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2306 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2307 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2308 | timer Tup := 10.0; |
| 2309 | Tup.start; |
| 2310 | alt { |
| 2311 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2312 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2313 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2314 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2315 | if (rx_lvl != max_rx_lvl) { |
| 2316 | repeat; |
| 2317 | } |
| 2318 | Tup.stop; |
| 2319 | } |
| 2320 | [] L1CTL.receive { repeat; } |
| 2321 | [] Tup.timeout { |
| 2322 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2323 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2324 | } |
| 2325 | } |
| 2326 | return max_rx_lvl; |
| 2327 | } |
| 2328 | |
| 2329 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2330 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2331 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2332 | var integer initial_rx_lvl := -1; |
| 2333 | var integer last_rx_lvl := -1; |
| 2334 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2335 | |
| 2336 | timer T := 2.0; |
| 2337 | alt { |
| 2338 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2339 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2340 | log("Received rx_level=", rx_lvl); |
| 2341 | if (initial_rx_lvl == -1) { |
| 2342 | initial_rx_lvl := rx_lvl; |
| 2343 | last_rx_lvl := rx_lvl; |
| 2344 | |
| 2345 | /* Expect a somehow low value during first received messages */ |
| 2346 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2347 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2348 | log2str("Detected high initial tx power during ramp up: ", |
| 2349 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2350 | } |
| 2351 | } |
| 2352 | |
| 2353 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2354 | if (rx_lvl > max_rx_lvl) { |
| 2355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2356 | log2str("Detected Tx power higher than full power: ", |
| 2357 | rx_lvl , " > ", max_rx_lvl)); |
| 2358 | } |
| 2359 | |
| 2360 | /* Make sure it never decreases, since we are rumping up */ |
| 2361 | if (last_rx_lvl > rx_lvl) { |
| 2362 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2363 | log2str("Detected Tx power decrease during ramp up: ", |
| 2364 | last_rx_lvl , " -> ", rx_lvl)); |
| 2365 | } |
| 2366 | |
| 2367 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2368 | /* We reached the maximum power, start timer and receive |
| 2369 | /* a few more to make sure we don't surpass it */ |
| 2370 | log("Reached full power, wating a bit more until success"); |
| 2371 | T.start; |
| 2372 | } |
| 2373 | |
| 2374 | last_rx_lvl := rx_lvl; |
| 2375 | repeat; |
| 2376 | } |
| 2377 | [] L1CTL.receive { repeat; } |
| 2378 | [] T.timeout { } |
| 2379 | } |
| 2380 | |
| 2381 | /* We didn't increase tx power during ramp up */ |
| 2382 | if (initial_rx_lvl < last_rx_lvl) { |
| 2383 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2384 | } else { |
| 2385 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2386 | log2str("No Tx power increase during whole ramp up: ", |
| 2387 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2388 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2389 | } |
| 2390 | |
| 2391 | /* verify BTS ramps power down to rx_level 0 */ |
| 2392 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2393 | var L1ctlDlMessage l1_dl; |
| 2394 | var integer last_rx_lvl := max_rx_lvl; |
| 2395 | |
| 2396 | timer Tdown := 5.0; |
| 2397 | Tdown.start; |
| 2398 | alt { |
| 2399 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2400 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2401 | log("Received rx_level=", rx_lvl); |
| 2402 | |
| 2403 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2404 | if (rx_lvl > max_rx_lvl) { |
| 2405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2406 | log2str("Detected Tx power higher than full power: ", |
| 2407 | rx_lvl , " > ", max_rx_lvl)); |
| 2408 | } |
| 2409 | |
| 2410 | /* Make sure it never increases, since we are rumping down */ |
| 2411 | if (last_rx_lvl < rx_lvl) { |
| 2412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2413 | log2str("Detected Tx power increase during ramp up: ", |
| 2414 | last_rx_lvl , " -> ", rx_lvl)); |
| 2415 | } |
| 2416 | |
| 2417 | last_rx_lvl := rx_lvl; |
| 2418 | if (last_rx_lvl != 0) { |
| 2419 | repeat; |
| 2420 | } |
| 2421 | /* we reached power level 0, we are done */ |
| 2422 | Tdown.stop; |
| 2423 | } |
| 2424 | [] L1CTL.receive { repeat; } |
| 2425 | [] Tdown.timeout { } |
| 2426 | } |
| 2427 | |
| 2428 | /* We didn't increase tx power during ramp down */ |
| 2429 | if (max_rx_lvl > last_rx_lvl) { |
| 2430 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2431 | } else { |
| 2432 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2433 | log2str("No Tx power decrease during whole ramp down: ", |
| 2434 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2435 | } |
| 2436 | } |
| 2437 | |
| 2438 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2439 | 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] | 2440 | f_l1_tune(L1CTL); |
| 2441 | RSL.clear; |
| 2442 | |
| 2443 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2444 | |
| 2445 | setverdict(pass); |
| 2446 | } |
| 2447 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2448 | var ConnHdlr vc_conn; |
| 2449 | var ConnHdlrPars pars; |
| 2450 | f_init(); |
| 2451 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2452 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2453 | pcu_comp := false, trxc_comp := true); |
| 2454 | vc_conn.done; |
| 2455 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2456 | } |
| 2457 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2458 | /* 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] | 2459 | 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] | 2460 | f_connhdlr_init_vty_bsc(); |
| 2461 | |
| 2462 | f_l1_tune(L1CTL); |
| 2463 | RSL.clear; |
| 2464 | |
| 2465 | /* Wait until BTS is started and at full power */ |
| 2466 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2467 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2468 | |
| 2469 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2470 | f_verify_ramp_down(max_rx_lvl); |
| 2471 | |
| 2472 | setverdict(pass); |
| 2473 | } |
| 2474 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2475 | var ConnHdlr vc_conn; |
| 2476 | var ConnHdlrPars pars; |
| 2477 | f_init(); |
| 2478 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2479 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2480 | pcu_comp := false, trxc_comp := true); |
| 2481 | vc_conn.done; |
| 2482 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2483 | } |
| 2484 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2485 | /* Verify Tx power: |
| 2486 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2487 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2488 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2489 | 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] | 2490 | var L1ctlDlMessage l1_dl; |
| 2491 | var integer last_rx_lvl; |
| 2492 | |
| 2493 | f_connhdlr_init_vty_bsc(); |
| 2494 | |
| 2495 | f_l1_tune(L1CTL); |
| 2496 | RSL.clear; |
| 2497 | |
| 2498 | /* Wait until BTS is started and at full power */ |
| 2499 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2500 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2501 | |
| 2502 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2503 | f_vty_enter_cfg_trx(BSCVTY); |
| 2504 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2505 | last_rx_lvl := max_rx_lvl; |
| 2506 | f_verify_ramp_down(max_rx_lvl); |
| 2507 | |
| 2508 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2509 | * anymore because scheduler has stopped after ramping down */ |
| 2510 | f_sleep(2.0); |
| 2511 | L1CTL.clear; |
| 2512 | timer Tlocked := 2.0; |
| 2513 | Tlocked.start; |
| 2514 | alt { |
| 2515 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2516 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2517 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2518 | } |
| 2519 | [] L1CTL.receive { repeat; } |
| 2520 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2521 | } |
| 2522 | |
| 2523 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2524 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2525 | f_verify_ramp_up(); |
| 2526 | setverdict(pass); |
| 2527 | } |
| 2528 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2529 | var ConnHdlr vc_conn; |
| 2530 | var ConnHdlrPars pars; |
| 2531 | f_init(); |
| 2532 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2533 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2534 | pcu_comp := false, trxc_comp := true); |
| 2535 | vc_conn.done; |
| 2536 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2537 | } |
| 2538 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2539 | 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] | 2540 | timer T := 8.0; |
| 2541 | T.start; |
| 2542 | var RSL_Message rsl; |
| 2543 | alt { |
| 2544 | [] as_l1_sacch(); |
| 2545 | [] L1CTL.receive { repeat; } |
| 2546 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2547 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2548 | setverdict(pass) |
| 2549 | } else { |
| 2550 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2551 | } |
| 2552 | } |
| 2553 | [] T.timeout { |
| 2554 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2555 | } |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | /* see if the rsl meas res contains our expeced bs power level |
| 2560 | bs power set during assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2561 | 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] | 2562 | f_l1_tune(L1CTL); |
| 2563 | RSL.clear; |
| 2564 | |
| 2565 | if (mp_bts_trxc_port != -1) { |
| 2566 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2567 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2568 | } |
| 2569 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2570 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2571 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2572 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2573 | |
| 2574 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2575 | |
| 2576 | f_check_meas_bs_power_level(pwr_var); |
| 2577 | |
| 2578 | f_rsl_chan_deact(); |
| 2579 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2580 | } |
| 2581 | |
| 2582 | /* see if the rsl meas res contains our expeced bs power level |
| 2583 | bs power set after assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2584 | 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] | 2585 | f_l1_tune(L1CTL); |
| 2586 | RSL.clear; |
| 2587 | |
| 2588 | if (mp_bts_trxc_port != -1) { |
| 2589 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2590 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2591 | } |
| 2592 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2593 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2594 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2595 | |
| 2596 | f_est_dchan(); |
| 2597 | |
| 2598 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2599 | |
| 2600 | f_check_meas_bs_power_level(pwr_var); |
| 2601 | |
| 2602 | f_rsl_chan_deact(); |
| 2603 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2604 | } |
| 2605 | |
| 2606 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2607 | var ConnHdlr vc_conn; |
| 2608 | var ConnHdlrPars pars; |
| 2609 | f_init(); |
| 2610 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2611 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2612 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2613 | pcu_comp := false, trxc_comp := true); |
| 2614 | vc_conn.done; |
| 2615 | } |
| 2616 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2617 | } |
| 2618 | |
| 2619 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2620 | var ConnHdlr vc_conn; |
| 2621 | var ConnHdlrPars pars; |
| 2622 | f_init(); |
| 2623 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2624 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2625 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2626 | pcu_comp := false, trxc_comp := true); |
| 2627 | vc_conn.done; |
| 2628 | } |
| 2629 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2630 | } |
| 2631 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2632 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2633 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2634 | 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] | 2635 | 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] | 2636 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2637 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2638 | |
| 2639 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2640 | f_l1_tune(L1CTL); |
| 2641 | RSL.clear; |
| 2642 | |
| 2643 | var RSL_IE_List addl_ies; |
| 2644 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2645 | |
| 2646 | addl_ies := { |
| 2647 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2648 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2649 | }; |
| 2650 | |
| 2651 | /* establish with power parameters */ |
| 2652 | f_est_dchan(more_ies := addl_ies); |
| 2653 | |
| 2654 | /* set a high value to ensure L1 power control level increases */ |
| 2655 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2656 | |
| 2657 | timer T2 := 6.0; |
| 2658 | T2.start; |
| 2659 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2660 | [] as_l1_sacch_l1h(l1h) { |
| 2661 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2662 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2663 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2664 | T2.stop; |
| 2665 | } |
| 2666 | [] L1CTL.receive { repeat; } |
| 2667 | [] T2.timeout { |
| 2668 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2669 | "Power Level in L1 header has not increased sufficiently"); |
| 2670 | } |
| 2671 | } |
| 2672 | |
| 2673 | /* set a low value to ensure L1 power control level decreases */ |
| 2674 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2675 | |
| 2676 | timer T4 := 6.0; |
| 2677 | T4.start; |
| 2678 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2679 | [] as_l1_sacch_l1h(l1h) { |
| 2680 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2681 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2682 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2683 | T4.stop; |
| 2684 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2685 | } |
| 2686 | [] L1CTL.receive { repeat; } |
| 2687 | [] T4.timeout { |
| 2688 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2689 | "Power Level in L1 header has not decreased sufficiently"); |
| 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | f_rsl_chan_deact(); |
| 2694 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2695 | |
| 2696 | } |
| 2697 | |
| 2698 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2699 | 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] | 2700 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2701 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2702 | |
| 2703 | /* set a low value to ensure power increases */ |
| 2704 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2705 | f_l1_tune(L1CTL); |
| 2706 | RSL.clear; |
| 2707 | |
| 2708 | var RSL_IE_List addl_ies; |
| 2709 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2710 | |
| 2711 | addl_ies := { |
| 2712 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2713 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2714 | }; |
| 2715 | |
| 2716 | /* establish with power parameters */ |
| 2717 | f_est_dchan(more_ies := addl_ies); |
| 2718 | |
| 2719 | timer T1 := 10.0; |
| 2720 | T1.start; |
| 2721 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2722 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2723 | [] L1CTL.receive { repeat; } |
| 2724 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2725 | if (not isbound(l1h)) { |
| 2726 | setverdict(fail, "No SACCH blocks were received"); |
| 2727 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2728 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2729 | } |
| 2730 | } |
| 2731 | } |
| 2732 | |
| 2733 | f_rsl_chan_deact(); |
| 2734 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2735 | |
| 2736 | } |
| 2737 | |
| 2738 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2739 | private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2740 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2741 | var uint5_t pwr_var := 15; |
| 2742 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2743 | |
| 2744 | /* set a low value to ensure power increases */ |
| 2745 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2746 | f_l1_tune(L1CTL); |
| 2747 | RSL.clear; |
| 2748 | |
| 2749 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2750 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2751 | |
| 2752 | /* establish with fixed power level */ |
| 2753 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2754 | |
| 2755 | /* check our initial power level */ |
| 2756 | f_wait_for_l1_power_level(pwr_var); |
| 2757 | |
| 2758 | /* update power param to enable power loop |
| 2759 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2760 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2761 | |
| 2762 | /* wait, then check that our power level was reduced */ |
| 2763 | timer T1 := 10.0; |
| 2764 | T1.start; |
| 2765 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2766 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2767 | [] L1CTL.receive { repeat; } |
| 2768 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2769 | if (not isbound(l1h)) { |
| 2770 | setverdict(fail, "No SACCH blocks were received"); |
| 2771 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2772 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2773 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2774 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 2775 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2776 | } |
| 2777 | } |
| 2778 | } |
| 2779 | |
| 2780 | f_rsl_chan_deact(); |
| 2781 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2782 | |
| 2783 | } |
| 2784 | |
| 2785 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2786 | private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2787 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2788 | |
| 2789 | /* set a high value to ensure power decreases */ |
| 2790 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2791 | f_l1_tune(L1CTL); |
| 2792 | RSL.clear; |
| 2793 | |
| 2794 | var uint5_t pwr_var := 5; |
| 2795 | var uint5_t pwr_target_val := 15; |
| 2796 | |
| 2797 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2798 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2799 | |
| 2800 | /* establish with fixed power level */ |
| 2801 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2802 | |
| 2803 | /* check our initial power level */ |
| 2804 | f_wait_for_l1_power_level(pwr_var); |
| 2805 | |
| 2806 | /* update power param to enable power loop |
| 2807 | 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] | 2808 | 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] | 2809 | |
| 2810 | /* wait, then check that our power level was increased */ |
| 2811 | timer T1 := 10.0; |
| 2812 | T1.start; |
| 2813 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2814 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2815 | [] L1CTL.receive { repeat; } |
| 2816 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2817 | if (not isbound(l1h)) { |
| 2818 | setverdict(fail, "No SACCH blocks were received"); |
| 2819 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 2820 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2821 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2822 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2823 | } |
| 2824 | } |
| 2825 | } |
| 2826 | |
| 2827 | f_rsl_chan_deact(); |
| 2828 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2829 | |
| 2830 | } |
| 2831 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2832 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2833 | rsl chan act WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2834 | private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2835 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2836 | |
| 2837 | /* set a high value to ensure power decreases */ |
| 2838 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2839 | f_l1_tune(L1CTL); |
| 2840 | RSL.clear; |
| 2841 | |
| 2842 | var uint5_t pwr_var := 5; |
| 2843 | |
| 2844 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2845 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2846 | |
| 2847 | /* establish with fixed power level */ |
| 2848 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2849 | |
| 2850 | /* check our initial power level */ |
| 2851 | f_wait_for_l1_power_level(pwr_var); |
| 2852 | |
| 2853 | /* wait, then check that our power level did not change */ |
| 2854 | timer T1 := 10.0; |
| 2855 | T1.start; |
| 2856 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2857 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2858 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2859 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2860 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2861 | } |
| 2862 | repeat; |
| 2863 | } |
| 2864 | [] L1CTL.receive { repeat; } |
| 2865 | [] T1.timeout { setverdict(pass); } |
| 2866 | } |
| 2867 | |
| 2868 | f_rsl_chan_deact(); |
| 2869 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2870 | |
| 2871 | } |
| 2872 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2873 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2874 | ms power control WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2875 | private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2876 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2877 | |
| 2878 | /* set a high value to ensure power decreases */ |
| 2879 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2880 | f_l1_tune(L1CTL); |
| 2881 | RSL.clear; |
| 2882 | |
| 2883 | var uint5_t pwr_var := 5; |
| 2884 | |
| 2885 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2886 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2887 | |
| 2888 | /* establish with fixed power level */ |
| 2889 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2890 | |
| 2891 | /* check our initial power level */ |
| 2892 | f_wait_for_l1_power_level(pwr_var); |
| 2893 | |
| 2894 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2895 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2896 | |
| 2897 | /* wait, then check that our power level did not change */ |
| 2898 | timer T1 := 10.0; |
| 2899 | T1.start; |
| 2900 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2901 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2902 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2903 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2904 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2905 | } |
| 2906 | repeat; |
| 2907 | } |
| 2908 | [] L1CTL.receive { repeat; } |
| 2909 | [] T1.timeout { setverdict(pass); } |
| 2910 | } |
| 2911 | |
| 2912 | f_rsl_chan_deact(); |
| 2913 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2914 | |
| 2915 | } |
| 2916 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2917 | private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2918 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2919 | timer T0 := 10.0; |
| 2920 | T0.start; |
| 2921 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2922 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2923 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2924 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2925 | "Power level in L1 header != signaled (RSL) power level."); |
| 2926 | } |
| 2927 | } |
| 2928 | [] L1CTL.receive { repeat; } |
| 2929 | [] T0.timeout { |
| 2930 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2931 | "Timeout waiting for initial power level"); |
| 2932 | } |
| 2933 | } |
| 2934 | T0.stop; |
| 2935 | } |
| 2936 | |
| 2937 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2938 | var IntegerRecord min_dbm_level; |
| 2939 | var IntegerRecord max_dbm_level; |
| 2940 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2941 | |
| 2942 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2943 | if (min_dbm_level[i] == level) { |
| 2944 | return true; |
| 2945 | } |
| 2946 | } |
| 2947 | return false; |
| 2948 | } |
| 2949 | |
| 2950 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2951 | var IntegerRecord min_dbm_level; |
| 2952 | var IntegerRecord max_dbm_level; |
| 2953 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2954 | |
| 2955 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2956 | if (max_dbm_level[i] == level) { |
| 2957 | return true; |
| 2958 | } |
| 2959 | } |
| 2960 | return false; |
| 2961 | } |
| 2962 | |
| 2963 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2964 | var IntegerRecord min_dbm_level; |
| 2965 | var IntegerRecord max_dbm_level; |
| 2966 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2967 | return max_dbm_level[0]; |
| 2968 | } |
| 2969 | |
| 2970 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2971 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2972 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2973 | // 45.005 4.1.1 |
| 2974 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2975 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2976 | 2, 1, 0}; |
| 2977 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2978 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2979 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2980 | var IntegerRecord rv; |
| 2981 | |
| 2982 | select(band){ |
| 2983 | case (BtsBand_allGSM){ |
| 2984 | rv := gsm_power; |
| 2985 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2986 | max_dbm_level := {2, 1, 0}; |
| 2987 | } |
| 2988 | case("DCS1800"){ |
| 2989 | rv := dcs_power; |
| 2990 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2991 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2992 | } |
| 2993 | case("PCS1900"){ |
| 2994 | rv := pcs_power; |
| 2995 | min_dbm_level := {15}; |
| 2996 | max_dbm_level := {30}; |
| 2997 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 2998 | case else { |
| 2999 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3000 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3001 | } |
| 3002 | |
| 3003 | return rv; |
| 3004 | } |
| 3005 | |
| 3006 | 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] | 3007 | 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] | 3008 | } |
| 3009 | |
| 3010 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3011 | var ConnHdlr vc_conn; |
| 3012 | var ConnHdlrPars pars; |
| 3013 | f_init(); |
| 3014 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3015 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3016 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3017 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3018 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3019 | vc_conn.done; |
| 3020 | } |
| 3021 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3022 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3023 | } |
| 3024 | |
| 3025 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3026 | var ConnHdlr vc_conn; |
| 3027 | var ConnHdlrPars pars; |
| 3028 | f_init(); |
| 3029 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3030 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3031 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3032 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3033 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3034 | vc_conn.done; |
| 3035 | } |
| 3036 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3038 | } |
| 3039 | |
| 3040 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3041 | var ConnHdlr vc_conn; |
| 3042 | var ConnHdlrPars pars; |
| 3043 | f_init(); |
| 3044 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3045 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3046 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3047 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3048 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3049 | vc_conn.done; |
| 3050 | } |
| 3051 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3052 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3053 | } |
| 3054 | |
| 3055 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3056 | var ConnHdlr vc_conn; |
| 3057 | var ConnHdlrPars pars; |
| 3058 | f_init(); |
| 3059 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3060 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3061 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3062 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3063 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3064 | vc_conn.done; |
| 3065 | } |
| 3066 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3067 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3068 | } |
| 3069 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3070 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3071 | var ConnHdlr vc_conn; |
| 3072 | var ConnHdlrPars pars; |
| 3073 | f_init(); |
| 3074 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3075 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3076 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3077 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3078 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3079 | vc_conn.done; |
| 3080 | } |
| 3081 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3083 | } |
| 3084 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3085 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3086 | var ConnHdlr vc_conn; |
| 3087 | var ConnHdlrPars pars; |
| 3088 | f_init(); |
| 3089 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3090 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3091 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3092 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3093 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3094 | vc_conn.done; |
| 3095 | } |
| 3096 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3097 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3098 | } |
| 3099 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3100 | function f_TC_meas_res_speech_tchf(boolean facch_enabled) runs on test_CT { |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3101 | var template RSL_IE_ChannelMode ch_mode; |
| 3102 | var ConnHdlr vc_conn; |
| 3103 | var ConnHdlrPars pars; |
| 3104 | f_init(); |
| 3105 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3106 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3107 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3108 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3109 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3110 | pcu_comp := false, trxc_comp := true); |
| 3111 | vc_conn.done; |
| 3112 | } |
| 3113 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3114 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3115 | |
| 3116 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3117 | f_TC_meas_res_speech_tchf(false); |
| 3118 | } |
| 3119 | |
| 3120 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3121 | f_TC_meas_res_speech_tchf(true); |
| 3122 | } |
| 3123 | |
| 3124 | function f_TC_meas_res_speech_tchh(boolean facch_enabled) runs on test_CT { |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3125 | var template RSL_IE_ChannelMode ch_mode; |
| 3126 | var ConnHdlr vc_conn; |
| 3127 | var ConnHdlrPars pars; |
| 3128 | f_init(); |
| 3129 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3130 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3131 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3132 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3133 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3134 | pcu_comp := false, trxc_comp := true); |
| 3135 | vc_conn.done; |
| 3136 | } |
| 3137 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3138 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3139 | |
| 3140 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3141 | f_TC_meas_res_speech_tchh(false) |
| 3142 | } |
| 3143 | |
| 3144 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3145 | f_TC_meas_res_speech_tchh(true) |
| 3146 | } |
| 3147 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3148 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3149 | var template RSL_IE_ChannelMode ch_mode; |
| 3150 | var ConnHdlr vc_conn; |
| 3151 | var ConnHdlrPars pars; |
| 3152 | f_init(); |
| 3153 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3154 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3155 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3156 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3157 | pars.l1_pars.toa256_enabled := true; |
| 3158 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3159 | pcu_comp := false, trxc_comp := true); |
| 3160 | vc_conn.done; |
| 3161 | } |
| 3162 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3163 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3164 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3165 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3166 | var ConnHdlr vc_conn; |
| 3167 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3168 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3169 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3170 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_F))); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3171 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3172 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3173 | vc_conn.done; |
| 3174 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3175 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3176 | } |
| 3177 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3178 | var ConnHdlr vc_conn; |
| 3179 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3180 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3181 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3182 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H))); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 3183 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3184 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3185 | vc_conn.done; |
| 3186 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3187 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3188 | } |
| 3189 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3190 | var ConnHdlr vc_conn; |
| 3191 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3192 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3193 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3194 | 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] | 3195 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3196 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3197 | vc_conn.done; |
| 3198 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3199 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3200 | } |
| 3201 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3202 | var ConnHdlr vc_conn; |
| 3203 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3204 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3205 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3206 | 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] | 3207 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3208 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3209 | vc_conn.done; |
| 3210 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3211 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3212 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3213 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3214 | var ConnHdlr vc_conn; |
| 3215 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3216 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3217 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3218 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3219 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H))); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3220 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3221 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3222 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3223 | vc_conn.done; |
| 3224 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3226 | } |
| 3227 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3228 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3229 | * 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] | 3230 | private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3231 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3232 | var RSL_IE_MS_Power ms_power; |
| 3233 | var RSL_Message rsl; |
| 3234 | var uint5_t power_level := 0; |
| 3235 | |
| 3236 | f_l1_tune(L1CTL); |
| 3237 | RSL.clear; |
| 3238 | |
| 3239 | f_est_dchan(); |
| 3240 | |
| 3241 | ms_power.reserved := 0; |
| 3242 | ms_power.fpc_epc := false; |
| 3243 | |
| 3244 | /* Send the first power control command. This will disable any BTS/TRX |
| 3245 | * internal power control and switch the MS (which is not in scope of |
| 3246 | * this test) to a constant power level. We start with a power level |
| 3247 | * of 0 */ |
| 3248 | ms_power.power_level := power_level; |
| 3249 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3250 | RSL.send(rsl); |
| 3251 | |
| 3252 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3253 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3254 | if (l1h.ms_power_lvl != power_level) { |
| 3255 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3256 | "match the signaled (RSL) power level := ", power_level); |
| 3257 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3258 | } |
| 3259 | |
| 3260 | /* Signal a new power level via RSL for the next turn. */ |
| 3261 | if (power_level < 31) { |
| 3262 | power_level := power_level + 1; |
| 3263 | ms_power.power_level := power_level; |
| 3264 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3265 | RSL.send(rsl); |
| 3266 | repeat; |
| 3267 | } |
| 3268 | |
| 3269 | } |
| 3270 | |
| 3271 | /* Ignore all other blocks */ |
| 3272 | [] L1CTL.receive { repeat; } |
| 3273 | |
| 3274 | } |
| 3275 | |
| 3276 | f_rsl_chan_deact(); |
| 3277 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3278 | |
| 3279 | setverdict(pass); |
| 3280 | } |
| 3281 | |
| 3282 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3283 | var ConnHdlr vc_conn; |
| 3284 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3285 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3286 | |
| 3287 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3288 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3289 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3290 | vc_conn.done; |
| 3291 | } |
| 3292 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3293 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3294 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3295 | /* 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] | 3296 | 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] | 3297 | 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] | 3298 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3299 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3300 | |
| 3301 | f_l1_tune(L1CTL); |
| 3302 | RSL.clear; |
| 3303 | |
| 3304 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3305 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3306 | |
| 3307 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3308 | |
| 3309 | |
| 3310 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3311 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3312 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3313 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3314 | } |
| 3315 | |
| 3316 | } |
| 3317 | |
| 3318 | /* Ignore all other blocks */ |
| 3319 | [] L1CTL.receive { repeat; } |
| 3320 | |
| 3321 | } |
| 3322 | |
| 3323 | f_rsl_chan_deact(); |
| 3324 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3325 | |
| 3326 | setverdict(pass); |
| 3327 | } |
| 3328 | |
| 3329 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3330 | var ConnHdlr vc_conn; |
| 3331 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3332 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3333 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3334 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3335 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3336 | vc_conn.done; |
| 3337 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3338 | } |
| 3339 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3340 | /* 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] | 3341 | 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] | 3342 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3343 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3344 | |
| 3345 | var RSL_IE_MS_Power ms_power; |
| 3346 | ms_power.reserved := 0; |
| 3347 | ms_power.fpc_epc := false; |
| 3348 | ms_power.power_level := ms_power_level; |
| 3349 | |
| 3350 | f_l1_tune(L1CTL); |
| 3351 | RSL.clear; |
| 3352 | |
| 3353 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3354 | |
| 3355 | timer T := 1.0; |
| 3356 | T.start; |
| 3357 | alt { |
| 3358 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3359 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3360 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3361 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3362 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3363 | } |
| 3364 | } |
| 3365 | /* Ignore all other blocks */ |
| 3366 | [] L1CTL.receive { repeat; } |
| 3367 | [] T.timeout { |
| 3368 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3369 | } |
| 3370 | } |
| 3371 | |
| 3372 | f_rsl_chan_deact(); |
| 3373 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3374 | setverdict(pass); |
| 3375 | } |
| 3376 | |
| 3377 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3378 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3379 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3380 | } |
| 3381 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3382 | /* 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] | 3383 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3384 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3385 | RSL.clear; |
| 3386 | |
| 3387 | f_est_dchan(); |
| 3388 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3389 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3390 | |
| 3391 | timer T := 40.0; |
| 3392 | T.start; |
| 3393 | alt { |
| 3394 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3395 | setverdict(pass) |
| 3396 | } |
| 3397 | [] RSL.receive { repeat }; |
| 3398 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3399 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3400 | } |
| 3401 | } |
| 3402 | f_rsl_chan_deact(); |
| 3403 | } |
| 3404 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3405 | var ConnHdlr vc_conn; |
| 3406 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3407 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3408 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3409 | pars.t_guard := 60.0; |
| 3410 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3411 | vc_conn.done; |
| 3412 | } |
| 3413 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3414 | /*********************************************************************** |
| 3415 | * Paging |
| 3416 | ***********************************************************************/ |
| 3417 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3418 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3419 | if (tmsi == 'FFFFFFFF'O) { |
| 3420 | return true; |
| 3421 | } else { |
| 3422 | return false; |
| 3423 | } |
| 3424 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3425 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3426 | private type record allowedFn { integer frame_nr } |
| 3427 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3428 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3429 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3430 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3431 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3432 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3433 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3434 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3435 | 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] | 3436 | { |
| 3437 | var integer frame_nr_51; |
| 3438 | frame_nr_51 := frame_nr mod 51 |
| 3439 | |
| 3440 | var allowedFn fn_check; |
| 3441 | fn_check.frame_nr := frame_nr_51; |
| 3442 | |
| 3443 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3444 | 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] | 3445 | return; |
| 3446 | } |
| 3447 | |
| 3448 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3449 | return; |
| 3450 | } |
| 3451 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3452 | return; |
| 3453 | } |
| 3454 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3455 | return; |
| 3456 | } |
| 3457 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3458 | return; |
| 3459 | } |
| 3460 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3461 | return; |
| 3462 | } |
| 3463 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3464 | return; |
| 3465 | } |
| 3466 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3467 | return; |
| 3468 | } |
| 3469 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3470 | return; |
| 3471 | } |
| 3472 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3473 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3474 | return; |
| 3475 | } |
| 3476 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3477 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3478 | inout integer num_paging_rcv_ids, |
| 3479 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3480 | runs on test_CT { |
| 3481 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3482 | [] 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] | 3483 | repeat; |
| 3484 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3485 | [] 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] | 3486 | var octetstring without_plen := |
| 3487 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3488 | 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] | 3489 | |
| 3490 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3491 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3492 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3493 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3494 | * TODO: does it make sense to count them? */ |
| 3495 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3496 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3497 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3498 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3499 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3500 | } |
| 3501 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3502 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3503 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3504 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3505 | } |
| 3506 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3507 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3508 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3509 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3510 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3511 | } |
| 3512 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3513 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3514 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3515 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3516 | } |
| 3517 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3518 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3519 | } |
| 3520 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3521 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3522 | } |
| 3523 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3524 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3525 | } |
| 3526 | } |
| 3527 | repeat; |
| 3528 | } |
| 3529 | } |
| 3530 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3531 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3532 | boolean combined_ccch, |
| 3533 | integer bs_ag_blks_res, |
| 3534 | float load_factor, |
| 3535 | boolean exp_load_ind, |
| 3536 | boolean exp_overload, |
| 3537 | boolean use_tmsi |
| 3538 | } |
| 3539 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3540 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3541 | integer num_paging_sent, |
| 3542 | integer num_paging_rcv_msgs, |
| 3543 | integer num_paging_rcv_ids, |
| 3544 | integer num_overload |
| 3545 | } |
| 3546 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3547 | /* Helper function for paging related testing */ |
| 3548 | 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] | 3549 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3550 | f_init_l1ctl(); |
| 3551 | f_l1_tune(L1CTL); |
| 3552 | |
| 3553 | var PagingTestState st := { |
| 3554 | num_paging_sent := 0, |
| 3555 | num_paging_rcv_msgs := 0, |
| 3556 | num_paging_rcv_ids := 0, |
| 3557 | num_overload := 0 |
| 3558 | }; |
| 3559 | |
| 3560 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3561 | var float max_pch_imsi_per_sec; |
| 3562 | if (cfg.use_tmsi) { |
| 3563 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3564 | } else { |
| 3565 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3566 | } |
| 3567 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3568 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3569 | var float time_total := 20.0; |
| 3570 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3571 | 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] | 3572 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3573 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3574 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3575 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3576 | timer T_itv := 0.0; |
| 3577 | T_itv.start; |
| 3578 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3579 | alt { |
| 3580 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3581 | [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] | 3582 | st.num_overload := st.num_overload + 1; |
| 3583 | repeat; |
| 3584 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3585 | [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] | 3586 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3587 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3588 | [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] | 3589 | log("Rx LOAD_IND"); |
| 3590 | /* FIXME: analyze/verify interval + contents */ |
| 3591 | repeat; |
| 3592 | } |
| 3593 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3594 | [] 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] | 3595 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3596 | [] T_itv.timeout { |
| 3597 | /* Send paging cmds based on elapsed time */ |
| 3598 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3599 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3600 | var MobileIdentityV mi; |
| 3601 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3602 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3603 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3604 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3605 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3606 | 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] | 3607 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3608 | |
| 3609 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3610 | 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] | 3611 | |
| 3612 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3613 | } |
| 3614 | if (st.num_paging_sent < pkt_total) { |
| 3615 | /* Wait for interval to next PAGING COMMAND */ |
| 3616 | var float time_now := T_total.read; |
| 3617 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3618 | if (next_sched > time_now) { |
| 3619 | T_itv.start(next_sched - time_now); |
| 3620 | } else { |
| 3621 | T_itv.start(0.0); |
| 3622 | } |
| 3623 | } else { |
| 3624 | /* We are done, no need to keep counting */ |
| 3625 | T_total.stop; |
| 3626 | } |
| 3627 | } |
| 3628 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3633 | timer T_wait := 18.0; |
| 3634 | T_wait.start; |
| 3635 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3636 | [] 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] | 3637 | [] L1CTL.receive { repeat; } |
| 3638 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3639 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3640 | [] 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] | 3641 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3642 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3643 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3644 | } |
| 3645 | |
| 3646 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3647 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3648 | return st; |
| 3649 | } |
| 3650 | |
| 3651 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3652 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3653 | * - that CCCH LOAD IND (PCH) are being generated |
| 3654 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3655 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3656 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3657 | var PagingTestCfg cfg := { |
| 3658 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3659 | 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] | 3660 | load_factor := 0.8, |
| 3661 | exp_load_ind := true, |
| 3662 | exp_overload := false, |
| 3663 | use_tmsi := false |
| 3664 | }; |
| 3665 | var PagingTestState st := f_TC_paging(cfg); |
| 3666 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3667 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3668 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3669 | } else { |
| 3670 | setverdict(pass); |
| 3671 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3672 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3673 | } |
| 3674 | |
| 3675 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3676 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3677 | * - that CCCH LOAD IND (PCH) are being generated |
| 3678 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3679 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3680 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3681 | var PagingTestCfg cfg := { |
| 3682 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3683 | 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] | 3684 | load_factor := 0.8, |
| 3685 | exp_load_ind := true, |
| 3686 | exp_overload := false, |
| 3687 | use_tmsi := true |
| 3688 | }; |
| 3689 | var PagingTestState st := f_TC_paging(cfg); |
| 3690 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3692 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3693 | } else { |
| 3694 | setverdict(pass); |
| 3695 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3696 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3697 | } |
| 3698 | |
| 3699 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3700 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3701 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3702 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3703 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3704 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3705 | var PagingTestCfg cfg := { |
| 3706 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3707 | 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] | 3708 | load_factor := 2.0, |
| 3709 | exp_load_ind := true, |
| 3710 | exp_overload := true, |
| 3711 | use_tmsi := false |
| 3712 | }; |
| 3713 | var PagingTestState st := f_TC_paging(cfg); |
| 3714 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3715 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3716 | 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] | 3717 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3718 | 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] | 3719 | } else { |
| 3720 | setverdict(pass); |
| 3721 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3722 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3723 | } |
| 3724 | |
| 3725 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3726 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3727 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3728 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3729 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3730 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3731 | var PagingTestCfg cfg := { |
| 3732 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3733 | 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] | 3734 | load_factor := 2.0, |
| 3735 | exp_load_ind := true, |
| 3736 | exp_overload := true, |
| 3737 | use_tmsi := true |
| 3738 | }; |
| 3739 | var PagingTestState st := f_TC_paging(cfg); |
| 3740 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3741 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3742 | 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] | 3743 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3744 | 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] | 3745 | } else { |
| 3746 | setverdict(pass); |
| 3747 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3748 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3749 | } |
| 3750 | |
| 3751 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3752 | /*********************************************************************** |
| 3753 | * Immediate Assignment / AGCH |
| 3754 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 3755 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3756 | len := 0, |
| 3757 | ma := ''B |
| 3758 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3759 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3760 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3761 | return int2str(num_tx) & " sent, " |
| 3762 | & int2str(num_rx) & " received, " |
| 3763 | & int2str(num_del) & " deleted"; |
| 3764 | } |
| 3765 | |
| 3766 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3767 | var L1ctlDlMessage l1_dl; |
| 3768 | timer T := 10.0; |
| 3769 | var integer num_tx := 0; |
| 3770 | var integer num_rx := 0; |
| 3771 | var integer num_del := 0; |
| 3772 | var charstring res_str; |
| 3773 | var float rx_ratio; |
| 3774 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3775 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3776 | f_init_l1ctl(); |
| 3777 | f_l1_tune(L1CTL); |
| 3778 | |
| 3779 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 3780 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 3781 | mp_trx_pars[0].arfcn, |
| 3782 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3783 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3784 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3785 | 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] | 3786 | num_tx := num_tx+1; |
| 3787 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3788 | } |
| 3789 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3790 | T.start; |
| 3791 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3792 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3793 | num_del := num_del+1; |
| 3794 | repeat; |
| 3795 | } |
| 3796 | [] RSL_CCHAN.receive { |
| 3797 | repeat; |
| 3798 | } |
| 3799 | [] 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] | 3800 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3801 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3802 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3803 | //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] | 3804 | } else { |
| 3805 | num_rx := num_rx+1; |
| 3806 | } |
| 3807 | repeat; |
| 3808 | } |
| 3809 | [] L1CTL.receive { repeat; } |
| 3810 | [] T.timeout { } |
| 3811 | } |
| 3812 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3813 | log("AGCH test: " & res_str); |
| 3814 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3815 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3816 | } |
| 3817 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3818 | 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] | 3819 | 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] | 3820 | } else { |
| 3821 | setverdict(pass); |
| 3822 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3823 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3824 | } |
| 3825 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3826 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3827 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3828 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3829 | } |
| 3830 | |
| 3831 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3832 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3833 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3834 | } |
| 3835 | |
| 3836 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3837 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3838 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3839 | } |
| 3840 | |
| 3841 | |
| 3842 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3843 | /*********************************************************************** |
| 3844 | * BCCH |
| 3845 | ***********************************************************************/ |
| 3846 | |
| 3847 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3848 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3849 | GsmFrameNumber frame_number, |
| 3850 | SystemInformation si |
| 3851 | } |
| 3852 | |
| 3853 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3854 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3855 | |
| 3856 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3857 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3858 | |
| 3859 | /* 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] | 3860 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 3861 | RrMessageType key, |
| 3862 | boolean bcch_ext := false) |
| 3863 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3864 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3865 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3866 | if (not bcch_ext and fn_mod51 == 2 or |
| 3867 | bcch_ext and fn_mod51 == 6) { |
| 3868 | if (arr[i].si.header.message_type == key) { |
| 3869 | return true; |
| 3870 | } |
| 3871 | } |
| 3872 | } |
| 3873 | return false; |
| 3874 | } |
| 3875 | |
| 3876 | /* 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] | 3877 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3878 | integer tc, RrMessageType key, |
| 3879 | boolean ext_bcch := false) |
| 3880 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3881 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3882 | 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] | 3883 | } |
| 3884 | } |
| 3885 | |
| 3886 | /* 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] | 3887 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3888 | RrMessageType key) |
| 3889 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3890 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3891 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3892 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3893 | return true; |
| 3894 | } |
| 3895 | } |
| 3896 | return false; |
| 3897 | } |
| 3898 | |
| 3899 | /* 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] | 3900 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 3901 | RrMessageType key, |
| 3902 | boolean bcch_ext := false, |
| 3903 | integer n := 1, integer m := 4) |
| 3904 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3905 | var integer count := 0; |
| 3906 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 3907 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 3908 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3909 | } |
| 3910 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3911 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3912 | if (not bcch_ext and fn_mod51 == 2 or |
| 3913 | bcch_ext and fn_mod51 == 6) { |
| 3914 | if (arr[i].si.header.message_type == key) { |
| 3915 | count := count + 1; |
| 3916 | } |
| 3917 | } |
| 3918 | } |
| 3919 | if (count >= n) { |
| 3920 | return true; |
| 3921 | } else { |
| 3922 | return false; |
| 3923 | } |
| 3924 | } |
| 3925 | |
| 3926 | /* 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] | 3927 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 3928 | integer tc, RrMessageType key, |
| 3929 | boolean ext_bcch := false, |
| 3930 | integer n, integer m) |
| 3931 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3932 | 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] | 3933 | 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] | 3934 | } |
| 3935 | } |
| 3936 | |
| 3937 | /* 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] | 3938 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 3939 | RrMessageType key, |
| 3940 | boolean bcch_ext := false) |
| 3941 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3942 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3943 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3944 | if (not bcch_ext and fn_mod51 == 2 or |
| 3945 | bcch_ext and fn_mod51 == 6) { |
| 3946 | if (arr[i].si.header.message_type != key) { |
| 3947 | return false; |
| 3948 | } |
| 3949 | } |
| 3950 | } |
| 3951 | return true; |
| 3952 | } |
| 3953 | |
| 3954 | /* 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] | 3955 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 3956 | integer tc, RrMessageType key, |
| 3957 | boolean ext_bcch := false) |
| 3958 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3959 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3960 | 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] | 3961 | } |
| 3962 | } |
| 3963 | |
| 3964 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3965 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3966 | boolean bcch_extended, |
| 3967 | boolean si1_present, |
| 3968 | boolean si2bis_present, |
| 3969 | boolean si2ter_present, |
| 3970 | boolean si2quater_present, |
| 3971 | boolean si7_present, |
| 3972 | boolean si8_present, |
| 3973 | boolean si9_present, |
| 3974 | boolean si13_present, |
| 3975 | boolean si13alt_present, |
| 3976 | boolean si15_present, |
| 3977 | boolean si16_present, |
| 3978 | boolean si17_present, |
| 3979 | boolean si2n_present, |
| 3980 | boolean si21_present, |
| 3981 | boolean si22_present |
| 3982 | } |
| 3983 | |
| 3984 | /* 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] | 3985 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 3986 | SystemInformationVectorPerTc si_per_tc) |
| 3987 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3988 | var integer i; |
| 3989 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3990 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3991 | 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] | 3992 | } |
| 3993 | } |
| 3994 | if (cfg.si1_present) { |
| 3995 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3996 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3997 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3998 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3999 | /* make sure *ALL* contain SI1 */ |
| 4000 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4001 | } |
| 4002 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4003 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4004 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4005 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4006 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4007 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4008 | |
| 4009 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4010 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4011 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4012 | * consecutive occurrences of TC = 4. */ |
| 4013 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4014 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4015 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4016 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4017 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4018 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4019 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4020 | } |
| 4021 | |
| 4022 | if (cfg.si7_present or cfg.si8_present) { |
| 4023 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4024 | * if System Information type 4 does not contain all information needed for cell |
| 4025 | * selection and reselection. */ |
| 4026 | if (not cfg.bcch_extended) { |
| 4027 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4028 | } |
| 4029 | if (cfg.si7_present) { |
| 4030 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4031 | } |
| 4032 | if (cfg.si8_present) { |
| 4033 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4034 | } |
| 4035 | } |
| 4036 | |
| 4037 | if (cfg.si2quater_present) { |
| 4038 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4039 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4040 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4041 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4042 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4043 | if (not (cfg.bcch_extended)) { |
| 4044 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4045 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4046 | } else { |
| 4047 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4048 | } |
| 4049 | } else { |
| 4050 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4051 | } |
| 4052 | } |
| 4053 | if (cfg.si9_present) { |
| 4054 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4055 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4056 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4057 | } |
| 4058 | if (cfg.si13_present) { |
| 4059 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4060 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4061 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4062 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4063 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4064 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4065 | if (not cfg.bcch_extended) { |
| 4066 | log("not-bccch-extended"); |
| 4067 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4068 | } else { |
| 4069 | log("bccch-extended"); |
| 4070 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4071 | } |
| 4072 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4073 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4074 | } |
| 4075 | } |
| 4076 | if (cfg.si16_present or cfg.si17_present) { |
| 4077 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4078 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4079 | if (cfg.si22_present) { |
| 4080 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4081 | } |
| 4082 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4083 | 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] | 4084 | } |
| 4085 | if (not cfg.bcch_extended) { |
| 4086 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4087 | } |
| 4088 | if (cfg.si16_present) { |
| 4089 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4090 | } |
| 4091 | if (cfg.si17_present) { |
| 4092 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4093 | } |
| 4094 | } |
| 4095 | |
| 4096 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4097 | * broadcast information. The frequency with which they are sent is determined by the |
| 4098 | * system operator. System Information type 9 identifies the scheduling of System |
| 4099 | * Information type 18 and 20 messages. */ |
| 4100 | |
| 4101 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4102 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4103 | * Information Type 9. */ |
| 4104 | |
| 4105 | if (cfg.si15_present) { |
| 4106 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4107 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4108 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4109 | * 4 consecutive occurrences of TC = 1. */ |
| 4110 | if (not cfg.bcch_extended) { |
| 4111 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4112 | } else { |
| 4113 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4114 | } |
| 4115 | } |
| 4116 | if (cfg.si13alt_present) { |
| 4117 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4118 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4119 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4120 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4121 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4122 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4123 | * of TC = 4. */ |
| 4124 | if (cfg.si13_present) { |
| 4125 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4126 | } |
| 4127 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4128 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4129 | } |
| 4130 | if (not cfg.bcch_extended) { |
| 4131 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4132 | } else { |
| 4133 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4134 | } |
| 4135 | } |
| 4136 | if (cfg.si2n_present) { |
| 4137 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4138 | * as determined by the system operator. In the case that the message is sent on the |
| 4139 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4140 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4141 | * consecutive occurrences of TC = 4. */ |
| 4142 | if (not cfg.bcch_extended) { |
| 4143 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4144 | } else { |
| 4145 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4146 | } |
| 4147 | } |
| 4148 | if (cfg.si21_present) { |
| 4149 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4150 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4151 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4152 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4153 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4154 | if (not cfg.bcch_extended) { |
| 4155 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4156 | } else { |
| 4157 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4158 | 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] | 4159 | 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] | 4160 | } |
| 4161 | } |
| 4162 | } |
| 4163 | if (cfg.si22_present) { |
| 4164 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4165 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4166 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4167 | * =2 and TC=6. */ |
| 4168 | if (cfg.si16_present or cfg.si17_present) { |
| 4169 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4170 | } |
| 4171 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4172 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4173 | 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] | 4174 | } |
| 4175 | if (not cfg.bcch_extended) { |
| 4176 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4177 | } else { |
| 4178 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4179 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4180 | } |
| 4181 | } |
| 4182 | } |
| 4183 | |
| 4184 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4185 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4186 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4187 | timer T := duration; |
| 4188 | var SystemInformationVectorPerTc si_per_tc; |
| 4189 | var L1ctlDlMessage l1_dl; |
| 4190 | |
| 4191 | /* initialize all per-TC vectors empty */ |
| 4192 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4193 | si_per_tc[i] := {}; |
| 4194 | } |
| 4195 | |
| 4196 | /* flush all previous L1 queued msgs */ |
| 4197 | pt.clear; |
| 4198 | |
| 4199 | T.start; |
| 4200 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4201 | [] 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] | 4202 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4203 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4204 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4205 | repeat; |
| 4206 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4207 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4208 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4209 | log("SI received at TC=", tc, ": ", sig.si); |
| 4210 | /* append to the per-TC bucket */ |
| 4211 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4212 | repeat; |
| 4213 | } |
| 4214 | [] pt.receive { repeat; } |
| 4215 | [] T.timeout { } |
| 4216 | } |
| 4217 | |
| 4218 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4219 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4220 | } |
| 4221 | log("si_per_tc=", si_per_tc); |
| 4222 | return si_per_tc; |
| 4223 | } |
| 4224 | |
| 4225 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4226 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4227 | 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] | 4228 | var SystemInformationVectorPerTc si_per_tc; |
| 4229 | f_init_l1ctl(); |
| 4230 | f_l1_tune(L1CTL); |
| 4231 | |
| 4232 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4233 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4234 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4235 | |
| 4236 | setverdict(pass); |
| 4237 | } |
| 4238 | |
| 4239 | testcase TC_si_sched_default() runs on test_CT { |
| 4240 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4241 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4242 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4243 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4244 | } |
| 4245 | |
| 4246 | testcase TC_si_sched_1() runs on test_CT { |
| 4247 | f_init(); |
| 4248 | si_cfg.si1_present := true; |
| 4249 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4250 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4251 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4255 | f_init(); |
| 4256 | si_cfg.si2bis_present := true; |
| 4257 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4258 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4259 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4260 | } |
| 4261 | |
| 4262 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4263 | f_init(); |
| 4264 | si_cfg.si2ter_present := true; |
| 4265 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4266 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4267 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4268 | } |
| 4269 | |
| 4270 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4271 | f_init(); |
| 4272 | si_cfg.si2bis_present := true; |
| 4273 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4274 | si_cfg.si2ter_present := true; |
| 4275 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4276 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4277 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4278 | } |
| 4279 | |
| 4280 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4281 | f_init(); |
| 4282 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4283 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4284 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4285 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4286 | } |
| 4287 | |
| 4288 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4289 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4290 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4291 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4292 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4293 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4294 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4295 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4299 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4300 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4301 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4302 | si_cfg.si2bis_present := true; |
| 4303 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4304 | si_cfg.si2ter_present := true; |
| 4305 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4306 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4307 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4308 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4309 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4310 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4311 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4315 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4316 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4317 | /* FIXME: enable / disable individual BCCH info */ |
| 4318 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4319 | /* expect no ERROR REPORT after either of them * |
| 4320 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4321 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4322 | } |
| 4323 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4324 | /*********************************************************************** |
| 4325 | * Low-Level Protocol Errors / ERROR REPORT |
| 4326 | ***********************************************************************/ |
| 4327 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4328 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4329 | timer T := 5.0; |
| 4330 | T.start; |
| 4331 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4332 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4333 | setverdict(pass); |
| 4334 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4335 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4336 | 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] | 4337 | } |
| 4338 | [] RSL_CCHAN.receive { |
| 4339 | repeat; |
| 4340 | } |
| 4341 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4342 | 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] | 4343 | } |
| 4344 | } |
| 4345 | } |
| 4346 | |
| 4347 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4348 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4349 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4350 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4351 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4352 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4353 | |
| 4354 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4355 | } |
| 4356 | |
| 4357 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4358 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4359 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4360 | |
| 4361 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4362 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4363 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4364 | |
| 4365 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4366 | } |
| 4367 | |
| 4368 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4369 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4370 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4371 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4372 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4373 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4374 | |
| 4375 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4376 | } |
| 4377 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4378 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4379 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4380 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4381 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4382 | RSL.send(rsl); |
| 4383 | f_rslem_unregister(0, g_chan_nr); |
| 4384 | } |
| 4385 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4386 | var ConnHdlr vc_conn; |
| 4387 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4388 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4389 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4390 | |
| 4391 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4392 | vc_conn.done; |
| 4393 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4394 | |
| 4395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4396 | } |
| 4397 | |
| 4398 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4399 | 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] | 4400 | var template (value) RSL_Message rsl_tx; |
| 4401 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4402 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4403 | RSL.send(rsl_tx); |
| 4404 | f_rslem_unregister(0, g_chan_nr); |
| 4405 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4406 | 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] | 4407 | var template (value) RSL_Message rsl_tx; |
| 4408 | /* we first have to activate the dedicated channel */ |
| 4409 | f_rsl_chan_act(g_pars.chan_mode); |
| 4410 | /* ... to then send an invalid RLL message */ |
| 4411 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4412 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4413 | RSL.send(rsl_tx); |
| 4414 | f_rslem_unregister(0, g_chan_nr); |
| 4415 | } |
| 4416 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4417 | var ConnHdlr vc_conn; |
| 4418 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4419 | var template (value) RSL_Message rsl_tx; |
| 4420 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4421 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4422 | |
| 4423 | /* Common Channel with wrong message type */ |
| 4424 | RSL_CCHAN.clear; |
| 4425 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4426 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4427 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4428 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4429 | |
| 4430 | /* TRX Management */ |
| 4431 | RSL_CCHAN.clear; |
| 4432 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4433 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4434 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4435 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4436 | |
| 4437 | /* Dedicated Channel */ |
| 4438 | RSL_CCHAN.clear; |
| 4439 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4440 | vc_conn.done; |
| 4441 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4442 | |
| 4443 | /* RLL */ |
| 4444 | RSL_CCHAN.clear; |
| 4445 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4446 | vc_conn.done; |
| 4447 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4448 | } |
| 4449 | |
| 4450 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4451 | 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] | 4452 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4453 | f_rslem_unregister(0, g_chan_nr); |
| 4454 | } |
| 4455 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4456 | var ConnHdlr vc_conn; |
| 4457 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4458 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4459 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4460 | |
| 4461 | RSL_CCHAN.clear; |
| 4462 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4463 | vc_conn.done; |
| 4464 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4465 | } |
| 4466 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4467 | /*********************************************************************** |
| 4468 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4469 | ***********************************************************************/ |
| 4470 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4471 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4472 | 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] | 4473 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4474 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4475 | } |
| 4476 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4477 | 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] | 4478 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4479 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4480 | vc_conn.done; |
| 4481 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4482 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4483 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4484 | 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] | 4485 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4486 | "IPA CRCX ACK"); |
| 4487 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4488 | "IPA CRCX NACK"); |
| 4489 | } |
| 4490 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4491 | 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] | 4492 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4493 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4494 | vc_conn.done; |
| 4495 | } |
| 4496 | |
| 4497 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4498 | 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] | 4499 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4500 | "IPA CRCX ACK"); |
| 4501 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4502 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4503 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4504 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4505 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4506 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4507 | "IPA MDCX ACK"); |
| 4508 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4509 | "IPA DLCX ACK"); |
| 4510 | } |
| 4511 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4512 | 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] | 4513 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4514 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4515 | vc_conn.done; |
| 4516 | } |
| 4517 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4518 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4519 | 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] | 4520 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4521 | "IPA CRCX ACK"); |
| 4522 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4523 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4524 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4525 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4526 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4527 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4528 | "IPA MDCX ACK"); |
| 4529 | /* Second MDCX */ |
| 4530 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4531 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4532 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4533 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4534 | "IPA MDCX ACK"); |
| 4535 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4536 | "IPA DLCX ACK"); |
| 4537 | } |
| 4538 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4539 | 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] | 4540 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4541 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4542 | vc_conn.done; |
| 4543 | } |
| 4544 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4545 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4546 | 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] | 4547 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4548 | "IPA CRCX NACK"); |
| 4549 | } |
| 4550 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4551 | var ConnHdlrPars pars; |
| 4552 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4553 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4554 | |
| 4555 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4556 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4557 | vc_conn.done; |
| 4558 | |
| 4559 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4560 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4561 | vc_conn.done; |
| 4562 | } |
| 4563 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4564 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4565 | /*********************************************************************** |
| 4566 | * PCU Socket related tests |
| 4567 | ***********************************************************************/ |
| 4568 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4569 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4570 | 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] | 4571 | runs on test_CT { |
| 4572 | timer T := 3.0; |
| 4573 | |
| 4574 | /* we don't expect any RTS.req before PDCH are active */ |
| 4575 | T.start; |
| 4576 | alt { |
| 4577 | [] 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] | 4578 | 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] | 4579 | } |
| 4580 | [] PCU.receive { repeat; } |
| 4581 | [] T.timeout { } |
| 4582 | } |
| 4583 | |
| 4584 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4585 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4586 | |
| 4587 | /* we now expect RTS.req for this timeslot (only) */ |
| 4588 | T.start; |
| 4589 | alt { |
| 4590 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4591 | setverdict(pass); |
| 4592 | } |
| 4593 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4594 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4595 | 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] | 4596 | } |
| 4597 | [] 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] | 4598 | 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] | 4599 | } |
| 4600 | [] PCU.receive { repeat; } |
| 4601 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4602 | 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] | 4603 | } |
| 4604 | [not exp_success] T.timeout { |
| 4605 | setverdict(pass); |
| 4606 | } |
| 4607 | } |
| 4608 | } |
| 4609 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4610 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4611 | 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] | 4612 | runs on test_CT { |
| 4613 | timer T := 3.0; |
| 4614 | |
| 4615 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4616 | 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] | 4617 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 4618 | * when it will actually have been executed in the BTS */ |
| 4619 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4620 | PCU.clear; |
| 4621 | /* we now expect no RTS.req for this timeslot */ |
| 4622 | T.start; |
| 4623 | alt { |
| 4624 | [] 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] | 4625 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4626 | } |
| 4627 | [] PCU.receive { repeat; } |
| 4628 | [] T.timeout { |
| 4629 | setverdict(pass); |
| 4630 | } |
| 4631 | } |
| 4632 | } |
| 4633 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4634 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4635 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4636 | map(self:PCU, system:PCU); |
| 4637 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4638 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4639 | } |
| 4640 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4641 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4642 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4643 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4644 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4645 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4646 | } |
| 4647 | |
| 4648 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4649 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4650 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4651 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4652 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4653 | } |
| 4654 | |
| 4655 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4656 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4657 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4658 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4659 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4660 | } |
| 4661 | |
| 4662 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4663 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4664 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4665 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4666 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4667 | } |
| 4668 | |
| 4669 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4670 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4671 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4672 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4673 | /* Activate PDCH */ |
| 4674 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4675 | f_sleep(1.0); |
| 4676 | /* and De-Activate again */ |
| 4677 | f_TC_pcu_deact_req(0, 0, 7); |
| 4678 | } |
| 4679 | |
| 4680 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4681 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4682 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4683 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4684 | f_TC_pcu_deact_req(0, 0, 1); |
| 4685 | } |
| 4686 | |
| 4687 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4688 | function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4689 | var PCUIF_send_data sd; |
| 4690 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4691 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4692 | |
| 4693 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4694 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4695 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4696 | T.start; |
| 4697 | alt { |
| 4698 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4699 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4700 | setverdict(pass); |
| 4701 | } else { |
| 4702 | repeat; |
| 4703 | } |
| 4704 | } |
| 4705 | [] PCU.receive { repeat; } |
| 4706 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4707 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4708 | } |
| 4709 | } |
| 4710 | } |
| 4711 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 4712 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 4713 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 4714 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 4715 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 4716 | } |
| 4717 | |
| 4718 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 4719 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 4720 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 4721 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 4722 | } |
| 4723 | |
| 4724 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4725 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4726 | const octetstring si13 := '01010203040506070909'O; |
| 4727 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 4728 | } |
| 4729 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4730 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4731 | |
| 4732 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4733 | 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] | 4734 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4735 | runs on test_CT |
| 4736 | { |
| 4737 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4738 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4739 | } |
| 4740 | |
| 4741 | /* 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] | 4742 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4743 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4744 | runs on test_CT |
| 4745 | { |
| 4746 | var PCUIF_send_data sd; |
| 4747 | |
| 4748 | timer T := 3.0; |
| 4749 | T.start; |
| 4750 | alt { |
| 4751 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4752 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4753 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4754 | sd.data.u.rts_req.fn, sapi, data); |
| 4755 | } |
| 4756 | [] PCU.receive { repeat; } |
| 4757 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4758 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4759 | } |
| 4760 | } |
| 4761 | } |
| 4762 | |
| 4763 | /* Send DATA.req on invalid BTS */ |
| 4764 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4765 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4766 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4767 | |
| 4768 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4769 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4770 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4771 | f_TfiUsfArrSet(tua, 7, 0); |
| 4772 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4773 | f_sleep(1.0); |
| 4774 | |
| 4775 | 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] | 4776 | } |
| 4777 | |
| 4778 | /* Send DATA.req on invalid TRX */ |
| 4779 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4780 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4781 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4782 | |
| 4783 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4784 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4785 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4786 | f_TfiUsfArrSet(tua, 7, 0); |
| 4787 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4788 | f_sleep(1.0); |
| 4789 | |
| 4790 | 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] | 4791 | } |
| 4792 | |
| 4793 | /* Send DATA.req on invalid timeslot */ |
| 4794 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4795 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4796 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4797 | |
| 4798 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4799 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4800 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4801 | f_TfiUsfArrSet(tua, 7, 0); |
| 4802 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4803 | f_sleep(1.0); |
| 4804 | |
| 4805 | 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] | 4806 | } |
| 4807 | |
| 4808 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4809 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4810 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4811 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4812 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4813 | f_virtphy_common(); |
| 4814 | |
| 4815 | f_TfiUsfArrSet(tua, 7, 0); |
| 4816 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4817 | f_sleep(1.0); |
| 4818 | |
| 4819 | 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] | 4820 | } |
| 4821 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4822 | 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] | 4823 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4824 | boolean wait_rts := true) |
| 4825 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4826 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4827 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4828 | |
| 4829 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4830 | if (wait_rts) { |
| 4831 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4832 | } else { |
| 4833 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4834 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4835 | |
| 4836 | T.start; |
| 4837 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4838 | [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] | 4839 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4840 | setverdict(pass); |
| 4841 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4842 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4843 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4844 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4845 | [] L1CTL.receive { |
| 4846 | repeat; |
| 4847 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4848 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4849 | setverdict(fail, "Timeout waiting for ", data); |
| 4850 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4851 | [not expect_data] T.timeout { |
| 4852 | setverdict(pass); |
| 4853 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4854 | } |
| 4855 | } |
| 4856 | |
| 4857 | private function f_disable_dynamic_ts() runs on test_CT |
| 4858 | { |
| 4859 | f_init_vty_bsc(); |
| 4860 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4861 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4862 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4863 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4864 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4865 | } |
| 4866 | |
| 4867 | private function f_virtphy_common() runs on test_CT { |
| 4868 | f_disable_dynamic_ts(); |
| 4869 | f_init_l1ctl(); |
| 4870 | f_l1_tune(L1CTL); |
| 4871 | } |
| 4872 | |
| 4873 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4874 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4875 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4876 | |
| 4877 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4878 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4879 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4880 | f_TfiUsfArrSet(tua, 7, 0); |
| 4881 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4882 | f_sleep(1.0); |
| 4883 | |
| 4884 | 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] | 4885 | } |
| 4886 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4887 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4888 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4889 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4890 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4891 | |
| 4892 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4893 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4894 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4895 | f_TfiUsfArrSet(tua, 7, 0); |
| 4896 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4897 | f_sleep(1.0); |
| 4898 | |
| 4899 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4900 | } |
| 4901 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4902 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4903 | runs on test_CT { |
| 4904 | var template PCUIF_Message pcu_rach_ind; |
| 4905 | var PCUIF_send_data sd; |
| 4906 | var GsmFrameNumber fn; |
| 4907 | timer T; |
| 4908 | |
| 4909 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4910 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4911 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4912 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4913 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4914 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4915 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4916 | |
| 4917 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4918 | T.start(52.0 * 4.615 / 1000.0); |
| 4919 | alt { |
| 4920 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4921 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4922 | setverdict(pass); |
| 4923 | T.stop; |
| 4924 | } |
| 4925 | [] PCU.receive { repeat; } |
| 4926 | [] T.timeout { |
| 4927 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4928 | /* Keep going, that's not the end of the world */ |
| 4929 | } |
| 4930 | } |
| 4931 | } |
| 4932 | |
| 4933 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4934 | var L1ctlDlMessage dl; |
| 4935 | var octetstring data; |
| 4936 | timer T; |
| 4937 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4938 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4939 | f_init_l1ctl(); |
| 4940 | f_l1_tune(L1CTL); |
| 4941 | |
| 4942 | /* Activate PDCH channel on TS7 */ |
| 4943 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4944 | |
| 4945 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4946 | 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] | 4947 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 4948 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4949 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4950 | |
| 4951 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4952 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4953 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4954 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4955 | } |
| 4956 | |
| 4957 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4958 | data := f_rnd_octstring(23); |
| 4959 | |
| 4960 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4961 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4962 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4963 | |
| 4964 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4965 | * let's give it more time in case if we miss the beginning. */ |
| 4966 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4967 | alt { |
| 4968 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4969 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4970 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4971 | frame := data)) -> value dl { |
| 4972 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4973 | setverdict(pass); |
| 4974 | T.stop; |
| 4975 | } |
| 4976 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4977 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4978 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4979 | l2_data := data)) -> value dl { |
| 4980 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4981 | setverdict(pass); |
| 4982 | T.stop; |
| 4983 | } |
| 4984 | [] L1CTL.receive { repeat; } |
| 4985 | [] T.timeout { |
| 4986 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4987 | } |
| 4988 | } |
| 4989 | } |
| 4990 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4991 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4992 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4993 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 4994 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4995 | f_init_l1ctl(); |
| 4996 | f_l1_tune(L1CTL); |
| 4997 | |
| 4998 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4999 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5000 | |
| 5001 | T.start; |
| 5002 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5003 | [] 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] | 5004 | setverdict(pass); |
| 5005 | } |
| 5006 | [] L1CTL.receive { repeat; } |
| 5007 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5008 | 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] | 5009 | } |
| 5010 | } |
| 5011 | } |
| 5012 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5013 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5014 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5015 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5016 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5017 | f_init_l1ctl(); |
| 5018 | f_l1_tune(L1CTL); |
| 5019 | |
| 5020 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5021 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5022 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5023 | |
| 5024 | T.start; |
| 5025 | alt { |
| 5026 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5027 | setverdict(pass); |
| 5028 | } |
| 5029 | [] L1CTL.receive { repeat; } |
| 5030 | [] T.timeout { |
| 5031 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5032 | } |
| 5033 | } |
| 5034 | } |
| 5035 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5036 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5037 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5038 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5039 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5040 | f_init_l1ctl(); |
| 5041 | f_l1_tune(L1CTL); |
| 5042 | |
| 5043 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5044 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5045 | |
| 5046 | timer T := 0.5; |
| 5047 | T.start; |
| 5048 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5049 | [] 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] | 5050 | /* TODO: verify paging group */ |
| 5051 | setverdict(pass); |
| 5052 | } |
| 5053 | [] L1CTL.receive { repeat; } |
| 5054 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5055 | 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] | 5056 | } |
| 5057 | } |
| 5058 | } |
| 5059 | |
| 5060 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5061 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5062 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5063 | f_init_l1ctl(); |
| 5064 | f_l1_tune(L1CTL); |
| 5065 | |
| 5066 | var GsmFrameNumber fn_last := 0; |
| 5067 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5068 | var OCT1 ra := f_rnd_ra_ps(); |
| 5069 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5070 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5071 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5072 | } |
| 5073 | fn_last := fn; |
| 5074 | |
| 5075 | timer T := 2.0; |
| 5076 | T.start; |
| 5077 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5078 | [] 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] | 5079 | T.stop; |
| 5080 | } |
| 5081 | [] 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] | 5082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5083 | } |
| 5084 | [] PCU.receive { repeat; } |
| 5085 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5086 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5087 | } |
| 5088 | } |
| 5089 | } |
| 5090 | setverdict(pass); |
| 5091 | } |
| 5092 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5093 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5094 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5095 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5096 | var template PCUIF_Message pcu_rach_ind; |
| 5097 | var GsmFrameNumber fn_last := 0; |
| 5098 | var L1ctlRachSynchSeq synch_seq; |
| 5099 | var PCUIF_BurstType pcu_bt; |
| 5100 | var GsmFrameNumber fn; |
| 5101 | var BIT11 ra11; |
| 5102 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5103 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5104 | f_init_l1ctl(); |
| 5105 | f_l1_tune(L1CTL); |
| 5106 | |
| 5107 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5108 | /* We need to test both TS1 & TS2 */ |
| 5109 | if (i rem 2 == 0) { |
| 5110 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5111 | pcu_bt := BURST_TYPE_1; |
| 5112 | } else { |
| 5113 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5114 | pcu_bt := BURST_TYPE_2; |
| 5115 | } |
| 5116 | |
| 5117 | ra11 := f_rnd_ra11_ps(); |
| 5118 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5119 | if (fn == fn_last) { |
| 5120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5121 | "Two RACH in same FN?!?"); |
| 5122 | } |
| 5123 | fn_last := fn; |
| 5124 | |
| 5125 | /* Compose the expected message */ |
| 5126 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5127 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5128 | ra := bit2int(ra11), |
| 5129 | is_11bit := 1, |
| 5130 | burst_type := pcu_bt, |
| 5131 | fn := fn); |
| 5132 | |
| 5133 | timer T := 2.0; |
| 5134 | T.start; |
| 5135 | alt { |
| 5136 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5137 | T.stop; |
| 5138 | } |
| 5139 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5140 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5141 | } |
| 5142 | [] PCU.receive { repeat; } |
| 5143 | [] T.timeout { |
| 5144 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5145 | } |
| 5146 | } |
| 5147 | } |
| 5148 | setverdict(pass); |
| 5149 | } |
| 5150 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5151 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5152 | runs on test_CT { |
| 5153 | var template PCUIF_send_data sdt; |
| 5154 | var PCUIF_send_data sd; |
| 5155 | var int16_t lqual_cb; |
| 5156 | timer T := 1.0; |
| 5157 | |
| 5158 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5159 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5160 | |
| 5161 | /* Send a random PDTCH frame over Um */ |
| 5162 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5163 | '0000'O & f_rnd_octstring(21))); |
| 5164 | |
| 5165 | T.start; |
| 5166 | alt { |
| 5167 | /* If expected link quality is above the threshold */ |
| 5168 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5169 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5170 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5171 | |
| 5172 | /* Make sure the actual link quality matches the expected value */ |
| 5173 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5174 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5175 | "expected value ", lqual_cb_exp)); |
| 5176 | } else { |
| 5177 | setverdict(pass); |
| 5178 | } |
| 5179 | } |
| 5180 | /* If expected link quality is below the threshold */ |
| 5181 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5182 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5183 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5184 | } |
| 5185 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5186 | [] PCU.receive { repeat; } |
| 5187 | [lqual_cb_exp < thresh] T.timeout { |
| 5188 | log("Rx nothing, as expected"); |
| 5189 | setverdict(pass); |
| 5190 | } |
| 5191 | [lqual_cb_exp >= thresh] T.timeout { |
| 5192 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5193 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5194 | } |
| 5195 | } |
| 5196 | } |
| 5197 | |
| 5198 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5199 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5200 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5201 | PCU.clear; |
| 5202 | |
| 5203 | f_init_l1ctl(); |
| 5204 | f_l1_tune(L1CTL); |
| 5205 | |
| 5206 | /* Activate a PDCH channel on TS7 */ |
| 5207 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5208 | |
| 5209 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5210 | 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] | 5211 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5212 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5213 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5214 | |
| 5215 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5216 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5217 | var TrxcMessage ret; |
| 5218 | |
| 5219 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 5220 | valueof(ts_TRXC_FAKE_CI(i))); |
| 5221 | |
| 5222 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5223 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5224 | } |
| 5225 | } |
| 5226 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5227 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5228 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5229 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5230 | |
| 5231 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5232 | var MobileIdentityLV mi_lv; |
| 5233 | var octetstring mi_lv_enc; |
| 5234 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5235 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5236 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5237 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5238 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5239 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5240 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5241 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5242 | |
| 5243 | /* Fancy encoding for PCUIF */ |
| 5244 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5245 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5246 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5247 | |
| 5248 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5249 | 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] | 5250 | T.start; |
| 5251 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5252 | [] 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] | 5253 | } |
| 5254 | [] 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] | 5255 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5256 | } |
| 5257 | [] PCU.receive { repeat; } |
| 5258 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5259 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5260 | } |
| 5261 | } |
| 5262 | } |
| 5263 | setverdict(pass); |
| 5264 | } |
| 5265 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5266 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5267 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5268 | var PCUIF_send_data pcu_sd; |
| 5269 | var integer num_time_ind := 0; |
| 5270 | var integer first_fn, last_fn; |
| 5271 | var float test_duration := 5.0; |
| 5272 | timer T; |
| 5273 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5274 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5275 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5276 | |
| 5277 | PCU.clear; |
| 5278 | T.start(test_duration); |
| 5279 | alt { |
| 5280 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5281 | num_time_ind := num_time_ind + 1; |
| 5282 | if (not isbound(first_fn)) { |
| 5283 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5284 | } |
| 5285 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5286 | repeat; |
| 5287 | } |
| 5288 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5289 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5290 | repeat; |
| 5291 | } |
| 5292 | [] PCU.receive { |
| 5293 | repeat; |
| 5294 | } |
| 5295 | [] T.timeout {} |
| 5296 | } |
| 5297 | var integer fn_expired := last_fn - first_fn; |
| 5298 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5299 | |
| 5300 | /* verify the number of frames expired matches our expectation */ |
| 5301 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5302 | 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] | 5303 | 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] | 5304 | if (not match(fn_expired, t_fn_expected)) { |
| 5305 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5306 | } |
| 5307 | |
| 5308 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5309 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5310 | /* Add some tolerance */ |
| 5311 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5312 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5313 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5314 | } |
| 5315 | |
| 5316 | setverdict(pass); |
| 5317 | } |
| 5318 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5319 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5320 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5321 | var PCUIF_send_data pcu_sd; |
| 5322 | var integer first_fn, last_fn; |
| 5323 | var integer num_rts_pdtch := 0; |
| 5324 | var integer num_rts_ptcch := 0; |
| 5325 | var float test_duration := 5.0; |
| 5326 | timer T; |
| 5327 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5328 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5329 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5330 | |
| 5331 | PCU.clear; |
| 5332 | T.start(test_duration); |
| 5333 | alt { |
| 5334 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5335 | -> value pcu_sd { |
| 5336 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5337 | if (not isbound(first_fn)) { |
| 5338 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5339 | } |
| 5340 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5341 | repeat; |
| 5342 | } |
| 5343 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5344 | -> value pcu_sd { |
| 5345 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5346 | if (not isbound(first_fn)) { |
| 5347 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5348 | } |
| 5349 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5350 | repeat; |
| 5351 | } |
| 5352 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5353 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5354 | repeat; |
| 5355 | } |
| 5356 | [] PCU.receive { |
| 5357 | repeat; |
| 5358 | } |
| 5359 | [] T.timeout {} |
| 5360 | } |
| 5361 | var integer fn_expired := last_fn - first_fn; |
| 5362 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5363 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5364 | |
| 5365 | /* verify the number of frames expired matches our expectation */ |
| 5366 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5367 | 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] | 5368 | 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] | 5369 | if (not match(fn_expired, t_fn_expected)) { |
| 5370 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5371 | } |
| 5372 | |
| 5373 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5374 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5375 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5376 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5377 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5378 | t_ptcch_exp); |
| 5379 | } |
| 5380 | |
| 5381 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5382 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5383 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5384 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5385 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5386 | t_pdtch_exp); |
| 5387 | } |
| 5388 | |
| 5389 | setverdict(pass); |
| 5390 | } |
| 5391 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5392 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5393 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5394 | var PCUIF_send_data pcu_sd; |
| 5395 | var integer num_time_ind := 0; |
| 5396 | var integer first_fn, last_fn; |
| 5397 | var float test_duration := 5.0; |
| 5398 | timer T; |
| 5399 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5400 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5401 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5402 | |
| 5403 | /* re-connect CTRL port from BTS to BSC */ |
| 5404 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 5405 | f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5406 | |
| 5407 | /* Send that OML Alert */ |
| 5408 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5409 | |
| 5410 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5411 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5412 | setverdict(pass); |
| 5413 | } |
| 5414 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5415 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5416 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5417 | var PCUIF_Message first_info; |
| 5418 | var integer pcu_conn_id := -1; |
| 5419 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5420 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5421 | var OCT4 tlli := '01020304'O; |
| 5422 | var OCT1 cause := '23'O; |
| 5423 | timer T := 5.0; |
| 5424 | |
| 5425 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5426 | |
| 5427 | f_l1_tune(L1CTL); |
| 5428 | RSL.clear; |
| 5429 | |
| 5430 | f_est_dchan(); |
| 5431 | L1CTL.clear; |
| 5432 | |
| 5433 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5434 | |
| 5435 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5436 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5437 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5438 | |
| 5439 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5440 | T.start; |
| 5441 | alt { |
| 5442 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5443 | setverdict(pass); |
| 5444 | } |
| 5445 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5446 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5447 | } |
| 5448 | [] PCU.receive { |
| 5449 | repeat; |
| 5450 | } |
| 5451 | [] T.timeout { |
| 5452 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5453 | } |
| 5454 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5455 | |
| 5456 | /* release the channel */ |
| 5457 | f_rsl_chan_deact(); |
| 5458 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5459 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5460 | } |
| 5461 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5462 | var ConnHdlrPars pars; |
| 5463 | var ConnHdlr vc_conn; |
| 5464 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5465 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5466 | |
| 5467 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5468 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5469 | vc_conn.done; |
| 5470 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5471 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5472 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5473 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5474 | var boolean connected := false; |
| 5475 | var UD_connect_result cr; |
| 5476 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5477 | timer T := 5.0; |
| 5478 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5479 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 5480 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 5481 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5482 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5483 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5484 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5485 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5486 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5487 | T.start; |
| 5488 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5489 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 5490 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 5491 | log("BTS has accept()ed connection"); |
| 5492 | connected := true; |
| 5493 | cid := cr.id; |
| 5494 | repeat; |
| 5495 | } |
| 5496 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 5497 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5498 | setverdict(pass); |
| 5499 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5500 | /* ignore other messages related to the first connection */ |
| 5501 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5502 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5503 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5504 | } |
| 5505 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 5506 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5507 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5508 | } |
| 5509 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5510 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5511 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5512 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5513 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5514 | |
| 5515 | f_sleep(1.0); |
| 5516 | |
| 5517 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5518 | g_pcu_conn_id := -1; |
| 5519 | |
| 5520 | f_sleep(1.0); |
| 5521 | |
| 5522 | /* re-connect */ |
| 5523 | PCU.clear; |
| 5524 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5525 | setverdict(pass); |
| 5526 | |
| 5527 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5528 | } |
| 5529 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5530 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5531 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5532 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5533 | var L1ctlDlMessage l1_dl; |
| 5534 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5535 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5536 | timer T := 5.0; |
| 5537 | T.start; |
| 5538 | alt { |
| 5539 | [] 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] | 5540 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 5541 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5542 | repeat; |
| 5543 | } |
| 5544 | } |
| 5545 | [] pt.receive { |
| 5546 | repeat; |
| 5547 | } |
| 5548 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5550 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5551 | } |
| 5552 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5553 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5554 | } |
| 5555 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5556 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5557 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5558 | runs on test_CT return boolean { |
| 5559 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5560 | |
| 5561 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5562 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5563 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5564 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5565 | } |
| 5566 | |
| 5567 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5568 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5569 | } |
| 5570 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5571 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5572 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5573 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5574 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5575 | f_init_l1ctl(); |
| 5576 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5577 | f_sleep(2.0); |
| 5578 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5579 | |
| 5580 | if (f_si_has_gprs_indicator(si_type)) { |
| 5581 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5582 | } else { |
| 5583 | setverdict(pass); |
| 5584 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5585 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5586 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5587 | } |
| 5588 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5589 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5590 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5591 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5592 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5593 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5594 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5595 | } |
| 5596 | |
| 5597 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5598 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5599 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5600 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5601 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5602 | f_init_l1ctl(); |
| 5603 | f_l1_tune(L1CTL); |
| 5604 | |
| 5605 | f_sleep(2.0); |
| 5606 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5607 | |
| 5608 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5609 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5610 | } else { |
| 5611 | setverdict(pass); |
| 5612 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5613 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5614 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5615 | } |
| 5616 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5617 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5618 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5619 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5620 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5621 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5622 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5623 | } |
| 5624 | |
| 5625 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5626 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5627 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5628 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5629 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5630 | f_init_l1ctl(); |
| 5631 | f_l1_tune(L1CTL); |
| 5632 | |
| 5633 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5634 | g_pcu_conn_id := -1; |
| 5635 | |
| 5636 | f_sleep(1.0); |
| 5637 | |
| 5638 | /* re-connect */ |
| 5639 | PCU.clear; |
| 5640 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5641 | |
| 5642 | f_sleep(2.0); |
| 5643 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5644 | |
| 5645 | if (f_si_has_gprs_indicator(si_type)) { |
| 5646 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5647 | } else { |
| 5648 | setverdict(pass); |
| 5649 | } |
| 5650 | |
| 5651 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5652 | } |
| 5653 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5654 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5655 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5656 | } |
| 5657 | |
| 5658 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5659 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5660 | } |
| 5661 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5662 | /* 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) */ |
| 5663 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5664 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5665 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5666 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5667 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 5668 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 5669 | * information */ |
| 5670 | timer T := 2.0; |
| 5671 | T.start; |
| 5672 | alt { |
| 5673 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 5674 | [] T.timeout {} |
| 5675 | } |
| 5676 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5677 | /* Verify cell_id */ |
| 5678 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5679 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5680 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5681 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5682 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5683 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5684 | } |
| 5685 | |
| 5686 | /* Verify LAC */ |
| 5687 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5688 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5689 | if (lac_si3 != lac_pcu) { |
| 5690 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5691 | } |
| 5692 | |
| 5693 | setverdict(pass); |
| 5694 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5695 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5696 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 5697 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 5698 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5699 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5700 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5701 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5702 | |
| 5703 | info_ind := g_pcu_last_info.u.info_ind; |
| 5704 | |
| 5705 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 5706 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5707 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5708 | /* Skip inactive timeslots */ |
| 5709 | continue; |
| 5710 | } |
| 5711 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5712 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 5713 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5714 | else |
| 5715 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5716 | |
| 5717 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5718 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5719 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5720 | hsn := fhp.maio_hsn.hsn, |
| 5721 | maio := fhp.maio_hsn.maio, |
| 5722 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 5723 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5724 | } else { |
| 5725 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 5726 | } |
| 5727 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5728 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5729 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 5730 | if (not match(ts, tr_ts)) { |
| 5731 | setverdict(fail, "Hopping parameters do not match: ", |
| 5732 | "received ", ts, " vs expected ", tr_ts); |
| 5733 | } else { |
| 5734 | setverdict(pass); |
| 5735 | } |
| 5736 | } |
| 5737 | } |
| 5738 | } |
| 5739 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5740 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5741 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 5742 | f_init_vty_bsc(); |
| 5743 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5744 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 5745 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5746 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5747 | |
| 5748 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5749 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5750 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 5751 | addr := { f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), ? } |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5752 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5753 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5754 | if (not match(remote_addr, tr_remote_addr)) { |
| 5755 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5756 | } |
| 5757 | |
| 5758 | setverdict(pass); |
| 5759 | } |
| 5760 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5761 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5762 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 5763 | f_init_vty_bsc(); |
| 5764 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 5765 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5766 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5767 | |
| 5768 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5769 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5770 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 5771 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 5772 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5773 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5774 | if (not match(remote_addr, tr_remote_addr)) { |
| 5775 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5776 | } |
| 5777 | |
| 5778 | setverdict(pass); |
| 5779 | } |
| 5780 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5781 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 5782 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 5783 | f_init_vty_bsc(); |
| 5784 | |
| 5785 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 5786 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 5787 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5788 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 5789 | |
| 5790 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 5791 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 5792 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 5793 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 5794 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5795 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5796 | |
| 5797 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 5798 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 5799 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 5800 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 5801 | addr := { |
| 5802 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 5803 | f_inet6_addr("fd00::ca:ff:ee") |
| 5804 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 5805 | }; |
| 5806 | |
| 5807 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 5808 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 5809 | if (not match(remote_addr, tr_remote_addr)) |
| 5810 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 5811 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 5812 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 5813 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 5814 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 5815 | |
| 5816 | setverdict(pass); |
| 5817 | } |
| 5818 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5819 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5820 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5821 | ***********************************************************************/ |
| 5822 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5823 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 5824 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5825 | runs on ConnHdlr { |
| 5826 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5827 | |
| 5828 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 5829 | var BIT8 pdch_mask := sd.data.u.info_ind.trx[trx_nr].pdch_mask; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5830 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 5831 | repeat; |
| 5832 | } |
| 5833 | } |
| 5834 | } |
| 5835 | |
| 5836 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5837 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5838 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5839 | PCU.clear; |
| 5840 | f_rsl_chan_act(g_pars.chan_mode); |
| 5841 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5842 | timer T_wait := 2.0; |
| 5843 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5844 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5845 | [] 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] | 5846 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5847 | [] T_wait.timeout { |
| 5848 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5849 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5850 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5851 | } |
| 5852 | /* try to activate this PDCH from the PCU point of view */ |
| 5853 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5854 | /* FIXME: is there a response? */ |
| 5855 | } |
| 5856 | |
| 5857 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5858 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5859 | /* Send RSL CHAN REL (deactivate) */ |
| 5860 | PCU.clear; |
| 5861 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5862 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5863 | timer T_wait := 2.0; |
| 5864 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5865 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5866 | [] 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] | 5867 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5868 | [] T_wait.timeout { |
| 5869 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5870 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5871 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5872 | } |
| 5873 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5874 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5875 | alt { |
| 5876 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5877 | setverdict(pass); |
| 5878 | } |
| 5879 | [] RSL.receive { repeat; } |
| 5880 | } |
| 5881 | } |
| 5882 | |
| 5883 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5884 | 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] | 5885 | var PCUIF_Message first_info; |
| 5886 | var integer ts_nr := g_chan_nr.tn; |
| 5887 | var integer trx_nr := 0; |
| 5888 | var integer bts_nr := 0; |
| 5889 | var integer pcu_conn_id := -1; |
| 5890 | |
| 5891 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5892 | |
| 5893 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5894 | f_sleep(3.0); |
| 5895 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5896 | setverdict(pass); |
| 5897 | } |
| 5898 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5899 | var ConnHdlrPars pars; |
| 5900 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5901 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5902 | |
| 5903 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5904 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5905 | vc_conn.done; |
| 5906 | } |
| 5907 | |
| 5908 | /* 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] | 5909 | 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] | 5910 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5911 | var integer pcu_conn_id := -1; |
| 5912 | |
| 5913 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5914 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5915 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5916 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5917 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5918 | setverdict(pass); |
| 5919 | } |
| 5920 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5921 | var ConnHdlrPars pars; |
| 5922 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5923 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5924 | |
| 5925 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5926 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5927 | vc_conn.done; |
| 5928 | } |
| 5929 | |
| 5930 | /* 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] | 5931 | 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] | 5932 | var PCUIF_Message first_info; |
| 5933 | var integer ts_nr := g_chan_nr.tn; |
| 5934 | var integer trx_nr := 0; |
| 5935 | var integer bts_nr := 0; |
| 5936 | var integer pcu_conn_id := -1; |
| 5937 | |
| 5938 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5939 | |
| 5940 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5941 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5942 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5943 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5944 | setverdict(pass); |
| 5945 | } |
| 5946 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5947 | var ConnHdlrPars pars; |
| 5948 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5949 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5950 | |
| 5951 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5952 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5953 | vc_conn.done; |
| 5954 | } |
| 5955 | |
| 5956 | /* 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] | 5957 | 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] | 5958 | var PCUIF_Message first_info; |
| 5959 | var integer ts_nr := g_chan_nr.tn; |
| 5960 | var integer trx_nr := 0; |
| 5961 | var integer bts_nr := 0; |
| 5962 | var integer pcu_conn_id := -1; |
| 5963 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5964 | |
| 5965 | /* register for the TCH/F channel number */ |
| 5966 | f_rslem_register(0, chan_nr); |
| 5967 | |
| 5968 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5969 | |
| 5970 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5971 | "RSL CHAN ACT"); |
| 5972 | setverdict(pass); |
| 5973 | } |
| 5974 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5975 | var ConnHdlrPars pars; |
| 5976 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5977 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5978 | |
| 5979 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5980 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5981 | vc_conn.done; |
| 5982 | } |
| 5983 | |
| 5984 | /* 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] | 5985 | 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] | 5986 | var PCUIF_Message first_info; |
| 5987 | var integer ts_nr := g_chan_nr.tn; |
| 5988 | var integer trx_nr := 0; |
| 5989 | var integer bts_nr := 0; |
| 5990 | var integer pcu_conn_id := -1; |
| 5991 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5992 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5993 | |
| 5994 | /* register for the TCH/H channel numbers */ |
| 5995 | f_rslem_register(0, chan_nr[0]); |
| 5996 | f_rslem_register(0, chan_nr[1]); |
| 5997 | |
| 5998 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5999 | |
| 6000 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6001 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6002 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6003 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6004 | setverdict(pass); |
| 6005 | } |
| 6006 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6007 | var ConnHdlrPars pars; |
| 6008 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6009 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6010 | |
| 6011 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6012 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6013 | vc_conn.done; |
| 6014 | } |
| 6015 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6016 | /*********************************************************************** |
| 6017 | * IPA Style Dynamic Timeslot Support |
| 6018 | ***********************************************************************/ |
| 6019 | |
| 6020 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6021 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6022 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6023 | PCU.clear; |
| 6024 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6025 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6026 | timer T_wait := 2.0; |
| 6027 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6028 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6029 | [] 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] | 6030 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6031 | [] T_wait.timeout { |
| 6032 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6033 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6034 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6035 | } |
| 6036 | /* try to activate this PDCH from the PCU point of view */ |
| 6037 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6038 | /* FIXME: is there a response? */ |
| 6039 | |
| 6040 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6041 | } |
| 6042 | |
| 6043 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6044 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6045 | /* Send RSL CHAN REL (deactivate) */ |
| 6046 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6047 | PCU.clear; |
| 6048 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6049 | timer T_wait := 2.0; |
| 6050 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6051 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6052 | [] 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] | 6053 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6054 | [] T_wait.timeout { |
| 6055 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6056 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6057 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6058 | } |
| 6059 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6060 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6061 | alt { |
| 6062 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6063 | setverdict(pass); |
| 6064 | } |
| 6065 | [] RSL.receive { repeat; } |
| 6066 | } |
| 6067 | } |
| 6068 | |
| 6069 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6070 | 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] | 6071 | var PCUIF_Message first_info; |
| 6072 | var integer ts_nr := g_chan_nr.tn; |
| 6073 | var integer trx_nr := 0; |
| 6074 | var integer bts_nr := 0; |
| 6075 | var integer pcu_conn_id := -1; |
| 6076 | |
| 6077 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6078 | |
| 6079 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6080 | f_sleep(3.0); |
| 6081 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6082 | |
| 6083 | setverdict(pass); |
| 6084 | |
| 6085 | } |
| 6086 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6087 | var ConnHdlrPars pars; |
| 6088 | var ConnHdlr vc_conn; |
| 6089 | f_init(); |
| 6090 | |
| 6091 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6092 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6093 | vc_conn.done; |
| 6094 | } |
| 6095 | |
| 6096 | /* 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] | 6097 | 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] | 6098 | var PCUIF_Message first_info; |
| 6099 | var integer ts_nr := g_chan_nr.tn; |
| 6100 | var integer trx_nr := 0; |
| 6101 | var integer bts_nr := 0; |
| 6102 | var integer pcu_conn_id := -1; |
| 6103 | |
| 6104 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6105 | |
| 6106 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6107 | "RSL CHAN ACT"); |
| 6108 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6109 | "RF CHAN REL", true); |
| 6110 | setverdict(pass); |
| 6111 | } |
| 6112 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6113 | var ConnHdlrPars pars; |
| 6114 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6115 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6116 | |
| 6117 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6118 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6119 | vc_conn.done; |
| 6120 | } |
| 6121 | |
| 6122 | /* 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] | 6123 | 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] | 6124 | var PCUIF_Message first_info; |
| 6125 | var integer ts_nr := g_chan_nr.tn; |
| 6126 | var integer trx_nr := 0; |
| 6127 | var integer bts_nr := 0; |
| 6128 | var integer pcu_conn_id := -1; |
| 6129 | |
| 6130 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6131 | |
| 6132 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6133 | "RSL CHAN ACT"); |
| 6134 | |
| 6135 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6136 | alt { |
| 6137 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6138 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6139 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6140 | } |
| 6141 | [] RSL.receive { repeat; } |
| 6142 | } |
| 6143 | |
| 6144 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6145 | "RF CHAN REL", true); |
| 6146 | setverdict(pass); |
| 6147 | } |
| 6148 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6149 | var ConnHdlrPars pars; |
| 6150 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6151 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6152 | |
| 6153 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6154 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 6155 | vc_conn.done; |
| 6156 | } |
| 6157 | |
| 6158 | /* 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] | 6159 | 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] | 6160 | var PCUIF_Message first_info; |
| 6161 | var integer ts_nr := g_chan_nr.tn; |
| 6162 | var integer trx_nr := 0; |
| 6163 | var integer bts_nr := 0; |
| 6164 | var integer pcu_conn_id := -1; |
| 6165 | |
| 6166 | /* register for the TCH/F channel number */ |
| 6167 | f_rslem_register(0, g_chan_nr); |
| 6168 | |
| 6169 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6170 | |
| 6171 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6172 | |
| 6173 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6174 | "RSL CHAN ACT"); |
| 6175 | |
| 6176 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6177 | |
| 6178 | setverdict(pass); |
| 6179 | } |
| 6180 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6181 | var ConnHdlrPars pars; |
| 6182 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6183 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6184 | |
| 6185 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6186 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6187 | vc_conn.done; |
| 6188 | } |
| 6189 | |
| 6190 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6191 | /*********************************************************************** |
| 6192 | * LAPDm / RLL related |
| 6193 | ***********************************************************************/ |
| 6194 | |
| 6195 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6196 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6197 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6198 | var template (value) SacchL1Header l1h; |
| 6199 | |
| 6200 | /* 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] | 6201 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6202 | /* Compose dummy L1 header */ |
| 6203 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 6204 | 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] | 6205 | } else { |
| 6206 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6207 | 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] | 6208 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6209 | } |
| 6210 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6211 | private type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6212 | uint3_t sapi, |
| 6213 | RslLinkId link_id, |
| 6214 | octetstring l3, |
| 6215 | boolean exp |
| 6216 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6217 | private type record of RllTestCase RllTestCases; |
| 6218 | private template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, |
| 6219 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6220 | sapi := sapi, |
| 6221 | link_id := id, |
| 6222 | l3 := l3, |
| 6223 | exp := exp |
| 6224 | } |
| 6225 | |
| 6226 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6227 | * variety of logical channels */ |
| 6228 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6229 | var ConnHdlrPars pars; |
| 6230 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6231 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6232 | |
| 6233 | /* test on each of the channels we have */ |
| 6234 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6235 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6236 | |
| 6237 | /* test each of the test cases on the current channel */ |
| 6238 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6239 | pars.spec.rll := tcs[j]; |
| 6240 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6241 | vc_conn := f_start_handler(fn, pars); |
| 6242 | vc_conn.done; |
| 6243 | } |
| 6244 | } |
| 6245 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6247 | } |
| 6248 | |
| 6249 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6250 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6251 | var RllTestCase tc := g_pars.spec.rll; |
| 6252 | timer T := 3.0; |
| 6253 | |
| 6254 | f_l1_tune(L1CTL); |
| 6255 | RSL.clear; |
| 6256 | |
| 6257 | /* activate the logical channel */ |
| 6258 | f_est_dchan(); |
| 6259 | L1CTL.clear; |
| 6260 | |
| 6261 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6262 | T.start; |
| 6263 | alt { |
| 6264 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6265 | if (tc.exp) { |
| 6266 | setverdict(pass); |
| 6267 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6268 | 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] | 6269 | } |
| 6270 | } |
| 6271 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6272 | if (tc.exp) { |
| 6273 | setverdict(pass); |
| 6274 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6275 | 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] | 6276 | } |
| 6277 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6278 | /* We also expect to receive the measurements */ |
| 6279 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6280 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6281 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6282 | } |
| 6283 | [not tc.exp] T.timeout { |
| 6284 | setverdict(pass); |
| 6285 | } |
| 6286 | } |
| 6287 | |
| 6288 | f_rsl_chan_deact(); |
| 6289 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6290 | f_rslem_unregister(0, g_chan_nr); |
| 6291 | } |
| 6292 | testcase TC_rll_est_ind() runs on test_CT { |
| 6293 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6294 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6295 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6296 | /* normal SAPI0 establishment */ |
| 6297 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6298 | /* SAPI 3 doesn't support contention resolution */ |
| 6299 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 6300 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 6301 | /* normal SAPI3 establishment on main DCCH */ |
| 6302 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6303 | /* normal SAPI3 establishment on SACCH */ |
| 6304 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6305 | }; |
| 6306 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6307 | } |
| 6308 | |
| 6309 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6310 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6311 | var RllTestCase tc := g_pars.spec.rll; |
| 6312 | var L1ctlDlMessage dl; |
| 6313 | timer T := 3.0; |
| 6314 | |
| 6315 | f_l1_tune(L1CTL); |
| 6316 | RSL.clear; |
| 6317 | |
| 6318 | /* activate the logical channel */ |
| 6319 | f_est_dchan(); |
| 6320 | L1CTL.clear; |
| 6321 | |
| 6322 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6323 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 6324 | T.start; |
| 6325 | alt { |
| 6326 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6327 | var LapdmFrame lapdm; |
| 6328 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6329 | if (dl.dl_info.link_id.c == SACCH) { |
| 6330 | /* remove L1 header */ |
| 6331 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6332 | } |
| 6333 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6334 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 6335 | setverdict(pass); |
| 6336 | } else { |
| 6337 | repeat; |
| 6338 | } |
| 6339 | } |
| 6340 | [] L1CTL.receive { repeat; } |
| 6341 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6342 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6343 | } |
| 6344 | } |
| 6345 | |
| 6346 | f_rsl_chan_deact(); |
| 6347 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6348 | f_rslem_unregister(0, g_chan_nr); |
| 6349 | } |
| 6350 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 6351 | var RllTestCases tcs := { |
| 6352 | /* normal SAPI3 establishment on main DCCH */ |
| 6353 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 6354 | }; |
| 6355 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6356 | } |
| 6357 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 6358 | var RllTestCases tcs := { |
| 6359 | /* normal SAPI3 establishment on SACCH */ |
| 6360 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6361 | } |
| 6362 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6363 | } |
| 6364 | |
| 6365 | /* altstep to receive a LAPDm frame matching the given template */ |
| 6366 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 6367 | var L1ctlDlMessage dl; |
| 6368 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6369 | var LapdmFrame lapdm; |
| 6370 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6371 | if (dl.dl_info.link_id.c == SACCH) { |
| 6372 | /* remove L1 header */ |
| 6373 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6374 | } |
| 6375 | if (ischosen(exp.ab)) { |
| 6376 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6377 | } else if (ischosen(exp.b4)) { |
| 6378 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 6379 | } else if (ischosen(exp.bbis)) { |
| 6380 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 6381 | } |
| 6382 | log("Rx LAPDm ", lapdm); |
| 6383 | if (match(lapdm, exp)) { |
| 6384 | setverdict(pass); |
| 6385 | } else { |
| 6386 | repeat; |
| 6387 | } |
| 6388 | } |
| 6389 | [] L1CTL.receive { repeat; } |
| 6390 | } |
| 6391 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 6392 | timer T := t; |
| 6393 | T.start; |
| 6394 | alt { |
| 6395 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6396 | 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] | 6397 | } |
| 6398 | [] as_l1_exp_lapdm(exp); |
| 6399 | } |
| 6400 | } |
| 6401 | |
| 6402 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 6403 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 6404 | /* send SABM from MS -> BTS */ |
| 6405 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 6406 | /* expect RLL EST IND on Abis */ |
| 6407 | alt { |
| 6408 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 6409 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 6410 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6411 | 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] | 6412 | } |
| 6413 | [] RSL.receive { repeat; } |
| 6414 | } |
| 6415 | /* expect UA from BTS -> MS */ |
| 6416 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 6417 | } |
| 6418 | |
| 6419 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 6420 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 6421 | var RllTestCase tc := g_pars.spec.rll; |
| 6422 | |
| 6423 | f_l1_tune(L1CTL); |
| 6424 | RSL.clear; |
| 6425 | |
| 6426 | /* activate the logical channel */ |
| 6427 | f_est_dchan(); |
| 6428 | L1CTL.clear; |
| 6429 | |
| 6430 | /* first establish the link-layer */ |
| 6431 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6432 | |
| 6433 | /* then send the DISC */ |
| 6434 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 6435 | /* ... and expect the REL IND on the RSL side */ |
| 6436 | alt { |
| 6437 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 6438 | setverdict(pass); |
| 6439 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6440 | /* We also expect to receive the measurements */ |
| 6441 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6442 | } |
| 6443 | |
| 6444 | /* release the channel */ |
| 6445 | f_rsl_chan_deact(); |
| 6446 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6447 | f_rslem_unregister(0, g_chan_nr); |
| 6448 | } |
| 6449 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6450 | var RllTestCases tcs := { |
| 6451 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 6452 | }; |
| 6453 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6454 | } |
| 6455 | |
| 6456 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6457 | var RllTestCases tcs := { |
| 6458 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 6459 | }; |
| 6460 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6461 | } |
| 6462 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6463 | var RllTestCases tcs := { |
| 6464 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 6465 | }; |
| 6466 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6467 | } |
| 6468 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6469 | var RllTestCases tcs := { |
| 6470 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6471 | }; |
| 6472 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6473 | } |
| 6474 | |
| 6475 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6476 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6477 | var RllTestCase tc := g_pars.spec.rll; |
| 6478 | f_l1_tune(L1CTL); |
| 6479 | RSL.clear; |
| 6480 | |
| 6481 | /* activate the logical channel */ |
| 6482 | f_est_dchan(); |
| 6483 | L1CTL.clear; |
| 6484 | |
| 6485 | /* first establish the link-layer */ |
| 6486 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6487 | |
| 6488 | /* then send the REL REQ via RSL */ |
| 6489 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6490 | /* ... and expect the DISC on the Um side */ |
| 6491 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6492 | [] 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] | 6493 | /* FIXME: send a UA in resposne to the DISC */ |
| 6494 | } |
| 6495 | } |
| 6496 | |
| 6497 | /* release the channel */ |
| 6498 | f_rsl_chan_deact(); |
| 6499 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6500 | f_rslem_unregister(0, g_chan_nr); |
| 6501 | } |
| 6502 | testcase TC_rll_rel_req() runs on test_CT { |
| 6503 | var RllTestCases tcs := { |
| 6504 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 6505 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 6506 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6507 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6508 | }; |
| 6509 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6510 | } |
| 6511 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6512 | /* 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] | 6513 | testcase TC_rll_data_req() runs on test_CT { |
| 6514 | } |
| 6515 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6516 | /* 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] | 6517 | testcase TC_rll_data_ind() runs on test_CT { |
| 6518 | } |
| 6519 | |
| 6520 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6521 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6522 | var RllTestCase tc := g_pars.spec.rll; |
| 6523 | |
| 6524 | f_l1_tune(L1CTL); |
| 6525 | RSL.clear; |
| 6526 | |
| 6527 | f_est_dchan(); |
| 6528 | L1CTL.clear; |
| 6529 | |
| 6530 | /* Send UNITDATA REQ on RSL side */ |
| 6531 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6532 | /* Expect it to arrive on the other side */ |
| 6533 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6534 | 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] | 6535 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6536 | 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] | 6537 | } |
| 6538 | |
| 6539 | /* release the channel */ |
| 6540 | f_rsl_chan_deact(); |
| 6541 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6542 | f_rslem_unregister(0, g_chan_nr); |
| 6543 | } |
| 6544 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6545 | var octetstring l3 := f_rnd_octstring(15); |
| 6546 | var RllTestCases tcs := { |
| 6547 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6548 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6549 | }; |
| 6550 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6551 | } |
| 6552 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6553 | var octetstring l3 := f_rnd_octstring(19); |
| 6554 | var RllTestCases tcs := { |
| 6555 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6556 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6557 | }; |
| 6558 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6559 | } |
| 6560 | |
| 6561 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6562 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6563 | var RllTestCase tc := g_pars.spec.rll; |
| 6564 | |
| 6565 | f_l1_tune(L1CTL); |
| 6566 | RSL.clear; |
| 6567 | |
| 6568 | f_est_dchan(); |
| 6569 | L1CTL.clear; |
| 6570 | |
| 6571 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6572 | 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] | 6573 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6574 | alt { |
| 6575 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6576 | setverdict(pass); |
| 6577 | } |
| 6578 | [] RSL.receive { repeat; } |
| 6579 | } |
| 6580 | |
| 6581 | /* release the channel */ |
| 6582 | f_rsl_chan_deact(); |
| 6583 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6584 | f_rslem_unregister(0, g_chan_nr); |
| 6585 | } |
| 6586 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6587 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6588 | var RllTestCases tcs := { |
| 6589 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6590 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6591 | }; |
| 6592 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6593 | } |
| 6594 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6595 | var octetstring l3 := f_rnd_octstring(18); |
| 6596 | var RllTestCases tcs := { |
| 6597 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6598 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6599 | }; |
| 6600 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6601 | } |
| 6602 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6603 | /*********************************************************************** |
| 6604 | * Encryption Related |
| 6605 | ***********************************************************************/ |
| 6606 | |
| 6607 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6608 | 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] | 6609 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6610 | if (link_id.c == SACCH) { |
| 6611 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6612 | } else { |
| 6613 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6614 | } |
| 6615 | } |
| 6616 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6617 | /* Expect (or not expect) other kinds of messages */ |
| 6618 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6619 | [exp_any] RSL.receive { repeat; } |
| 6620 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6621 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6622 | } |
| 6623 | } |
| 6624 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6625 | /* 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] | 6626 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6627 | RslLinkId link_id, |
| 6628 | octetstring l3, |
| 6629 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6630 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6631 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6632 | timer T := 3.0; |
| 6633 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6634 | T.start; |
| 6635 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6636 | alt { |
| 6637 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6638 | setverdict(pass); |
| 6639 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6640 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6641 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6642 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6643 | 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] | 6644 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6645 | } |
| 6646 | } |
| 6647 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6648 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6649 | private function f_data_mo( |
| 6650 | RslLinkId link_id, |
| 6651 | boolean p, uint3_t nr, uint3_t ns, |
| 6652 | octetstring l3, |
| 6653 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6654 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6655 | ) runs on ConnHdlr { |
| 6656 | timer T := 3.0; |
| 6657 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6658 | T.start; |
| 6659 | /* Expect RLL DATA IND on RSL side */ |
| 6660 | alt { |
| 6661 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6662 | setverdict(pass); |
| 6663 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6664 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6665 | [] as_rsl_any_ind(exp_any); |
| 6666 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6667 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6668 | } |
| 6669 | } |
| 6670 | } |
| 6671 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6672 | /* 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] | 6673 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6674 | f_l1_tune(L1CTL); |
| 6675 | f_est_dchan(true); |
| 6676 | |
| 6677 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6678 | var L1ctlDlMessage dl; |
| 6679 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6680 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6681 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6682 | |
| 6683 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6684 | f_unitdata_mt(link_id, l3); |
| 6685 | |
| 6686 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6687 | f_unitdata_mo(link_id, l3); |
| 6688 | |
| 6689 | /* release the channel */ |
| 6690 | f_rsl_chan_deact(); |
| 6691 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6692 | f_rslem_unregister(0, g_chan_nr); |
| 6693 | } |
| 6694 | testcase TC_chan_act_a51() runs on test_CT { |
| 6695 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6696 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6697 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6698 | } |
| 6699 | testcase TC_chan_act_a52() runs on test_CT { |
| 6700 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6701 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6702 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6703 | } |
| 6704 | testcase TC_chan_act_a53() runs on test_CT { |
| 6705 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6706 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6707 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6708 | } |
| 6709 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6710 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6711 | 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] | 6712 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6713 | f_l1_tune(L1CTL); |
| 6714 | f_est_dchan(true); |
| 6715 | |
| 6716 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6717 | var L1ctlDlMessage dl; |
| 6718 | |
| 6719 | var octetstring l3 := f_rnd_octstring(20); |
| 6720 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6721 | |
| 6722 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6723 | f_unitdata_mt(link_id, l3); |
| 6724 | |
| 6725 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6726 | f_unitdata_mo(link_id, l3); |
| 6727 | |
| 6728 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6729 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, ts_RSL_ChanMode_SIGN)); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6730 | |
| 6731 | /* modify key to break proper encryption */ |
| 6732 | g_pars.encr.key := f_rnd_octstring(8); |
| 6733 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6734 | rsl.ies := rsl.ies & { ei }; |
| 6735 | RSL.send(rsl); |
| 6736 | |
| 6737 | timer T0 := 1.0; |
| 6738 | T0.start; |
| 6739 | /* Expect RSL MODIFY ACK */ |
| 6740 | alt { |
| 6741 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6742 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6743 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6744 | } |
| 6745 | [] T0.timeout { |
| 6746 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6747 | } |
| 6748 | } |
| 6749 | |
| 6750 | var octetstring l3msg := f_rnd_octstring(15); |
| 6751 | timer T1 := 3.0; |
| 6752 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6753 | due to broken encryption */ |
| 6754 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6755 | T1.start; |
| 6756 | alt { |
| 6757 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6758 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6759 | } |
| 6760 | [] T1.timeout { |
| 6761 | setverdict(pass); |
| 6762 | } |
| 6763 | } |
| 6764 | |
| 6765 | /* release the channel */ |
| 6766 | f_rsl_chan_deact(); |
| 6767 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6768 | f_rslem_unregister(0, g_chan_nr); |
| 6769 | } |
| 6770 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6771 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6772 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6773 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6774 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6775 | |
| 6776 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6777 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6778 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6779 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6780 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6781 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6782 | |
| 6783 | f_l1_tune(L1CTL); |
| 6784 | |
| 6785 | /* first establish a dedicated channel in the clear */ |
| 6786 | f_est_dchan(false); |
| 6787 | |
| 6788 | /* Establish ABM */ |
| 6789 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6790 | |
| 6791 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6792 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6793 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6794 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6795 | |
| 6796 | /* configure L1 to apply ciphering */ |
| 6797 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6798 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6799 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6800 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6801 | 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] | 6802 | |
| 6803 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6804 | * and hence enable encryption also on the downlink */ |
| 6805 | |
| 6806 | /* expect bi-directional communication work in encrypted mode */ |
| 6807 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6808 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6809 | |
| 6810 | /* release the channel */ |
| 6811 | f_rsl_chan_deact(); |
| 6812 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6813 | f_rslem_unregister(0, g_chan_nr); |
| 6814 | } |
| 6815 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6816 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6817 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6818 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6819 | } |
| 6820 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6821 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6822 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6823 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6824 | } |
| 6825 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6826 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6827 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6828 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6829 | } |
| 6830 | |
| 6831 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6832 | var LapdmFrame lf; |
| 6833 | var octetstring reenc; |
| 6834 | |
| 6835 | /* decode the LAPDm frame */ |
| 6836 | if (ischosen(exp_match.ab)) { |
| 6837 | lf.ab := dec_LapdmFrameAB(enc); |
| 6838 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6839 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6840 | } |
| 6841 | |
| 6842 | /* check if decoder result matches expectation */ |
| 6843 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6844 | 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] | 6845 | } else { |
| 6846 | log(name, ": matched"); |
| 6847 | setverdict(pass); |
| 6848 | } |
| 6849 | |
| 6850 | /* test if re-encoded frame equals original input */ |
| 6851 | reenc := enc_LapdmFrame(lf); |
| 6852 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6853 | 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] | 6854 | } else { |
| 6855 | setverdict(pass); |
| 6856 | } |
| 6857 | } |
| 6858 | |
| 6859 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6860 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6861 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6862 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6863 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6864 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6865 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6866 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6867 | } |
| 6868 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6869 | /*********************************************************************** |
| 6870 | * DTX Related (see GSM 05.08, section 8.3) |
| 6871 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6872 | 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] | 6873 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6874 | var GsmFrameNumber first_fn; |
| 6875 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6876 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6877 | 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] | 6878 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6879 | 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] | 6880 | const integer frame_dtx_tchf_mod := 104; |
| 6881 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6882 | * which operates in terms of blocks rather than frames. */ |
| 6883 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6884 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6885 | timer T := 5.0; |
| 6886 | |
| 6887 | f_l1_tune(L1CTL); |
| 6888 | RSL.clear; |
| 6889 | L1CTL.clear; |
| 6890 | |
| 6891 | /* activate TCHF signalling channel */ |
| 6892 | f_est_dchan(false); |
| 6893 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6894 | /* A template for matching dummy LAPDm func=UA frames */ |
| 6895 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 6896 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 6897 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 6898 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6899 | T.start; |
| 6900 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6901 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6902 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6903 | |
| 6904 | if (is_first_frame) { |
| 6905 | is_first_frame := false; |
| 6906 | first_fn := dl.dl_info.frame_nr; |
| 6907 | } |
| 6908 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6909 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6910 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6911 | T.stop; |
| 6912 | f_rsl_chan_deact(); |
| 6913 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6914 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6915 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 6916 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6917 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6918 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6919 | setverdict(fail, "Not enough fill frames received: ", |
| 6920 | nfill_frames, " out of ", expected_fill_frames); |
| 6921 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6922 | } else { |
| 6923 | setverdict(pass); |
| 6924 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6925 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6926 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6927 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6928 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6929 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6930 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6931 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6932 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6933 | repeat; |
| 6934 | } |
| 6935 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6936 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 6937 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6938 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6939 | f_rsl_chan_deact(); |
| 6940 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6941 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6942 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6943 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6944 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6945 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6946 | |
| 6947 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6948 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 6949 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6950 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 6951 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 6952 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6953 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 6954 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6955 | case else { |
| 6956 | /* This shall not happen, just to be sure */ |
| 6957 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6958 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6959 | } |
| 6960 | |
| 6961 | f_rsl_chan_deact(); |
| 6962 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6963 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6964 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6965 | setverdict(pass); |
| 6966 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6967 | setverdict(fail, "Not enough fill frames received: ", |
| 6968 | nfill_frames, " out of ", expected_fill_frames); |
| 6969 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6970 | } |
| 6971 | } else { |
| 6972 | repeat; |
| 6973 | } |
| 6974 | } |
| 6975 | } |
| 6976 | [] L1CTL.receive { repeat; } |
| 6977 | [] T.timeout { |
| 6978 | f_rsl_chan_deact(); |
| 6979 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6980 | 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] | 6981 | } |
| 6982 | } |
| 6983 | } |
| 6984 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6985 | private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6986 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6987 | var ConnHdlr vc_conn; |
| 6988 | var ConnHdlrPars pars; |
| 6989 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6990 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6991 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6992 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6993 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6994 | if (dtxd) { |
| 6995 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6996 | break; |
| 6997 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6998 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6999 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7000 | vc_conn.done; |
| 7001 | } |
| 7002 | } |
| 7003 | |
| 7004 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7005 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7006 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7007 | f_tch_sign_l2_fill_frame(false); |
| 7008 | } |
| 7009 | |
| 7010 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7011 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7012 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7013 | f_tch_sign_l2_fill_frame(true); |
| 7014 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7015 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7016 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7017 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7018 | } |
| 7019 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7020 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7021 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7022 | } |
| 7023 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7024 | |
| 7025 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7026 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7027 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7028 | runs on ConnHdlr return octetstring; |
| 7029 | |
| 7030 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7031 | runs on ConnHdlr { |
| 7032 | var L1ctlDlMessage l1_dl; |
| 7033 | var SacchL1Header l1h; |
| 7034 | var octetstring l2; |
| 7035 | |
| 7036 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7037 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7038 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7039 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7040 | |
| 7041 | /* Pass it to the user specified call-back function */ |
| 7042 | l2 := cb.apply(l1h, num_blocks); |
| 7043 | /* Send a Measurement Report generated by the call-back */ |
| 7044 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 7045 | l1_dl.dl_info.link_id, |
| 7046 | l1h, l2)); |
| 7047 | |
| 7048 | /* Shall we keep going? */ |
| 7049 | num_blocks := num_blocks - 1; |
| 7050 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 7051 | if (num_blocks > 0) { repeat; } |
| 7052 | } |
| 7053 | [] L1CTL.receive { repeat; } |
| 7054 | } |
| 7055 | |
| 7056 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 7057 | runs on ConnHdlr return octetstring { |
| 7058 | /* Command the L1 to apply received parameters */ |
| 7059 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 7060 | |
| 7061 | /* Dummy measurement report (the results are invalid) */ |
| 7062 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 7063 | } |
| 7064 | |
| 7065 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 7066 | runs on ConnHdlr return octetstring { |
| 7067 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 7068 | setverdict(fail, "Unexpected MS Power level change: ", |
| 7069 | g_pars.l1_pars.ms_power_level, " -> ", |
| 7070 | l1h.ms_power_lvl); |
| 7071 | } |
| 7072 | |
| 7073 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7074 | } |
| 7075 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7076 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7077 | runs on ConnHdlr return octetstring { |
| 7078 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7079 | if (num_blocks rem 2 == 0) { |
| 7080 | f_trxc_fake_rssi(-100); |
| 7081 | } else { |
| 7082 | f_trxc_fake_rssi(-50); |
| 7083 | } |
| 7084 | |
| 7085 | /* Make sure that MS power level remains constant */ |
| 7086 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7087 | } |
| 7088 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7089 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7090 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7091 | runs on ConnHdlr { |
| 7092 | var integer num_blocks := 8; |
| 7093 | timer T := int2float(num_blocks); |
| 7094 | |
| 7095 | f_l1_tune(L1CTL); |
| 7096 | RSL.clear; |
| 7097 | |
| 7098 | /* These IEs are needed for autonomous MS power control */ |
| 7099 | var template (value) RSL_IE_List ies := { |
| 7100 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7101 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7102 | }), |
| 7103 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7104 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7105 | }) |
| 7106 | }; |
| 7107 | |
| 7108 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7109 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7110 | |
| 7111 | /* Establish a dedicated channel */ |
| 7112 | f_est_dchan(more_ies := valueof(ies)); |
| 7113 | |
| 7114 | L1CTL.clear; |
| 7115 | T.start; |
| 7116 | alt { |
| 7117 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 7118 | [] T.timeout { |
| 7119 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7120 | num_blocks, " were not handled"); |
| 7121 | } |
| 7122 | } |
| 7123 | } |
| 7124 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 7125 | var ConnHdlr vc_conn; |
| 7126 | var ConnHdlrPars pars; |
| 7127 | |
| 7128 | f_init(); |
| 7129 | |
| 7130 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 7131 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 7132 | |
| 7133 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7134 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7135 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7136 | |
| 7137 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 7138 | pars, trxc_comp := true); |
| 7139 | vc_conn.done; |
| 7140 | } |
| 7141 | |
| 7142 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7143 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7144 | } |
| 7145 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7146 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 7147 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7148 | runs on ConnHdlr { |
| 7149 | var integer num_blocks := 16; |
| 7150 | timer T := int2float(num_blocks); |
| 7151 | |
| 7152 | f_l1_tune(L1CTL); |
| 7153 | RSL.clear; |
| 7154 | |
| 7155 | /* These IEs are needed for autonomous MS power control */ |
| 7156 | var template (value) RSL_IE_List ies := { |
| 7157 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7158 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7159 | }), |
| 7160 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7161 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7162 | }) |
| 7163 | }; |
| 7164 | |
| 7165 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7166 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7167 | |
| 7168 | /* Establish a dedicated channel */ |
| 7169 | f_est_dchan(more_ies := valueof(ies)); |
| 7170 | |
| 7171 | L1CTL.clear; |
| 7172 | T.start; |
| 7173 | alt { |
| 7174 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7175 | [] T.timeout { |
| 7176 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7177 | num_blocks, " were not handled"); |
| 7178 | } |
| 7179 | } |
| 7180 | } |
| 7181 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7182 | var ConnHdlr vc_conn; |
| 7183 | var ConnHdlrPars pars; |
| 7184 | |
| 7185 | f_init(); |
| 7186 | |
| 7187 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7188 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7189 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7190 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7191 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7192 | |
| 7193 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7194 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7195 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7196 | |
| 7197 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7198 | pars, trxc_comp := true); |
| 7199 | vc_conn.done; |
| 7200 | } |
| 7201 | |
| 7202 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7203 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7204 | } |
| 7205 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7206 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7207 | var template L1ctlDlMessage tr_bad_frame; |
| 7208 | var L1ctlDlMessage l1_dl; |
| 7209 | timer T := 8.0; |
| 7210 | |
| 7211 | f_l1_tune(L1CTL); |
| 7212 | RSL.clear; |
| 7213 | |
| 7214 | f_est_dchan(); |
| 7215 | |
| 7216 | /* There may be a few errors right after the channel activation */ |
| 7217 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 7218 | L1CTL.clear; |
| 7219 | |
| 7220 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 7221 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 7222 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 7223 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 7224 | tr_bad_frame.payload := ?; |
| 7225 | |
| 7226 | T.start; |
| 7227 | alt { |
| 7228 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 7229 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 7230 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 7231 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 7232 | } |
| 7233 | [] as_l1_sacch(); |
| 7234 | [] L1CTL.receive { repeat; } |
| 7235 | [] T.timeout { |
| 7236 | /* We're done, break the loop */ |
| 7237 | setverdict(pass); |
| 7238 | } |
| 7239 | } |
| 7240 | |
| 7241 | f_rsl_chan_deact(); |
| 7242 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7243 | } |
| 7244 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 7245 | var ConnHdlr vc_conn; |
| 7246 | var ConnHdlrPars pars; |
| 7247 | |
| 7248 | f_init(); |
| 7249 | |
| 7250 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7251 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7252 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7253 | vc_conn.done; |
| 7254 | } |
| 7255 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 7256 | var ConnHdlr vc_conn; |
| 7257 | var ConnHdlrPars pars; |
| 7258 | |
| 7259 | f_init(); |
| 7260 | |
| 7261 | /* TS5, TCH/H, V1 (HR codec) */ |
| 7262 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7263 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7264 | vc_conn.done; |
| 7265 | } |
| 7266 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7267 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 7268 | /* protocol error as per 44.006 */ |
| 7269 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 7270 | /* repetition of SABM or DISC N200 times without ACK */ |
| 7271 | /* receptiom of SABM in multi-frame established state */ |
| 7272 | |
| 7273 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7274 | /* TODO Areas: |
| 7275 | |
| 7276 | * channel activation |
| 7277 | ** with BS_Power / MS_Power, bypassing power control loop |
| 7278 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7279 | ** with timing advance from initial activation on |
| 7280 | * mode modify |
| 7281 | ** encryption |
| 7282 | ** multirate |
| 7283 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7284 | ** unsupported algorithm |
| 7285 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7286 | * BS Power Control |
| 7287 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7288 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7289 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7290 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7291 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7292 | ** DATA_IND from BTS->PCU |
| 7293 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7294 | |
| 7295 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7296 | |
| 7297 | control { |
| 7298 | execute( TC_chan_act_stress() ); |
| 7299 | execute( TC_chan_act_react() ); |
| 7300 | execute( TC_chan_deact_not_active() ); |
| 7301 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 7302 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 7303 | execute( TC_sacch_filling() ); |
| 7304 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 7305 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 7306 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 7307 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 7308 | execute( TC_sacch_chan_act_ho_async() ); |
| 7309 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7310 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 7311 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7312 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 7313 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 7314 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 7315 | execute( TC_rach_load_idle_thresh0() ); |
| 7316 | execute( TC_rach_load_idle_below_thresh() ); |
| 7317 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7318 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7319 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7320 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7321 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 7322 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7323 | execute( TC_meas_res_sign_tchf() ); |
| 7324 | execute( TC_meas_res_sign_tchh() ); |
| 7325 | execute( TC_meas_res_sign_sdcch4() ); |
| 7326 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 7327 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 7328 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 7329 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 7330 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 7331 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 7332 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 7333 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 7334 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 7335 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 7336 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 7337 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 7338 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 7339 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 7340 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 7341 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7342 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7343 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7344 | execute( TC_paging_imsi_80percent() ); |
| 7345 | execute( TC_paging_tmsi_80percent() ); |
| 7346 | execute( TC_paging_imsi_200percent() ); |
| 7347 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 7348 | execute( TC_rsl_protocol_error() ); |
| 7349 | execute( TC_rsl_mand_ie_error() ); |
| 7350 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7351 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 7352 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7353 | execute( TC_si_sched_2bis() ); |
| 7354 | execute( TC_si_sched_2ter() ); |
| 7355 | execute( TC_si_sched_2ter_2bis() ); |
| 7356 | execute( TC_si_sched_2quater() ); |
| 7357 | execute( TC_si_sched_13() ); |
| 7358 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 7359 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 7360 | execute( TC_ipa_crcx_twice_not_active() ); |
| 7361 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 7362 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 7363 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7364 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7365 | if (mp_pcu_socket != "") { |
| 7366 | execute( TC_pcu_act_req() ); |
| 7367 | execute( TC_pcu_act_req_wrong_ts() ); |
| 7368 | execute( TC_pcu_act_req_wrong_bts() ); |
| 7369 | execute( TC_pcu_act_req_wrong_trx() ); |
| 7370 | execute( TC_pcu_deact_req() ); |
| 7371 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 7372 | execute( TC_pcu_ver_si1() ); |
| 7373 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7374 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7375 | if (mp_l1_supports_gprs) { |
| 7376 | execute( TC_pcu_data_req_pdtch() ); |
| 7377 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 7378 | execute( TC_pcu_data_req_wrong_bts() ); |
| 7379 | execute( TC_pcu_data_req_wrong_trx() ); |
| 7380 | execute( TC_pcu_data_req_wrong_ts() ); |
| 7381 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7382 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 7383 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7384 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 7385 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7386 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 7387 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 7388 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 7389 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7390 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 7391 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 7392 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 7393 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 7394 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 7395 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 7396 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7397 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7398 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7399 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7400 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7401 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7402 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 7403 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 7404 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 7405 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 7406 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 7407 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 7408 | execute( TC_pcu_info_ind_fh_params() ); |
| 7409 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 7410 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 7411 | execute( TC_pcu_socket_two_nsvc() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7412 | } else { |
| 7413 | log("PCU socket path not available, skipping PCU tests"); |
| 7414 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7415 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7416 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7417 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 7418 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7419 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 7420 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7421 | |
| 7422 | execute( TC_rll_est_ind() ); |
| 7423 | execute( TC_rll_est_req_DCCH_3() ); |
| 7424 | execute( TC_rll_est_req_ACCH_3() ); |
| 7425 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 7426 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 7427 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 7428 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 7429 | execute( TC_rll_rel_req() ); |
| 7430 | execute( TC_rll_unit_data_req_DCCH() ); |
| 7431 | execute( TC_rll_unit_data_req_ACCH() ); |
| 7432 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 7433 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7434 | |
| 7435 | execute( TC_chan_act_a51() ); |
| 7436 | execute( TC_chan_act_a52() ); |
| 7437 | execute( TC_chan_act_a53() ); |
| 7438 | execute( TC_encr_cmd_a51() ); |
| 7439 | execute( TC_encr_cmd_a52() ); |
| 7440 | execute( TC_encr_cmd_a53() ); |
| 7441 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 7442 | execute( TC_err_rep_wrong_mdisc() ); |
| 7443 | execute( TC_err_rep_wrong_msg_type() ); |
| 7444 | execute( TC_err_rep_wrong_sequence() ); |
| 7445 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7446 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7447 | |
| 7448 | execute( TC_tch_sign_l2_fill_frame() ); |
| 7449 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7450 | |
| 7451 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7452 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7453 | |
| 7454 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7455 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7456 | |
| 7457 | execute( TC_speech_no_rtp_tchf() ); |
| 7458 | execute( TC_speech_no_rtp_tchh() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7459 | } |
| 7460 | |
| 7461 | |
| 7462 | } |