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 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 475 | /* global init function */ |
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); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 550 | f_ipa_ctrl_start(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 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 558 | map(self:PCU, system:PCU); |
| 559 | f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 560 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 561 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 562 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 563 | |
| 564 | /* Init TRXC interface to FakeTRX */ |
| 565 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 566 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 567 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 568 | /* 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] | 569 | 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] | 570 | 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] | 571 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 572 | 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] | 573 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 574 | |
| 575 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 576 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 577 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 578 | } |
| 579 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 580 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 581 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 582 | map(self:L1CTL, system:L1CTL); |
| 583 | f_connect_reset(L1CTL); |
| 584 | } |
| 585 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 586 | private type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 587 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 588 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 589 | |
| 590 | private type record of FreqHopGroup FreqHopGroups; |
| 591 | private type record FreqHopGroup { |
| 592 | uint6_t hsn, |
| 593 | FreqHopGroupItems trx_maio |
| 594 | }; |
| 595 | |
| 596 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 597 | private type record FreqHopGroupItem { |
| 598 | uint8_t trx_nr, |
| 599 | uint6_t maio |
| 600 | }; |
| 601 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 602 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 603 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 604 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 605 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 606 | var integer i, j; |
| 607 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 608 | fhp.enabled := false; |
| 609 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 610 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 611 | var FreqHopGroup g := groups[i]; |
| 612 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 613 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 614 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 615 | fhp.maio_hsn.maio := gi.maio; |
| 616 | fhp.maio_hsn.hsn := g.hsn; |
| 617 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 618 | break; |
| 619 | } |
| 620 | } |
| 621 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 622 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 623 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 624 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 625 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 626 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 627 | |
| 628 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 629 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 630 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 631 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 632 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 633 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 634 | } |
| 635 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 636 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 637 | break; /* We're done */ |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 642 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 643 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 644 | boolean pcu_comp := false, |
| 645 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 646 | runs on test_CT return ConnHdlr { |
| 647 | var charstring id := testcasename(); |
| 648 | var ConnHdlr vc_conn; |
| 649 | |
| 650 | vc_conn := ConnHdlr.create(id); |
| 651 | /* connect to RSL Emulation main component */ |
| 652 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 653 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 654 | |
| 655 | /* The ConnHdlr component may want to talk to some ports directly, |
| 656 | * so we disconnect it from the test_CT and connect it to the component. |
| 657 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 658 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 659 | unmap(self:PCU, system:PCU); |
| 660 | map(vc_conn:PCU, system:PCU); |
| 661 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 662 | if (trxc_comp) { |
| 663 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 664 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 665 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 666 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 667 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 668 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 669 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 670 | } |
| 671 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 672 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 673 | return vc_conn; |
| 674 | } |
| 675 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 676 | private altstep as_Tguard() runs on ConnHdlr { |
| 677 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 678 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 682 | 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] | 683 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 684 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 685 | } |
| 686 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 687 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 688 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 689 | 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] | 690 | } |
| 691 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 692 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 693 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 694 | 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] | 695 | } |
| 696 | |
| 697 | /* first function started in ConnHdlr component */ |
| 698 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 699 | runs on ConnHdlr { |
| 700 | g_pars := pars; |
| 701 | g_chan_nr := pars.chan_nr; |
| 702 | |
| 703 | map(self:L1CTL, system:L1CTL); |
| 704 | f_connect_reset(L1CTL); |
| 705 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 706 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 707 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 708 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 709 | |
| 710 | g_Tguard.start(pars.t_guard); |
| 711 | activate(as_Tguard()); |
| 712 | |
| 713 | f_rslem_register(0, pars.chan_nr); |
| 714 | |
| 715 | /* call the user-supplied test case function */ |
| 716 | fn.apply(id); |
| 717 | } |
| 718 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 719 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 720 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 721 | runs on ConnHdlr return RSL_Message { |
| 722 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 723 | timer T := 3.0; |
| 724 | RSL.send(tx); |
| 725 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 726 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 727 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 728 | T.stop; |
| 729 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 730 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 731 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 732 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 733 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 734 | [not ignore_other] as_l1_sacch(); |
| 735 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 736 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 737 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 738 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 739 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 740 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 741 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 742 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 743 | return rx; |
| 744 | } |
| 745 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 746 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 747 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 748 | runs on ConnHdlr { |
| 749 | 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] | 750 | } |
| 751 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 752 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 753 | boolean encr_enable := false, |
| 754 | RSL_IE_List more_ies := {}, |
| 755 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 756 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 757 | 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] | 758 | if (encr_enable) { |
| 759 | /* append encryption related IEs, if requested */ |
| 760 | var RSL_IE_EncryptionInfo encr_info; |
| 761 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 762 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 763 | encr_info})) }; |
| 764 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 765 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 766 | 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] | 767 | } |
| 768 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 769 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 770 | 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] | 771 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 772 | } |
| 773 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 774 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 775 | template RSL_IE_ChannelMode chan_mode, |
| 776 | float t_guard := 20.0) := { |
| 777 | chan_nr := valueof(chan_nr), |
| 778 | chan_mode := valueof(chan_mode), |
| 779 | t_guard := t_guard, |
| 780 | l1_pars := { |
| 781 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 782 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 783 | meas_ul := { |
| 784 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 785 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 786 | rxqual := 0 |
| 787 | }, |
| 788 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 789 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 790 | rxqual := 0 |
| 791 | } |
| 792 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 793 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 794 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 795 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 796 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 797 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 798 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 799 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 800 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 801 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 802 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 803 | fhp := { |
| 804 | enabled := false, |
| 805 | maio_hsn := ts_HsnMaio(0, 0), |
| 806 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 807 | ma := { } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 808 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 809 | } |
| 810 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 811 | /*********************************************************************** |
| 812 | * Channel Activation / Deactivation |
| 813 | ***********************************************************************/ |
| 814 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 815 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 816 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 817 | for (var integer i := 0; i < 500; i := i+1) { |
| 818 | f_rsl_chan_act(g_pars.chan_mode); |
| 819 | f_rsl_chan_deact(); |
| 820 | } |
| 821 | setverdict(pass); |
| 822 | } |
| 823 | testcase TC_chan_act_stress() runs on test_CT { |
| 824 | var ConnHdlr vc_conn; |
| 825 | 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] | 826 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 827 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 828 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 829 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 833 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 834 | f_rsl_chan_act(g_pars.chan_mode); |
| 835 | /* attempt to activate the same lchan again -> expect reject */ |
| 836 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 837 | alt { |
| 838 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 839 | 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] | 840 | } |
| 841 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 842 | setverdict(pass); |
| 843 | } |
| 844 | } |
| 845 | f_rsl_chan_deact(); |
| 846 | } |
| 847 | testcase TC_chan_act_react() runs on test_CT { |
| 848 | var ConnHdlr vc_conn; |
| 849 | 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] | 850 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 851 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 852 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 853 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 857 | 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] | 858 | timer T := 3.0; |
| 859 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 860 | T.start; |
| 861 | alt { |
| 862 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 863 | setverdict(pass); |
| 864 | } |
| 865 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 866 | 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] | 867 | } |
| 868 | } |
| 869 | } |
| 870 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 871 | 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] | 872 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 873 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 874 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 875 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 879 | 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] | 880 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 881 | alt { |
| 882 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 883 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 884 | } |
| 885 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 886 | setverdict(pass); |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | private type record WrongChanNrCase { |
| 891 | RslChannelNr chan_nr, |
| 892 | charstring description |
| 893 | } |
| 894 | private type record of WrongChanNrCase WrongChanNrCases; |
| 895 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 896 | chan_nr := chan_nr, |
| 897 | description := desc |
| 898 | } |
| 899 | |
| 900 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 901 | var ConnHdlr vc_conn; |
| 902 | var ConnHdlrPars pars; |
| 903 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 904 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 905 | |
| 906 | var WrongChanNrCases wrong := { |
| 907 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 908 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 909 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 910 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 911 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 912 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 913 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 914 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 915 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 916 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 917 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 918 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 919 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 920 | }; |
| 921 | |
| 922 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 923 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 924 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 925 | vc_conn.done; |
| 926 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 927 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 928 | } |
| 929 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 930 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 931 | 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] | 932 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 933 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 934 | |
| 935 | /* test on each of the channels we have */ |
| 936 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 937 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 938 | |
| 939 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 940 | vc_conn := f_start_handler(fn, pars); |
| 941 | vc_conn.done; |
| 942 | } |
| 943 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 944 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 945 | } |
| 946 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 947 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 948 | * SACCH handling |
| 949 | ***********************************************************************/ |
| 950 | |
| 951 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 952 | timer T_sacch := 3.0; |
| 953 | T_sacch.start; |
| 954 | alt { |
| 955 | [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] | 956 | 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] | 957 | } |
| 958 | [not exp] T_sacch.timeout { |
| 959 | setverdict(pass); |
| 960 | } |
| 961 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 962 | setverdict(pass); |
| 963 | } |
| 964 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 965 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr)); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 966 | } |
| 967 | [] L1CTL.receive { repeat; } |
| 968 | [] RSL.receive { repeat; } |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 973 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 974 | f_l1_tune(L1CTL); |
| 975 | RSL.clear; |
| 976 | |
| 977 | /* activate the logical channel */ |
| 978 | f_est_dchan(); |
| 979 | L1CTL.clear; |
| 980 | |
| 981 | /* check that SACCH actually are received as expected */ |
| 982 | f_exp_sacch(true); |
| 983 | |
| 984 | /* deactivate SACCH on the logical channel */ |
| 985 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 986 | f_sleep(1.0); |
| 987 | L1CTL.clear; |
| 988 | |
| 989 | /* check that no SACCH are received anymore */ |
| 990 | f_exp_sacch(false); |
| 991 | |
| 992 | /* release the channel */ |
| 993 | f_rsl_chan_deact(); |
| 994 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 995 | } |
| 996 | testcase TC_deact_sacch() runs on test_CT { |
| 997 | var ConnHdlr vc_conn; |
| 998 | var ConnHdlrPars pars; |
| 999 | f_init(); |
| 1000 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1001 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1002 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1003 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1004 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1005 | vc_conn.done; |
| 1006 | } |
| 1007 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1008 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1009 | } |
| 1010 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1011 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1012 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 1013 | var L1ctlDlMessage dl; |
| 1014 | /* check that the specified SI5 value is actually sent */ |
| 1015 | timer T_sacch := 3.0; |
| 1016 | L1CTL.clear; |
| 1017 | T_sacch.start; |
| 1018 | alt { |
| 1019 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1020 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1021 | if (match(l3, l3_exp)) { |
| 1022 | setverdict(pass); |
| 1023 | } else { |
| 1024 | repeat; |
| 1025 | } |
| 1026 | } |
| 1027 | [] L1CTL.receive { repeat; } |
| 1028 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1029 | 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] | 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1034 | /* verify that given SACCH payload is not present */ |
| 1035 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1036 | var L1ctlDlMessage dl; |
| 1037 | /* check that the specified SI5 value is actually sent */ |
| 1038 | timer T_sacch := 3.0; |
| 1039 | L1CTL.clear; |
| 1040 | T_sacch.start; |
| 1041 | alt { |
| 1042 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1043 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1044 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1045 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1046 | } else { |
| 1047 | repeat; |
| 1048 | } |
| 1049 | } |
| 1050 | [] L1CTL.receive { repeat; } |
| 1051 | [] T_sacch.timeout { |
| 1052 | setverdict(pass); |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1057 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1058 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1059 | /* Set a known default SACCH filling for SI5 */ |
| 1060 | var octetstring si5 := f_rnd_octstring(19); |
| 1061 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1062 | |
| 1063 | f_l1_tune(L1CTL); |
| 1064 | RSL.clear; |
| 1065 | |
| 1066 | /* activate the logical channel */ |
| 1067 | f_est_dchan(); |
| 1068 | |
| 1069 | /* check that the specified SI5 value is actually sent */ |
| 1070 | f_sacch_present(si5); |
| 1071 | |
| 1072 | /* release the channel */ |
| 1073 | RSL.clear; |
| 1074 | f_rsl_chan_deact(); |
| 1075 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1076 | } |
| 1077 | testcase TC_sacch_filling() runs on test_CT { |
| 1078 | var ConnHdlr vc_conn; |
| 1079 | var ConnHdlrPars pars; |
| 1080 | f_init(); |
| 1081 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1082 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1083 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1084 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1085 | vc_conn.done; |
| 1086 | } |
| 1087 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1088 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1089 | } |
| 1090 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1091 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1092 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1093 | /* Set a known default SACCH filling for SI5 */ |
| 1094 | var octetstring si5 := f_rnd_octstring(19); |
| 1095 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1096 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1097 | |
| 1098 | f_l1_tune(L1CTL); |
| 1099 | RSL.clear; |
| 1100 | |
| 1101 | log("Activating channel, expecting standard SI5"); |
| 1102 | /* activate the logical channel */ |
| 1103 | f_est_dchan(); |
| 1104 | /* check that the specified SI5 value is actually sent */ |
| 1105 | f_sacch_present(si5); |
| 1106 | |
| 1107 | /* set channel-specific different SI5 */ |
| 1108 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1109 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1110 | /* check that the specified lchan-specific value is now used */ |
| 1111 | f_sacch_present(si5_diff); |
| 1112 | |
| 1113 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1114 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1115 | f_rsl_chan_deact(); |
| 1116 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1117 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1118 | f_sacch_present(si5); |
| 1119 | |
| 1120 | /* release the channel */ |
| 1121 | RSL.clear; |
| 1122 | f_rsl_chan_deact(); |
| 1123 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1124 | } |
| 1125 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1126 | var ConnHdlr vc_conn; |
| 1127 | var ConnHdlrPars pars; |
| 1128 | f_init(); |
| 1129 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1130 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1131 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1132 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1133 | vc_conn.done; |
| 1134 | } |
| 1135 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1136 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1139 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1140 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1141 | var octetstring si5 := f_rnd_octstring(19); |
| 1142 | var octetstring si5bis := f_rnd_octstring(19); |
| 1143 | var octetstring si5ter := f_rnd_octstring(19); |
| 1144 | var octetstring si6 := f_rnd_octstring(19); |
| 1145 | |
| 1146 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1147 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1148 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1149 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1150 | |
| 1151 | f_l1_tune(L1CTL); |
| 1152 | RSL.clear; |
| 1153 | |
| 1154 | /* activate the logical channel */ |
| 1155 | f_est_dchan(); |
| 1156 | L1CTL.clear; |
| 1157 | |
| 1158 | /* check that SACCH actually are received as expected */ |
| 1159 | f_sacch_present(si5); |
| 1160 | f_sacch_present(si5bis); |
| 1161 | f_sacch_present(si5ter); |
| 1162 | f_sacch_present(si6); |
| 1163 | |
| 1164 | /* release the channel */ |
| 1165 | f_rsl_chan_deact(); |
| 1166 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1167 | } |
| 1168 | testcase TC_sacch_multi() runs on test_CT { |
| 1169 | var ConnHdlr vc_conn; |
| 1170 | var ConnHdlrPars pars; |
| 1171 | f_init(); |
| 1172 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1173 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1174 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1175 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1176 | vc_conn.done; |
| 1177 | } |
| 1178 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1180 | } |
| 1181 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1182 | /* Test if SACH information is modified as expected */ |
| 1183 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1184 | var octetstring si5 := f_rnd_octstring(19); |
| 1185 | var octetstring si6 := f_rnd_octstring(19); |
| 1186 | |
| 1187 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1188 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1189 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1190 | |
| 1191 | f_l1_tune(L1CTL); |
| 1192 | RSL.clear; |
| 1193 | |
| 1194 | /* activate the logical channel */ |
| 1195 | f_est_dchan(); |
| 1196 | L1CTL.clear; |
| 1197 | |
| 1198 | /* check that SACCH actually are received as expected */ |
| 1199 | f_sacch_present(si5); |
| 1200 | f_sacch_present(si6); |
| 1201 | |
| 1202 | /* disable SI6 */ |
| 1203 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1204 | |
| 1205 | /* check that SI5 is still transmitted */ |
| 1206 | f_sacch_present(si5); |
| 1207 | /* check if SI6 is now gone */ |
| 1208 | f_sacch_missing(si6); |
| 1209 | |
| 1210 | /* release the channel */ |
| 1211 | f_rsl_chan_deact(); |
| 1212 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1213 | } |
| 1214 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1215 | var ConnHdlr vc_conn; |
| 1216 | var ConnHdlrPars pars; |
| 1217 | f_init(); |
| 1218 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1219 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1220 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1221 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1222 | vc_conn.done; |
| 1223 | } |
| 1224 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1226 | } |
| 1227 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1228 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1229 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1230 | var octetstring si5 := f_rnd_octstring(19); |
| 1231 | var octetstring si6 := f_rnd_octstring(19); |
| 1232 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1233 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1234 | |
| 1235 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1236 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1237 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1238 | |
| 1239 | f_l1_tune(L1CTL); |
| 1240 | RSL.clear; |
| 1241 | |
| 1242 | /* activate channel with different SACCH filling */ |
| 1243 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1244 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1245 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1246 | })); |
| 1247 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1248 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1249 | f_est_dchan(more_ies := addl_ies); |
| 1250 | |
| 1251 | /* check that SACCH actually are received as expected */ |
| 1252 | f_sacch_present(si5_specific); |
| 1253 | f_sacch_present(si6_specific); |
| 1254 | |
| 1255 | /* release the channel */ |
| 1256 | f_rsl_chan_deact(); |
| 1257 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1258 | } |
| 1259 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1260 | var ConnHdlr vc_conn; |
| 1261 | var ConnHdlrPars pars; |
| 1262 | f_init(); |
| 1263 | |
| 1264 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1265 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1266 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1267 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1268 | vc_conn.done; |
| 1269 | } |
| 1270 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1271 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1272 | } |
| 1273 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1274 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1275 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1276 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1277 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1278 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1279 | |
| 1280 | f_l1_tune(L1CTL); |
| 1281 | RSL.clear; |
| 1282 | |
| 1283 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1284 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1285 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1286 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1287 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1288 | var RSL_IE_List addl_ies := { |
| 1289 | ho_ref_ie |
| 1290 | }; |
| 1291 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1292 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1293 | 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] | 1294 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1295 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1296 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1297 | |
| 1298 | /* Verify that no DL SACCH is being received */ |
| 1299 | f_sacch_missing(?); |
| 1300 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1301 | /* Send handover Access Burst and expect SACCH to start */ |
| 1302 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1303 | |
| 1304 | f_sacch_present(si5); |
| 1305 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1306 | f_rsl_chan_deact(); |
| 1307 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1308 | |
| 1309 | |
| 1310 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1311 | |
| 1312 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1313 | addl_ies := { |
| 1314 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1315 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1316 | }; |
| 1317 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1318 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1319 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1320 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1321 | |
| 1322 | /* Verify that DL SACCH is being received */ |
| 1323 | f_sacch_present(si5); |
| 1324 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1325 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1326 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1327 | |
| 1328 | f_sacch_present(si5); |
| 1329 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1330 | f_rsl_chan_deact(); |
| 1331 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1332 | } |
| 1333 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1334 | var ConnHdlr vc_conn; |
| 1335 | var ConnHdlrPars pars; |
| 1336 | f_init(); |
| 1337 | |
| 1338 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1339 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1340 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1341 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1342 | vc_conn.done; |
| 1343 | } |
| 1344 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1345 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1346 | } |
| 1347 | |
| 1348 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1349 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1350 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1351 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1352 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1353 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1354 | var RSL_IE_List addl_ies; |
| 1355 | |
| 1356 | f_l1_tune(L1CTL); |
| 1357 | RSL.clear; |
| 1358 | |
| 1359 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1360 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1361 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1362 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1363 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1364 | addl_ies := { |
| 1365 | ho_ref_ie |
| 1366 | }; |
| 1367 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1368 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1369 | 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] | 1370 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1371 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1372 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1373 | |
| 1374 | /* Verify that no DL SACCH is being received */ |
| 1375 | f_sacch_missing(?); |
| 1376 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1377 | /* Send handover Access Burst and expect SACCH to start */ |
| 1378 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1379 | |
| 1380 | f_sacch_present(si5); |
| 1381 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1382 | f_rsl_chan_deact(); |
| 1383 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1384 | |
| 1385 | |
| 1386 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1387 | |
| 1388 | /* Activate channel on BTS side */ |
| 1389 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1390 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1391 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1392 | }; |
| 1393 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1394 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1395 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1396 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1397 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1398 | /* Verify that DL SACCH is being received, because MS Power IE was sent */ |
| 1399 | f_sacch_present(si5); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1400 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1401 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1402 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1403 | |
| 1404 | f_sacch_present(si5); |
| 1405 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1406 | f_rsl_chan_deact(); |
| 1407 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1408 | |
| 1409 | |
| 1410 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1411 | |
| 1412 | /* Activate channel on BTS side */ |
| 1413 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1414 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1415 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1416 | }; |
| 1417 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1418 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1419 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1420 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1421 | |
| 1422 | /* Verify that no DL SACCH is being received */ |
| 1423 | f_sacch_missing(?); |
| 1424 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1425 | /* Send handover Access Burst and expect SACCH to start */ |
| 1426 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1427 | |
| 1428 | f_sacch_present(si5); |
| 1429 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1430 | f_rsl_chan_deact(); |
| 1431 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1432 | |
| 1433 | |
| 1434 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1435 | |
| 1436 | /* Activate channel on BTS side */ |
| 1437 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1438 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1439 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1440 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1441 | }; |
| 1442 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1443 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1444 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1445 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1446 | |
| 1447 | /* Verify that DL SACCH is being received */ |
| 1448 | f_sacch_present(si5); |
| 1449 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1450 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1451 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1452 | |
| 1453 | f_sacch_present(si5); |
| 1454 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1455 | f_rsl_chan_deact(); |
| 1456 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1457 | } |
| 1458 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1459 | var ConnHdlr vc_conn; |
| 1460 | var ConnHdlrPars pars; |
| 1461 | f_init(); |
| 1462 | |
| 1463 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1464 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1465 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1466 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1467 | vc_conn.done; |
| 1468 | } |
| 1469 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1470 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1471 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1472 | |
| 1473 | |
| 1474 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1475 | * RACH Handling |
| 1476 | ***********************************************************************/ |
| 1477 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1478 | /* 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] | 1479 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1480 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1481 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1482 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1483 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1484 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1485 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1486 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1487 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1488 | if (emerg == true) { |
| 1489 | ra := f_rnd_ra_emerg(); |
| 1490 | } else { |
| 1491 | ra := f_rnd_ra_cs(); |
| 1492 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1493 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1494 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1495 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1496 | } |
| 1497 | fn_last := fn; |
| 1498 | |
| 1499 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1500 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1501 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1502 | [] 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] | 1503 | T.stop; |
| 1504 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1505 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1506 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1507 | } |
| 1508 | [] RSL_CCHAN.receive { repeat; } |
| 1509 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1510 | test_failed := true; |
| 1511 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1512 | } |
| 1513 | } |
| 1514 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1515 | if (test_failed) { |
| 1516 | 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] | 1517 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1518 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1519 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1520 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1521 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1522 | /* Normal variant */ |
| 1523 | testcase TC_rach_content() runs on test_CT { |
| 1524 | f_TC_rach_content(emerg := false); |
| 1525 | } |
| 1526 | |
| 1527 | /* Emergency call variant */ |
| 1528 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1529 | f_TC_rach_content(emerg := true); |
| 1530 | } |
| 1531 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1532 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1533 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1534 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1535 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1536 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1537 | f_l1_tune(L1CTL); |
| 1538 | |
| 1539 | var GsmFrameNumber fn_last := 0; |
| 1540 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1541 | var OCT1 ra := f_rnd_ra_cs(); |
| 1542 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1543 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1544 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1545 | } |
| 1546 | fn_last := fn; |
| 1547 | } |
| 1548 | var integer rsl_chrqd := 0; |
| 1549 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1550 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1551 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1552 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1553 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1554 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1555 | repeat; |
| 1556 | } |
| 1557 | [] RSL_CCHAN.receive { repeat; } |
| 1558 | [] T.timeout { } |
| 1559 | } |
| 1560 | if (rsl_chrqd == 1000) { |
| 1561 | setverdict(pass); |
| 1562 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1563 | 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] | 1564 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1565 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1566 | } |
| 1567 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1568 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1569 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1570 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1571 | } |
| 1572 | |
| 1573 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1574 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1575 | |
| 1576 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1577 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1578 | var ASP_RSL_Unitdata rx_ud; |
| 1579 | |
| 1580 | f_init_vty_bsc(); |
| 1581 | /* send load indications even at 0% load */ |
| 1582 | f_vty_load_ind_thresh(0); |
| 1583 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1584 | f_sleep(2.0); |
| 1585 | |
| 1586 | f_init(); |
| 1587 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1588 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1589 | alt { |
| 1590 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1591 | [] RSL_CCHAN.receive { repeat } |
| 1592 | } |
| 1593 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1594 | timer T := 5.0; |
| 1595 | T.start; |
| 1596 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1597 | [] 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] | 1598 | setverdict(pass); |
| 1599 | repeat; |
| 1600 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1601 | [] 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] | 1602 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1603 | repeat; |
| 1604 | } |
| 1605 | [] RSL_CCHAN.receive { |
| 1606 | repeat; |
| 1607 | } |
| 1608 | [] T.timeout { } |
| 1609 | } |
| 1610 | |
| 1611 | f_vty_load_ind_thresh(10); |
| 1612 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1613 | } |
| 1614 | |
| 1615 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1616 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1617 | var ASP_RSL_Unitdata rx_ud; |
| 1618 | |
| 1619 | f_init_vty_bsc(); |
| 1620 | f_init(); |
| 1621 | |
| 1622 | timer T := 5.0; |
| 1623 | T.start; |
| 1624 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1625 | [] 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] | 1626 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1627 | repeat; |
| 1628 | } |
| 1629 | [] RSL_CCHAN.receive { |
| 1630 | repeat; |
| 1631 | } |
| 1632 | [] T.timeout { |
| 1633 | setverdict(pass); |
| 1634 | } |
| 1635 | } |
| 1636 | |
| 1637 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1638 | } |
| 1639 | |
| 1640 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1641 | testcase TC_rach_load_count() runs on test_CT { |
| 1642 | var ASP_RSL_Unitdata rx_ud; |
| 1643 | var integer load_access_count := 0; |
| 1644 | |
| 1645 | f_init_vty_bsc(); |
| 1646 | /* send load indications even at 0% load */ |
| 1647 | f_vty_load_ind_thresh(0); |
| 1648 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1649 | f_sleep(2.0); |
| 1650 | f_init(); |
| 1651 | |
| 1652 | f_init_l1ctl(); |
| 1653 | f_sleep(1.0); |
| 1654 | f_l1_tune(L1CTL); |
| 1655 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1656 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1657 | alt { |
| 1658 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1659 | [] RSL_CCHAN.receive { repeat } |
| 1660 | } |
| 1661 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1662 | var GsmFrameNumber fn_last := 0; |
| 1663 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1664 | var OCT1 ra := f_rnd_ra_cs(); |
| 1665 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1666 | if (fn == fn_last) { |
| 1667 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1668 | } |
| 1669 | fn_last := fn; |
| 1670 | } |
| 1671 | |
| 1672 | timer T := 5.0; |
| 1673 | T.start; |
| 1674 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1675 | [] 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] | 1676 | -> value rx_ud { |
| 1677 | var RSL_IE_Body ie; |
| 1678 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1679 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1680 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1681 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1682 | } |
| 1683 | repeat; |
| 1684 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1685 | [] 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] | 1686 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1687 | repeat; |
| 1688 | } |
| 1689 | [] RSL_CCHAN.receive { |
| 1690 | repeat; |
| 1691 | } |
| 1692 | [] T.timeout { } |
| 1693 | } |
| 1694 | if (load_access_count == 1000) { |
| 1695 | setverdict(pass); |
| 1696 | } else { |
| 1697 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1698 | } |
| 1699 | |
| 1700 | f_vty_load_ind_thresh(10); |
| 1701 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1702 | } |
| 1703 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1704 | 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] | 1705 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1706 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1707 | 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] | 1708 | f_sleep(0.5); |
| 1709 | |
| 1710 | /* Transmit RACH request + wait for confirmation */ |
| 1711 | var OCT1 ra := f_rnd_ra_cs(); |
| 1712 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1713 | |
| 1714 | /* Check for expected result */ |
| 1715 | timer T := 1.5; |
| 1716 | T.start; |
| 1717 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1718 | [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] | 1719 | setverdict(pass); |
| 1720 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1721 | [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] | 1722 | 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] | 1723 | } |
| 1724 | [] RSL_CCHAN.receive { repeat; } |
| 1725 | [not expect_pass] T.timeout { |
| 1726 | setverdict(pass); |
| 1727 | } |
| 1728 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1729 | 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] | 1730 | } |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1735 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1736 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1737 | f_init_l1ctl(); |
| 1738 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1739 | f_sleep(1.0); |
| 1740 | |
| 1741 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1742 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1743 | /* We allow early arrival up to 2 symbols */ |
| 1744 | f_rach_toffs(-1*256, true); |
| 1745 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1746 | f_rach_toffs(-10*256, false); |
| 1747 | |
| 1748 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1749 | f_rach_toffs(0, true); |
| 1750 | f_rach_toffs(32*256, true); |
| 1751 | f_rach_toffs(63*256, true); |
| 1752 | |
| 1753 | /* more than 63 bits is not legal / permitted */ |
| 1754 | f_rach_toffs(64*256, false); |
| 1755 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1756 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1757 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1758 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1759 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1760 | var GsmFrameNumber fn; |
| 1761 | var RSL_Message rm; |
| 1762 | |
| 1763 | f_l1_tune(L1CTL); |
| 1764 | RSL.clear; |
| 1765 | |
| 1766 | /* Generate a random Handover Reference */ |
| 1767 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1768 | |
| 1769 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1770 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1771 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1772 | |
| 1773 | /* Activate a channel on the BTS side (no encryption) */ |
| 1774 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1775 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1776 | |
| 1777 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1778 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1779 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1780 | |
| 1781 | /* Send handover Access Burst */ |
| 1782 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1783 | |
| 1784 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1785 | |
| 1786 | /* Wait for handover detection */ |
| 1787 | timer T := 3.0; |
| 1788 | T.start; |
| 1789 | alt { |
| 1790 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1791 | log("Handover RACH has been detected: ", rm); |
| 1792 | setverdict(pass); |
| 1793 | } |
| 1794 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1795 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1796 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1797 | } |
| 1798 | [] RSL.receive { repeat; } |
| 1799 | [] T.timeout { |
| 1800 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1801 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1802 | } |
| 1803 | } |
| 1804 | |
| 1805 | /* Release the channel */ |
| 1806 | f_rsl_chan_deact(); |
| 1807 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1808 | } |
| 1809 | |
| 1810 | /* Test handover RACH detection */ |
| 1811 | testcase TC_ho_rach() runs on test_CT { |
| 1812 | var ConnHdlrPars pars; |
| 1813 | var ConnHdlr vc_conn; |
| 1814 | |
| 1815 | f_init(); |
| 1816 | |
| 1817 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1818 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1819 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1820 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1821 | vc_conn.done; |
| 1822 | } |
| 1823 | |
| 1824 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1825 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1826 | } |
| 1827 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1828 | /*********************************************************************** |
| 1829 | * Measurement Processing / Reporting |
| 1830 | ***********************************************************************/ |
| 1831 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1832 | private template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, 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 | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1840 | private template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1841 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1842 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1843 | len := 0, /* overwritten */ |
| 1844 | m := false, |
| 1845 | el := 1, |
| 1846 | payload := pl |
| 1847 | } |
| 1848 | |
| 1849 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1850 | private altstep as_l1_sacch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1851 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1852 | [] 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] | 1853 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | bc8ebce | 2020-11-11 19:31:56 +0700 | [diff] [blame] | 1854 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp)); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1855 | var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1856 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1857 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1858 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1859 | g_pars.l1_pars.ms_power_level, false, |
| 1860 | g_pars.l1_pars.ms_actual_ta); |
| 1861 | |
| 1862 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1863 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1864 | |
| 1865 | log("Sending Measurement Report: ", l1h, l2); |
| 1866 | 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] | 1867 | repeat; |
| 1868 | } |
| 1869 | } |
| 1870 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 1871 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 1872 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 1873 | boolean do_apply := true) |
| 1874 | runs on ConnHdlr |
| 1875 | { |
| 1876 | var L1ctlDlMessage l1_dl; |
| 1877 | |
| 1878 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 1879 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 1880 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 1881 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 1882 | |
| 1883 | if (do_apply) { |
| 1884 | /* Update TA and MS power to follow what BTS requests */ |
| 1885 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 1886 | } |
| 1887 | } |
| 1888 | } |
| 1889 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 1890 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1891 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1892 | [] 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] | 1893 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1894 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1895 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1896 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1897 | repeat; |
| 1898 | } |
| 1899 | } |
| 1900 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1901 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 1902 | var L1ctlDlMessage l1_dl; |
| 1903 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 1904 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1905 | |
| 1906 | /* occasionaly inject FACCH frames into the uplink */ |
| 1907 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 1908 | var octetstring pl := '010301'O; |
| 1909 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1910 | f_pad_oct(pl, 23, '2B'O))); |
| 1911 | } else { |
| 1912 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 1913 | l1_dl.payload.traffic_ind.data)); |
| 1914 | } |
| 1915 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1916 | repeat; |
| 1917 | } |
| 1918 | } |
| 1919 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1920 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1921 | uint6_t rxlev, |
| 1922 | uint3_t rxqual |
| 1923 | } |
| 1924 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1925 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1926 | MeasElem full, |
| 1927 | MeasElem sub |
| 1928 | } |
| 1929 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1930 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1931 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1932 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1933 | MeasElemFS meas_ul, |
| 1934 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1935 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1936 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1937 | uint8_t ms_actual_ta, |
| 1938 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1939 | } |
| 1940 | |
| 1941 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1942 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1943 | return 63 + (toffs256s/256); |
| 1944 | } |
| 1945 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1946 | private function f_max(integer a, integer b) return integer { |
| 1947 | if (a > b) { |
| 1948 | return a; |
| 1949 | } else { |
| 1950 | return b; |
| 1951 | } |
| 1952 | } |
| 1953 | |
| 1954 | private function f_min(integer a, integer b) return integer { |
| 1955 | if (a < b) { |
| 1956 | return a; |
| 1957 | } else { |
| 1958 | return b; |
| 1959 | } |
| 1960 | } |
| 1961 | |
| 1962 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1963 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1964 | val := val - tolerance; |
| 1965 | return f_max(val, min); |
| 1966 | } |
| 1967 | |
| 1968 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1969 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1970 | val := val + tolerance; |
| 1971 | return f_min(val, max); |
| 1972 | } |
| 1973 | |
| 1974 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1975 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1976 | return template integer { |
| 1977 | var template integer ret; |
| 1978 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1979 | return ret; |
| 1980 | } |
| 1981 | |
| 1982 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1983 | /* build a template for matching measurement results against */ |
| 1984 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1985 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1986 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1987 | len := 3, |
| 1988 | rfu := '0'B, |
| 1989 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1990 | 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] | 1991 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1992 | 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] | 1993 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1994 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1995 | 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] | 1996 | supp_meas_info := omit |
| 1997 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1998 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1999 | ul_meas.len := (3+8); |
| 2000 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2001 | 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] | 2002 | toa256_min := ?, |
| 2003 | toa256_max := ?, |
| 2004 | toa256_std_dev := ? |
| 2005 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2006 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2007 | var template RSL_IE_BS_Power bs_power := { |
| 2008 | reserved := 0, |
| 2009 | epc := false, |
| 2010 | fpc := false, |
| 2011 | power_level := l1p.bs_power_level |
| 2012 | }; |
| 2013 | var template RSL_IE_L1Info l1_info := { |
| 2014 | ms_power_lvl := l1p.ms_power_level, |
| 2015 | fpc := false, |
| 2016 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2017 | 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] | 2018 | }; |
| 2019 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2020 | 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] | 2021 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2022 | ?, t_toffs); |
| 2023 | } |
| 2024 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2025 | /* build a template for matching measurement results that do not contain any |
| 2026 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2027 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2028 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2029 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2030 | len := 3, |
| 2031 | rfu := '0'B, |
| 2032 | dtx_d := l1p.dtx_enabled, |
| 2033 | rxlev_f_u := ?, |
| 2034 | reserved1 := '00'B, |
| 2035 | rxlev_s_u := ?, |
| 2036 | reserved2 := '00'B, |
| 2037 | rxq_f_u := ?, |
| 2038 | rxq_s_u := ?, |
| 2039 | supp_meas_info := omit |
| 2040 | }; |
| 2041 | if (l1p.toa256_enabled) { |
| 2042 | ul_meas.len := (3+8); |
| 2043 | ul_meas.supp_meas_info := { |
| 2044 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2045 | toa256_min := ?, |
| 2046 | toa256_max := ?, |
| 2047 | toa256_std_dev := ? |
| 2048 | } |
| 2049 | } |
| 2050 | var template RSL_IE_BS_Power bs_power := { |
| 2051 | reserved := 0, |
| 2052 | epc := false, |
| 2053 | fpc := false, |
| 2054 | power_level := l1p.bs_power_level |
| 2055 | }; |
| 2056 | |
| 2057 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2058 | } |
| 2059 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2060 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2061 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2062 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2063 | var boolean chan_est := false; |
| 2064 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2065 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2066 | |
| 2067 | /* Receive osmocom specific measurement reports. This is the normal |
| 2068 | * case. Here we verify that the measurement reports we sent are |
| 2069 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2070 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2071 | /* increment counter of next to-be-expected meas rep */ |
| 2072 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2073 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2074 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2075 | |
| 2076 | /* The following two cases may only happen in the beginning |
| 2077 | * of the channel establishment phase. Once we have received |
| 2078 | * the "our" measurement report the first time, the channel |
| 2079 | * is established and empty or hardcoded TRXCON reports must |
| 2080 | * not occur anymore. */ |
| 2081 | chan_est := true; |
| 2082 | |
| 2083 | repeat; |
| 2084 | } |
| 2085 | |
| 2086 | /* When the BTS has established the channel, the MS might need slightly |
| 2087 | * more time to establish the channel and actually start sending. The |
| 2088 | * result is then a measurement report that just lacks the measurement |
| 2089 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2090 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2091 | /* increment counter of next to-be-expected meas rep */ |
| 2092 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2093 | /* Re-start the timer expecting the next MEAS RES */ |
| 2094 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2095 | repeat; |
| 2096 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2097 | |
| 2098 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2099 | * measurements if the TTCN3 side does not supply measurement input in |
| 2100 | * time. In those cases TRXCON will either use a cached measurement |
| 2101 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2102 | * report the templates above will not match. We tolerate this |
| 2103 | * behavior, but only once. */ |
| 2104 | [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] | 2105 | /* increment counter of next to-be-expected meas rep */ |
| 2106 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2107 | if (g_first_meas_res) { |
| 2108 | g_first_meas_res := false; |
| 2109 | repeat; |
| 2110 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2111 | 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] | 2112 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2113 | } |
| 2114 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2115 | 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] | 2116 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2117 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2118 | 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] | 2119 | } |
| 2120 | } |
| 2121 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2122 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2123 | select (rsl_alg_id) { |
| 2124 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2125 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2126 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2127 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2128 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2129 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2130 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2131 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2132 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2134 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2135 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2136 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2137 | } |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2142 | select (rsl_alg_id) { |
| 2143 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2144 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2145 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2146 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2147 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2148 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2149 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2150 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2151 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2152 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2153 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2154 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2155 | } |
| 2156 | } |
| 2157 | } |
| 2158 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2159 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2160 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2161 | var GsmFrameNumber fn; |
| 2162 | timer T := 8.0; |
| 2163 | |
| 2164 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2165 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2166 | |
| 2167 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2168 | /* Send the actual RACH */ |
| 2169 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2170 | |
| 2171 | T.start; |
| 2172 | alt { |
| 2173 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2174 | [] T.timeout { |
| 2175 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2176 | } |
| 2177 | } |
| 2178 | T.stop |
| 2179 | return fn; |
| 2180 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2181 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2182 | /* Tune to a dedicated channel: L1CTL only */ |
| 2183 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2184 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2185 | 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] | 2186 | mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2187 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2188 | 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] | 2189 | pars.fhp.maio_hsn.hsn, |
| 2190 | pars.fhp.maio_hsn.maio, |
| 2191 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2192 | } |
| 2193 | } |
| 2194 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2195 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2196 | 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] | 2197 | var GsmFrameNumber fn; |
| 2198 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2199 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2200 | var integer ra := 23; |
| 2201 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2202 | /* Send RACH request and wait for ChanReq */ |
| 2203 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2204 | |
| 2205 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2206 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2207 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2208 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2209 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2210 | 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] | 2211 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2212 | 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] | 2213 | } |
| 2214 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2215 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2216 | 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] | 2217 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 2218 | |
| 2219 | /* receive IMM.ASS on MS side */ |
| 2220 | var ImmediateAssignment ia_um; |
| 2221 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2222 | |
| 2223 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 2224 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 2225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 2226 | } |
| 2227 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2228 | /* enable dedicated mode */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2229 | 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] | 2230 | /* enable encryption, if requested */ |
| 2231 | if (encr_enable) { |
| 2232 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2233 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2234 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2235 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2236 | /* Send TCH Mode Request to the L1 if needed */ |
| 2237 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2238 | var L1ctlTchMode tch_mode; |
| 2239 | |
| 2240 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2241 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2242 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2243 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2244 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2245 | case else { |
| 2246 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2247 | " is not supported by the L1, falling back to signalling"); |
| 2248 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2253 | } |
| 2254 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2255 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2259 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2260 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2261 | RSL.clear; |
| 2262 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2263 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2264 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2265 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2266 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2267 | |
| 2268 | f_est_dchan(); |
| 2269 | |
| 2270 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2271 | * RSL measurement reports on Abis side */ |
| 2272 | timer T := 8.0; |
| 2273 | T.start; |
| 2274 | alt { |
| 2275 | [] as_l1_sacch(); |
| 2276 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2277 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2278 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2279 | [] L1CTL.receive { repeat; } |
| 2280 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2281 | /* 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] | 2282 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2283 | setverdict(pass); |
| 2284 | } |
| 2285 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2286 | 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] | 2287 | } |
| 2288 | } |
| 2289 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2290 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2291 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2292 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2293 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2294 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2295 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2296 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2297 | timer Tup := 10.0; |
| 2298 | Tup.start; |
| 2299 | alt { |
| 2300 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2301 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2302 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2303 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2304 | if (rx_lvl != max_rx_lvl) { |
| 2305 | repeat; |
| 2306 | } |
| 2307 | Tup.stop; |
| 2308 | } |
| 2309 | [] L1CTL.receive { repeat; } |
| 2310 | [] Tup.timeout { |
| 2311 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2312 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2313 | } |
| 2314 | } |
| 2315 | return max_rx_lvl; |
| 2316 | } |
| 2317 | |
| 2318 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2319 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2320 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2321 | var integer initial_rx_lvl := -1; |
| 2322 | var integer last_rx_lvl := -1; |
| 2323 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2324 | |
| 2325 | timer T := 2.0; |
| 2326 | alt { |
| 2327 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2328 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2329 | log("Received rx_level=", rx_lvl); |
| 2330 | if (initial_rx_lvl == -1) { |
| 2331 | initial_rx_lvl := rx_lvl; |
| 2332 | last_rx_lvl := rx_lvl; |
| 2333 | |
| 2334 | /* Expect a somehow low value during first received messages */ |
| 2335 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2336 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2337 | log2str("Detected high initial tx power during ramp up: ", |
| 2338 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2339 | } |
| 2340 | } |
| 2341 | |
| 2342 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2343 | if (rx_lvl > max_rx_lvl) { |
| 2344 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2345 | log2str("Detected Tx power higher than full power: ", |
| 2346 | rx_lvl , " > ", max_rx_lvl)); |
| 2347 | } |
| 2348 | |
| 2349 | /* Make sure it never decreases, since we are rumping up */ |
| 2350 | if (last_rx_lvl > rx_lvl) { |
| 2351 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2352 | log2str("Detected Tx power decrease during ramp up: ", |
| 2353 | last_rx_lvl , " -> ", rx_lvl)); |
| 2354 | } |
| 2355 | |
| 2356 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2357 | /* We reached the maximum power, start timer and receive |
| 2358 | /* a few more to make sure we don't surpass it */ |
| 2359 | log("Reached full power, wating a bit more until success"); |
| 2360 | T.start; |
| 2361 | } |
| 2362 | |
| 2363 | last_rx_lvl := rx_lvl; |
| 2364 | repeat; |
| 2365 | } |
| 2366 | [] L1CTL.receive { repeat; } |
| 2367 | [] T.timeout { } |
| 2368 | } |
| 2369 | |
| 2370 | /* We didn't increase tx power during ramp up */ |
| 2371 | if (initial_rx_lvl < last_rx_lvl) { |
| 2372 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2373 | } else { |
| 2374 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2375 | log2str("No Tx power increase during whole ramp up: ", |
| 2376 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2377 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | /* verify BTS ramps power down to rx_level 0 */ |
| 2381 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2382 | var L1ctlDlMessage l1_dl; |
| 2383 | var integer last_rx_lvl := max_rx_lvl; |
| 2384 | |
| 2385 | timer Tdown := 5.0; |
| 2386 | Tdown.start; |
| 2387 | alt { |
| 2388 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2389 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2390 | log("Received rx_level=", rx_lvl); |
| 2391 | |
| 2392 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2393 | if (rx_lvl > max_rx_lvl) { |
| 2394 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2395 | log2str("Detected Tx power higher than full power: ", |
| 2396 | rx_lvl , " > ", max_rx_lvl)); |
| 2397 | } |
| 2398 | |
| 2399 | /* Make sure it never increases, since we are rumping down */ |
| 2400 | if (last_rx_lvl < rx_lvl) { |
| 2401 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2402 | log2str("Detected Tx power increase during ramp up: ", |
| 2403 | last_rx_lvl , " -> ", rx_lvl)); |
| 2404 | } |
| 2405 | |
| 2406 | last_rx_lvl := rx_lvl; |
| 2407 | if (last_rx_lvl != 0) { |
| 2408 | repeat; |
| 2409 | } |
| 2410 | /* we reached power level 0, we are done */ |
| 2411 | Tdown.stop; |
| 2412 | } |
| 2413 | [] L1CTL.receive { repeat; } |
| 2414 | [] Tdown.timeout { } |
| 2415 | } |
| 2416 | |
| 2417 | /* We didn't increase tx power during ramp down */ |
| 2418 | if (max_rx_lvl > last_rx_lvl) { |
| 2419 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2420 | } else { |
| 2421 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2422 | log2str("No Tx power decrease during whole ramp down: ", |
| 2423 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2424 | } |
| 2425 | } |
| 2426 | |
| 2427 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2428 | 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] | 2429 | f_l1_tune(L1CTL); |
| 2430 | RSL.clear; |
| 2431 | |
| 2432 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2433 | |
| 2434 | setverdict(pass); |
| 2435 | } |
| 2436 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2437 | var ConnHdlr vc_conn; |
| 2438 | var ConnHdlrPars pars; |
| 2439 | f_init(); |
| 2440 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2441 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2442 | pcu_comp := false, trxc_comp := true); |
| 2443 | vc_conn.done; |
| 2444 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2445 | } |
| 2446 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2447 | /* 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] | 2448 | 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] | 2449 | f_connhdlr_init_vty_bsc(); |
| 2450 | |
| 2451 | f_l1_tune(L1CTL); |
| 2452 | RSL.clear; |
| 2453 | |
| 2454 | /* Wait until BTS is started and at full power */ |
| 2455 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2456 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2457 | |
| 2458 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2459 | f_verify_ramp_down(max_rx_lvl); |
| 2460 | |
| 2461 | setverdict(pass); |
| 2462 | } |
| 2463 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2464 | var ConnHdlr vc_conn; |
| 2465 | var ConnHdlrPars pars; |
| 2466 | f_init(); |
| 2467 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2468 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2469 | pcu_comp := false, trxc_comp := true); |
| 2470 | vc_conn.done; |
| 2471 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2472 | } |
| 2473 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2474 | /* Verify Tx power: |
| 2475 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2476 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2477 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2478 | 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] | 2479 | var L1ctlDlMessage l1_dl; |
| 2480 | var integer last_rx_lvl; |
| 2481 | |
| 2482 | f_connhdlr_init_vty_bsc(); |
| 2483 | |
| 2484 | f_l1_tune(L1CTL); |
| 2485 | RSL.clear; |
| 2486 | |
| 2487 | /* Wait until BTS is started and at full power */ |
| 2488 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2489 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2490 | |
| 2491 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2492 | f_vty_enter_cfg_trx(BSCVTY); |
| 2493 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2494 | last_rx_lvl := max_rx_lvl; |
| 2495 | f_verify_ramp_down(max_rx_lvl); |
| 2496 | |
| 2497 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2498 | * anymore because scheduler has stopped after ramping down */ |
| 2499 | f_sleep(2.0); |
| 2500 | L1CTL.clear; |
| 2501 | timer Tlocked := 2.0; |
| 2502 | Tlocked.start; |
| 2503 | alt { |
| 2504 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2505 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2506 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2507 | } |
| 2508 | [] L1CTL.receive { repeat; } |
| 2509 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2510 | } |
| 2511 | |
| 2512 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2513 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2514 | f_verify_ramp_up(); |
| 2515 | setverdict(pass); |
| 2516 | } |
| 2517 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2518 | var ConnHdlr vc_conn; |
| 2519 | var ConnHdlrPars pars; |
| 2520 | f_init(); |
| 2521 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2522 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2523 | pcu_comp := false, trxc_comp := true); |
| 2524 | vc_conn.done; |
| 2525 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2526 | } |
| 2527 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2528 | 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] | 2529 | timer T := 8.0; |
| 2530 | T.start; |
| 2531 | var RSL_Message rsl; |
| 2532 | alt { |
| 2533 | [] as_l1_sacch(); |
| 2534 | [] L1CTL.receive { repeat; } |
| 2535 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2536 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2537 | setverdict(pass) |
| 2538 | } else { |
| 2539 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2540 | } |
| 2541 | } |
| 2542 | [] T.timeout { |
| 2543 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2544 | } |
| 2545 | } |
| 2546 | } |
| 2547 | |
| 2548 | /* see if the rsl meas res contains our expeced bs power level |
| 2549 | bs power set during assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2550 | 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] | 2551 | f_l1_tune(L1CTL); |
| 2552 | RSL.clear; |
| 2553 | |
| 2554 | if (mp_bts_trxc_port != -1) { |
| 2555 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2556 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2557 | } |
| 2558 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2559 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2560 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2561 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2562 | |
| 2563 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2564 | |
| 2565 | f_check_meas_bs_power_level(pwr_var); |
| 2566 | |
| 2567 | f_rsl_chan_deact(); |
| 2568 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2569 | } |
| 2570 | |
| 2571 | /* see if the rsl meas res contains our expeced bs power level |
| 2572 | bs power set after assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2573 | 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] | 2574 | f_l1_tune(L1CTL); |
| 2575 | RSL.clear; |
| 2576 | |
| 2577 | if (mp_bts_trxc_port != -1) { |
| 2578 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2579 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2580 | } |
| 2581 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2582 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2583 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2584 | |
| 2585 | f_est_dchan(); |
| 2586 | |
| 2587 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2588 | |
| 2589 | f_check_meas_bs_power_level(pwr_var); |
| 2590 | |
| 2591 | f_rsl_chan_deact(); |
| 2592 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2593 | } |
| 2594 | |
| 2595 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2596 | var ConnHdlr vc_conn; |
| 2597 | var ConnHdlrPars pars; |
| 2598 | f_init(); |
| 2599 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2600 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2601 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2602 | pcu_comp := false, trxc_comp := true); |
| 2603 | vc_conn.done; |
| 2604 | } |
| 2605 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2606 | } |
| 2607 | |
| 2608 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2609 | var ConnHdlr vc_conn; |
| 2610 | var ConnHdlrPars pars; |
| 2611 | f_init(); |
| 2612 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2613 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2614 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2615 | pcu_comp := false, trxc_comp := true); |
| 2616 | vc_conn.done; |
| 2617 | } |
| 2618 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2619 | } |
| 2620 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2621 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2622 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2623 | 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] | 2624 | 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] | 2625 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2626 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2627 | |
| 2628 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2629 | f_l1_tune(L1CTL); |
| 2630 | RSL.clear; |
| 2631 | |
| 2632 | var RSL_IE_List addl_ies; |
| 2633 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2634 | |
| 2635 | addl_ies := { |
| 2636 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2637 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2638 | }; |
| 2639 | |
| 2640 | /* establish with power parameters */ |
| 2641 | f_est_dchan(more_ies := addl_ies); |
| 2642 | |
| 2643 | /* set a high value to ensure L1 power control level increases */ |
| 2644 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2645 | |
| 2646 | timer T2 := 6.0; |
| 2647 | T2.start; |
| 2648 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2649 | [] as_l1_sacch_l1h(l1h) { |
| 2650 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2651 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2652 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2653 | T2.stop; |
| 2654 | } |
| 2655 | [] L1CTL.receive { repeat; } |
| 2656 | [] T2.timeout { |
| 2657 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2658 | "Power Level in L1 header has not increased sufficiently"); |
| 2659 | } |
| 2660 | } |
| 2661 | |
| 2662 | /* set a low value to ensure L1 power control level decreases */ |
| 2663 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2664 | |
| 2665 | timer T4 := 6.0; |
| 2666 | T4.start; |
| 2667 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2668 | [] as_l1_sacch_l1h(l1h) { |
| 2669 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2670 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2671 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2672 | T4.stop; |
| 2673 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2674 | } |
| 2675 | [] L1CTL.receive { repeat; } |
| 2676 | [] T4.timeout { |
| 2677 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2678 | "Power Level in L1 header has not decreased sufficiently"); |
| 2679 | } |
| 2680 | } |
| 2681 | |
| 2682 | f_rsl_chan_deact(); |
| 2683 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2684 | |
| 2685 | } |
| 2686 | |
| 2687 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2688 | 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] | 2689 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2690 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2691 | |
| 2692 | /* set a low value to ensure power increases */ |
| 2693 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2694 | f_l1_tune(L1CTL); |
| 2695 | RSL.clear; |
| 2696 | |
| 2697 | var RSL_IE_List addl_ies; |
| 2698 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2699 | |
| 2700 | addl_ies := { |
| 2701 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2702 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2703 | }; |
| 2704 | |
| 2705 | /* establish with power parameters */ |
| 2706 | f_est_dchan(more_ies := addl_ies); |
| 2707 | |
| 2708 | timer T1 := 10.0; |
| 2709 | T1.start; |
| 2710 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2711 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2712 | [] L1CTL.receive { repeat; } |
| 2713 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2714 | if (not isbound(l1h)) { |
| 2715 | setverdict(fail, "No SACCH blocks were received"); |
| 2716 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2717 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2718 | } |
| 2719 | } |
| 2720 | } |
| 2721 | |
| 2722 | f_rsl_chan_deact(); |
| 2723 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2724 | |
| 2725 | } |
| 2726 | |
| 2727 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2728 | 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] | 2729 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2730 | var uint5_t pwr_var := 15; |
| 2731 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2732 | |
| 2733 | /* set a low value to ensure power increases */ |
| 2734 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2735 | f_l1_tune(L1CTL); |
| 2736 | RSL.clear; |
| 2737 | |
| 2738 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2739 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2740 | |
| 2741 | /* establish with fixed power level */ |
| 2742 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2743 | |
| 2744 | /* check our initial power level */ |
| 2745 | f_wait_for_l1_power_level(pwr_var); |
| 2746 | |
| 2747 | /* update power param to enable power loop |
| 2748 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2749 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2750 | |
| 2751 | /* wait, then check that our power level was reduced */ |
| 2752 | timer T1 := 10.0; |
| 2753 | T1.start; |
| 2754 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2755 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2756 | [] L1CTL.receive { repeat; } |
| 2757 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2758 | if (not isbound(l1h)) { |
| 2759 | setverdict(fail, "No SACCH blocks were received"); |
| 2760 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2761 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2762 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2763 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 2764 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2765 | } |
| 2766 | } |
| 2767 | } |
| 2768 | |
| 2769 | f_rsl_chan_deact(); |
| 2770 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2771 | |
| 2772 | } |
| 2773 | |
| 2774 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2775 | 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] | 2776 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2777 | |
| 2778 | /* set a high value to ensure power decreases */ |
| 2779 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2780 | f_l1_tune(L1CTL); |
| 2781 | RSL.clear; |
| 2782 | |
| 2783 | var uint5_t pwr_var := 5; |
| 2784 | var uint5_t pwr_target_val := 15; |
| 2785 | |
| 2786 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2787 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2788 | |
| 2789 | /* establish with fixed power level */ |
| 2790 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2791 | |
| 2792 | /* check our initial power level */ |
| 2793 | f_wait_for_l1_power_level(pwr_var); |
| 2794 | |
| 2795 | /* update power param to enable power loop |
| 2796 | 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] | 2797 | 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] | 2798 | |
| 2799 | /* wait, then check that our power level was increased */ |
| 2800 | timer T1 := 10.0; |
| 2801 | T1.start; |
| 2802 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2803 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2804 | [] L1CTL.receive { repeat; } |
| 2805 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2806 | if (not isbound(l1h)) { |
| 2807 | setverdict(fail, "No SACCH blocks were received"); |
| 2808 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 2809 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2810 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2811 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2812 | } |
| 2813 | } |
| 2814 | } |
| 2815 | |
| 2816 | f_rsl_chan_deact(); |
| 2817 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2818 | |
| 2819 | } |
| 2820 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2821 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2822 | rsl chan act WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2823 | 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] | 2824 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2825 | |
| 2826 | /* set a high value to ensure power decreases */ |
| 2827 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2828 | f_l1_tune(L1CTL); |
| 2829 | RSL.clear; |
| 2830 | |
| 2831 | var uint5_t pwr_var := 5; |
| 2832 | |
| 2833 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2834 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2835 | |
| 2836 | /* establish with fixed power level */ |
| 2837 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2838 | |
| 2839 | /* check our initial power level */ |
| 2840 | f_wait_for_l1_power_level(pwr_var); |
| 2841 | |
| 2842 | /* wait, then check that our power level did not change */ |
| 2843 | timer T1 := 10.0; |
| 2844 | T1.start; |
| 2845 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2846 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2847 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2848 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2849 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2850 | } |
| 2851 | repeat; |
| 2852 | } |
| 2853 | [] L1CTL.receive { repeat; } |
| 2854 | [] T1.timeout { setverdict(pass); } |
| 2855 | } |
| 2856 | |
| 2857 | f_rsl_chan_deact(); |
| 2858 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2859 | |
| 2860 | } |
| 2861 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2862 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2863 | ms power control WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2864 | 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] | 2865 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2866 | |
| 2867 | /* set a high value to ensure power decreases */ |
| 2868 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2869 | f_l1_tune(L1CTL); |
| 2870 | RSL.clear; |
| 2871 | |
| 2872 | var uint5_t pwr_var := 5; |
| 2873 | |
| 2874 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2875 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2876 | |
| 2877 | /* establish with fixed power level */ |
| 2878 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2879 | |
| 2880 | /* check our initial power level */ |
| 2881 | f_wait_for_l1_power_level(pwr_var); |
| 2882 | |
| 2883 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2884 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2885 | |
| 2886 | /* wait, then check that our power level did not change */ |
| 2887 | timer T1 := 10.0; |
| 2888 | T1.start; |
| 2889 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2890 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2891 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2892 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2893 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2894 | } |
| 2895 | repeat; |
| 2896 | } |
| 2897 | [] L1CTL.receive { repeat; } |
| 2898 | [] T1.timeout { setverdict(pass); } |
| 2899 | } |
| 2900 | |
| 2901 | f_rsl_chan_deact(); |
| 2902 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2903 | |
| 2904 | } |
| 2905 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2906 | 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] | 2907 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2908 | timer T0 := 10.0; |
| 2909 | T0.start; |
| 2910 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2911 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 2912 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2913 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2914 | "Power level in L1 header != signaled (RSL) power level."); |
| 2915 | } |
| 2916 | } |
| 2917 | [] L1CTL.receive { repeat; } |
| 2918 | [] T0.timeout { |
| 2919 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2920 | "Timeout waiting for initial power level"); |
| 2921 | } |
| 2922 | } |
| 2923 | T0.stop; |
| 2924 | } |
| 2925 | |
| 2926 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2927 | var IntegerRecord min_dbm_level; |
| 2928 | var IntegerRecord max_dbm_level; |
| 2929 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2930 | |
| 2931 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2932 | if (min_dbm_level[i] == level) { |
| 2933 | return true; |
| 2934 | } |
| 2935 | } |
| 2936 | return false; |
| 2937 | } |
| 2938 | |
| 2939 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2940 | var IntegerRecord min_dbm_level; |
| 2941 | var IntegerRecord max_dbm_level; |
| 2942 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2943 | |
| 2944 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2945 | if (max_dbm_level[i] == level) { |
| 2946 | return true; |
| 2947 | } |
| 2948 | } |
| 2949 | return false; |
| 2950 | } |
| 2951 | |
| 2952 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2953 | var IntegerRecord min_dbm_level; |
| 2954 | var IntegerRecord max_dbm_level; |
| 2955 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2956 | return max_dbm_level[0]; |
| 2957 | } |
| 2958 | |
| 2959 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2960 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2961 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2962 | // 45.005 4.1.1 |
| 2963 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2964 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2965 | 2, 1, 0}; |
| 2966 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2967 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2968 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2969 | var IntegerRecord rv; |
| 2970 | |
| 2971 | select(band){ |
| 2972 | case (BtsBand_allGSM){ |
| 2973 | rv := gsm_power; |
| 2974 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2975 | max_dbm_level := {2, 1, 0}; |
| 2976 | } |
| 2977 | case("DCS1800"){ |
| 2978 | rv := dcs_power; |
| 2979 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2980 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2981 | } |
| 2982 | case("PCS1900"){ |
| 2983 | rv := pcs_power; |
| 2984 | min_dbm_level := {15}; |
| 2985 | max_dbm_level := {30}; |
| 2986 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 2987 | case else { |
| 2988 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 2989 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2990 | } |
| 2991 | |
| 2992 | return rv; |
| 2993 | } |
| 2994 | |
| 2995 | 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] | 2996 | 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] | 2997 | } |
| 2998 | |
| 2999 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3000 | var ConnHdlr vc_conn; |
| 3001 | var ConnHdlrPars pars; |
| 3002 | f_init(); |
| 3003 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3004 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3005 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3006 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3007 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3008 | vc_conn.done; |
| 3009 | } |
| 3010 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3011 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3012 | } |
| 3013 | |
| 3014 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3015 | var ConnHdlr vc_conn; |
| 3016 | var ConnHdlrPars pars; |
| 3017 | f_init(); |
| 3018 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3019 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3020 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3021 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3022 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3023 | vc_conn.done; |
| 3024 | } |
| 3025 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3026 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3027 | } |
| 3028 | |
| 3029 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3030 | var ConnHdlr vc_conn; |
| 3031 | var ConnHdlrPars pars; |
| 3032 | f_init(); |
| 3033 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3034 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3035 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3036 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3037 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3038 | vc_conn.done; |
| 3039 | } |
| 3040 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3041 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3042 | } |
| 3043 | |
| 3044 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3045 | var ConnHdlr vc_conn; |
| 3046 | var ConnHdlrPars pars; |
| 3047 | f_init(); |
| 3048 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3049 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3050 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3051 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3052 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3053 | vc_conn.done; |
| 3054 | } |
| 3055 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3056 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3057 | } |
| 3058 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3059 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3060 | var ConnHdlr vc_conn; |
| 3061 | var ConnHdlrPars pars; |
| 3062 | f_init(); |
| 3063 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3064 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3065 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3066 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3067 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3068 | vc_conn.done; |
| 3069 | } |
| 3070 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3071 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3072 | } |
| 3073 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3074 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3075 | var ConnHdlr vc_conn; |
| 3076 | var ConnHdlrPars pars; |
| 3077 | f_init(); |
| 3078 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3079 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3080 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3081 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3082 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3083 | vc_conn.done; |
| 3084 | } |
| 3085 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3086 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3087 | } |
| 3088 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3089 | 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] | 3090 | var template RSL_IE_ChannelMode ch_mode; |
| 3091 | var ConnHdlr vc_conn; |
| 3092 | var ConnHdlrPars pars; |
| 3093 | f_init(); |
| 3094 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3095 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3096 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3097 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3098 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3099 | pcu_comp := false, trxc_comp := true); |
| 3100 | vc_conn.done; |
| 3101 | } |
| 3102 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3103 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3104 | |
| 3105 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3106 | f_TC_meas_res_speech_tchf(false); |
| 3107 | } |
| 3108 | |
| 3109 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3110 | f_TC_meas_res_speech_tchf(true); |
| 3111 | } |
| 3112 | |
| 3113 | 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] | 3114 | var template RSL_IE_ChannelMode ch_mode; |
| 3115 | var ConnHdlr vc_conn; |
| 3116 | var ConnHdlrPars pars; |
| 3117 | f_init(); |
| 3118 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3119 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3120 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3121 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3122 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3123 | pcu_comp := false, trxc_comp := true); |
| 3124 | vc_conn.done; |
| 3125 | } |
| 3126 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3127 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3128 | |
| 3129 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3130 | f_TC_meas_res_speech_tchh(false) |
| 3131 | } |
| 3132 | |
| 3133 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3134 | f_TC_meas_res_speech_tchh(true) |
| 3135 | } |
| 3136 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3137 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3138 | var template RSL_IE_ChannelMode ch_mode; |
| 3139 | var ConnHdlr vc_conn; |
| 3140 | var ConnHdlrPars pars; |
| 3141 | f_init(); |
| 3142 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3143 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3144 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3145 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3146 | pars.l1_pars.toa256_enabled := true; |
| 3147 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3148 | pcu_comp := false, trxc_comp := true); |
| 3149 | vc_conn.done; |
| 3150 | } |
| 3151 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3152 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3153 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3154 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3155 | var ConnHdlr vc_conn; |
| 3156 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3157 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3158 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3159 | 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] | 3160 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3161 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3162 | vc_conn.done; |
| 3163 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3164 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3165 | } |
| 3166 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3167 | var ConnHdlr vc_conn; |
| 3168 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3169 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3170 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3171 | 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] | 3172 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3173 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3174 | vc_conn.done; |
| 3175 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3176 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3177 | } |
| 3178 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3179 | var ConnHdlr vc_conn; |
| 3180 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3181 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3182 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3183 | 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] | 3184 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3185 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3186 | vc_conn.done; |
| 3187 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3188 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3189 | } |
| 3190 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3191 | var ConnHdlr vc_conn; |
| 3192 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3193 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3194 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3195 | 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] | 3196 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3197 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3198 | vc_conn.done; |
| 3199 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3200 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3201 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3202 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3203 | var ConnHdlr vc_conn; |
| 3204 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3205 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3206 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3207 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3208 | 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] | 3209 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3210 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3211 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3212 | vc_conn.done; |
| 3213 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3214 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3215 | } |
| 3216 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3217 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3218 | * 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] | 3219 | 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] | 3220 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3221 | var RSL_IE_MS_Power ms_power; |
| 3222 | var RSL_Message rsl; |
| 3223 | var uint5_t power_level := 0; |
| 3224 | |
| 3225 | f_l1_tune(L1CTL); |
| 3226 | RSL.clear; |
| 3227 | |
| 3228 | f_est_dchan(); |
| 3229 | |
| 3230 | ms_power.reserved := 0; |
| 3231 | ms_power.fpc_epc := false; |
| 3232 | |
| 3233 | /* Send the first power control command. This will disable any BTS/TRX |
| 3234 | * internal power control and switch the MS (which is not in scope of |
| 3235 | * this test) to a constant power level. We start with a power level |
| 3236 | * of 0 */ |
| 3237 | ms_power.power_level := power_level; |
| 3238 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3239 | RSL.send(rsl); |
| 3240 | |
| 3241 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3242 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3243 | if (l1h.ms_power_lvl != power_level) { |
| 3244 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3245 | "match the signaled (RSL) power level := ", power_level); |
| 3246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3247 | } |
| 3248 | |
| 3249 | /* Signal a new power level via RSL for the next turn. */ |
| 3250 | if (power_level < 31) { |
| 3251 | power_level := power_level + 1; |
| 3252 | ms_power.power_level := power_level; |
| 3253 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3254 | RSL.send(rsl); |
| 3255 | repeat; |
| 3256 | } |
| 3257 | |
| 3258 | } |
| 3259 | |
| 3260 | /* Ignore all other blocks */ |
| 3261 | [] L1CTL.receive { repeat; } |
| 3262 | |
| 3263 | } |
| 3264 | |
| 3265 | f_rsl_chan_deact(); |
| 3266 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3267 | |
| 3268 | setverdict(pass); |
| 3269 | } |
| 3270 | |
| 3271 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3272 | var ConnHdlr vc_conn; |
| 3273 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3274 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3275 | |
| 3276 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3277 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3278 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3279 | vc_conn.done; |
| 3280 | } |
| 3281 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3282 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3283 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3284 | /* 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] | 3285 | 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] | 3286 | 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] | 3287 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3288 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3289 | |
| 3290 | f_l1_tune(L1CTL); |
| 3291 | RSL.clear; |
| 3292 | |
| 3293 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3294 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3295 | |
| 3296 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3297 | |
| 3298 | |
| 3299 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3300 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3301 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3302 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3303 | } |
| 3304 | |
| 3305 | } |
| 3306 | |
| 3307 | /* Ignore all other blocks */ |
| 3308 | [] L1CTL.receive { repeat; } |
| 3309 | |
| 3310 | } |
| 3311 | |
| 3312 | f_rsl_chan_deact(); |
| 3313 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3314 | |
| 3315 | setverdict(pass); |
| 3316 | } |
| 3317 | |
| 3318 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3319 | var ConnHdlr vc_conn; |
| 3320 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3321 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3322 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3323 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3324 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3325 | vc_conn.done; |
| 3326 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3327 | } |
| 3328 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3329 | /* 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] | 3330 | 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] | 3331 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3332 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3333 | |
| 3334 | var RSL_IE_MS_Power ms_power; |
| 3335 | ms_power.reserved := 0; |
| 3336 | ms_power.fpc_epc := false; |
| 3337 | ms_power.power_level := ms_power_level; |
| 3338 | |
| 3339 | f_l1_tune(L1CTL); |
| 3340 | RSL.clear; |
| 3341 | |
| 3342 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3343 | |
| 3344 | timer T := 1.0; |
| 3345 | T.start; |
| 3346 | alt { |
| 3347 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3348 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3349 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3350 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3351 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3352 | } |
| 3353 | } |
| 3354 | /* Ignore all other blocks */ |
| 3355 | [] L1CTL.receive { repeat; } |
| 3356 | [] T.timeout { |
| 3357 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3358 | } |
| 3359 | } |
| 3360 | |
| 3361 | f_rsl_chan_deact(); |
| 3362 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3363 | setverdict(pass); |
| 3364 | } |
| 3365 | |
| 3366 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3367 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3368 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3369 | } |
| 3370 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3371 | /* 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] | 3372 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3373 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3374 | RSL.clear; |
| 3375 | |
| 3376 | f_est_dchan(); |
| 3377 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3378 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3379 | |
| 3380 | timer T := 40.0; |
| 3381 | T.start; |
| 3382 | alt { |
| 3383 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3384 | setverdict(pass) |
| 3385 | } |
| 3386 | [] RSL.receive { repeat }; |
| 3387 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3388 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3389 | } |
| 3390 | } |
| 3391 | f_rsl_chan_deact(); |
| 3392 | } |
| 3393 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3394 | var ConnHdlr vc_conn; |
| 3395 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3396 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3397 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3398 | pars.t_guard := 60.0; |
| 3399 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3400 | vc_conn.done; |
| 3401 | } |
| 3402 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3403 | /*********************************************************************** |
| 3404 | * Paging |
| 3405 | ***********************************************************************/ |
| 3406 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3407 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3408 | if (tmsi == 'FFFFFFFF'O) { |
| 3409 | return true; |
| 3410 | } else { |
| 3411 | return false; |
| 3412 | } |
| 3413 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3414 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3415 | private type record allowedFn { integer frame_nr } |
| 3416 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3417 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3418 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3419 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3420 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3421 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3422 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3423 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3424 | 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] | 3425 | { |
| 3426 | var integer frame_nr_51; |
| 3427 | frame_nr_51 := frame_nr mod 51 |
| 3428 | |
| 3429 | var allowedFn fn_check; |
| 3430 | fn_check.frame_nr := frame_nr_51; |
| 3431 | |
| 3432 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3433 | 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] | 3434 | return; |
| 3435 | } |
| 3436 | |
| 3437 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3438 | return; |
| 3439 | } |
| 3440 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3441 | return; |
| 3442 | } |
| 3443 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3444 | return; |
| 3445 | } |
| 3446 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3447 | return; |
| 3448 | } |
| 3449 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3450 | return; |
| 3451 | } |
| 3452 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3453 | return; |
| 3454 | } |
| 3455 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3456 | return; |
| 3457 | } |
| 3458 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3459 | return; |
| 3460 | } |
| 3461 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3462 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3463 | return; |
| 3464 | } |
| 3465 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3466 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3467 | inout integer num_paging_rcv_ids, |
| 3468 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3469 | runs on test_CT { |
| 3470 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3471 | [] 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] | 3472 | repeat; |
| 3473 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3474 | [] 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] | 3475 | var octetstring without_plen := |
| 3476 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3477 | 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] | 3478 | |
| 3479 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3480 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3481 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3482 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3483 | * TODO: does it make sense to count them? */ |
| 3484 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3485 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3486 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3487 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3488 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3489 | } |
| 3490 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3491 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3492 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3493 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3494 | } |
| 3495 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3496 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3497 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3498 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
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_REQ3)) { |
| 3502 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3503 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3504 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3505 | } |
| 3506 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3507 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3508 | } |
| 3509 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3510 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3511 | } |
| 3512 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3513 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3514 | } |
| 3515 | } |
| 3516 | repeat; |
| 3517 | } |
| 3518 | } |
| 3519 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3520 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3521 | boolean combined_ccch, |
| 3522 | integer bs_ag_blks_res, |
| 3523 | float load_factor, |
| 3524 | boolean exp_load_ind, |
| 3525 | boolean exp_overload, |
| 3526 | boolean use_tmsi |
| 3527 | } |
| 3528 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3529 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3530 | integer num_paging_sent, |
| 3531 | integer num_paging_rcv_msgs, |
| 3532 | integer num_paging_rcv_ids, |
| 3533 | integer num_overload |
| 3534 | } |
| 3535 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3536 | /* Helper function for paging related testing */ |
| 3537 | 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] | 3538 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3539 | f_init_l1ctl(); |
| 3540 | f_l1_tune(L1CTL); |
| 3541 | |
| 3542 | var PagingTestState st := { |
| 3543 | num_paging_sent := 0, |
| 3544 | num_paging_rcv_msgs := 0, |
| 3545 | num_paging_rcv_ids := 0, |
| 3546 | num_overload := 0 |
| 3547 | }; |
| 3548 | |
| 3549 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3550 | var float max_pch_imsi_per_sec; |
| 3551 | if (cfg.use_tmsi) { |
| 3552 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3553 | } else { |
| 3554 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3555 | } |
| 3556 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3557 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3558 | var float time_total := 20.0; |
| 3559 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3560 | 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] | 3561 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3562 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3563 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3564 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3565 | timer T_itv := 0.0; |
| 3566 | T_itv.start; |
| 3567 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3568 | alt { |
| 3569 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3570 | [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] | 3571 | st.num_overload := st.num_overload + 1; |
| 3572 | repeat; |
| 3573 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3574 | [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] | 3575 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3576 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3577 | [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] | 3578 | log("Rx LOAD_IND"); |
| 3579 | /* FIXME: analyze/verify interval + contents */ |
| 3580 | repeat; |
| 3581 | } |
| 3582 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3583 | [] 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] | 3584 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3585 | [] T_itv.timeout { |
| 3586 | /* Send paging cmds based on elapsed time */ |
| 3587 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3588 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3589 | var MobileIdentityV mi; |
| 3590 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3591 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3592 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3593 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3594 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3595 | 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] | 3596 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3597 | |
| 3598 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3599 | 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] | 3600 | |
| 3601 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3602 | } |
| 3603 | if (st.num_paging_sent < pkt_total) { |
| 3604 | /* Wait for interval to next PAGING COMMAND */ |
| 3605 | var float time_now := T_total.read; |
| 3606 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3607 | if (next_sched > time_now) { |
| 3608 | T_itv.start(next_sched - time_now); |
| 3609 | } else { |
| 3610 | T_itv.start(0.0); |
| 3611 | } |
| 3612 | } else { |
| 3613 | /* We are done, no need to keep counting */ |
| 3614 | T_total.stop; |
| 3615 | } |
| 3616 | } |
| 3617 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3618 | } |
| 3619 | } |
| 3620 | |
| 3621 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3622 | timer T_wait := 18.0; |
| 3623 | T_wait.start; |
| 3624 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3625 | [] 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] | 3626 | [] L1CTL.receive { repeat; } |
| 3627 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3628 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3629 | [] 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] | 3630 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3631 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3632 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3633 | } |
| 3634 | |
| 3635 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3636 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3637 | return st; |
| 3638 | } |
| 3639 | |
| 3640 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3641 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3642 | * - that CCCH LOAD IND (PCH) are being generated |
| 3643 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3644 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3645 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3646 | var PagingTestCfg cfg := { |
| 3647 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3648 | 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] | 3649 | load_factor := 0.8, |
| 3650 | exp_load_ind := true, |
| 3651 | exp_overload := false, |
| 3652 | use_tmsi := false |
| 3653 | }; |
| 3654 | var PagingTestState st := f_TC_paging(cfg); |
| 3655 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3656 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3657 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3658 | } else { |
| 3659 | setverdict(pass); |
| 3660 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3661 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3662 | } |
| 3663 | |
| 3664 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3665 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3666 | * - that CCCH LOAD IND (PCH) are being generated |
| 3667 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3668 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3669 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3670 | var PagingTestCfg cfg := { |
| 3671 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3672 | 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] | 3673 | load_factor := 0.8, |
| 3674 | exp_load_ind := true, |
| 3675 | exp_overload := false, |
| 3676 | use_tmsi := true |
| 3677 | }; |
| 3678 | var PagingTestState st := f_TC_paging(cfg); |
| 3679 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3680 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3681 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3682 | } else { |
| 3683 | setverdict(pass); |
| 3684 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3685 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3686 | } |
| 3687 | |
| 3688 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3689 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3690 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3691 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3692 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3693 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3694 | var PagingTestCfg cfg := { |
| 3695 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3696 | 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] | 3697 | load_factor := 2.0, |
| 3698 | exp_load_ind := true, |
| 3699 | exp_overload := true, |
| 3700 | use_tmsi := false |
| 3701 | }; |
| 3702 | var PagingTestState st := f_TC_paging(cfg); |
| 3703 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3704 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3705 | 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] | 3706 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3707 | 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] | 3708 | } else { |
| 3709 | setverdict(pass); |
| 3710 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3711 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3712 | } |
| 3713 | |
| 3714 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3715 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3716 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3717 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3718 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3719 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3720 | var PagingTestCfg cfg := { |
| 3721 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3722 | 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] | 3723 | load_factor := 2.0, |
| 3724 | exp_load_ind := true, |
| 3725 | exp_overload := true, |
| 3726 | use_tmsi := true |
| 3727 | }; |
| 3728 | var PagingTestState st := f_TC_paging(cfg); |
| 3729 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3730 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3731 | 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] | 3732 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3733 | 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] | 3734 | } else { |
| 3735 | setverdict(pass); |
| 3736 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3737 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3738 | } |
| 3739 | |
| 3740 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3741 | /*********************************************************************** |
| 3742 | * Immediate Assignment / AGCH |
| 3743 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 3744 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3745 | len := 0, |
| 3746 | ma := ''B |
| 3747 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3748 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3749 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3750 | return int2str(num_tx) & " sent, " |
| 3751 | & int2str(num_rx) & " received, " |
| 3752 | & int2str(num_del) & " deleted"; |
| 3753 | } |
| 3754 | |
| 3755 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3756 | var L1ctlDlMessage l1_dl; |
| 3757 | timer T := 10.0; |
| 3758 | var integer num_tx := 0; |
| 3759 | var integer num_rx := 0; |
| 3760 | var integer num_del := 0; |
| 3761 | var charstring res_str; |
| 3762 | var float rx_ratio; |
| 3763 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3764 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3765 | f_init_l1ctl(); |
| 3766 | f_l1_tune(L1CTL); |
| 3767 | |
| 3768 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 3769 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 3770 | mp_trx_pars[0].arfcn, |
| 3771 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3772 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3773 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3774 | 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] | 3775 | num_tx := num_tx+1; |
| 3776 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3777 | } |
| 3778 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3779 | T.start; |
| 3780 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3781 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3782 | num_del := num_del+1; |
| 3783 | repeat; |
| 3784 | } |
| 3785 | [] RSL_CCHAN.receive { |
| 3786 | repeat; |
| 3787 | } |
| 3788 | [] 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] | 3789 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3790 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3791 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3792 | //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] | 3793 | } else { |
| 3794 | num_rx := num_rx+1; |
| 3795 | } |
| 3796 | repeat; |
| 3797 | } |
| 3798 | [] L1CTL.receive { repeat; } |
| 3799 | [] T.timeout { } |
| 3800 | } |
| 3801 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3802 | log("AGCH test: " & res_str); |
| 3803 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3804 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3805 | } |
| 3806 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3807 | 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] | 3808 | 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] | 3809 | } else { |
| 3810 | setverdict(pass); |
| 3811 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3812 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3813 | } |
| 3814 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3815 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3816 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3817 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3818 | } |
| 3819 | |
| 3820 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3821 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3822 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3823 | } |
| 3824 | |
| 3825 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3826 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3827 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3828 | } |
| 3829 | |
| 3830 | |
| 3831 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3832 | /*********************************************************************** |
| 3833 | * BCCH |
| 3834 | ***********************************************************************/ |
| 3835 | |
| 3836 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3837 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3838 | GsmFrameNumber frame_number, |
| 3839 | SystemInformation si |
| 3840 | } |
| 3841 | |
| 3842 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3843 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3844 | |
| 3845 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3846 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3847 | |
| 3848 | /* 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] | 3849 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 3850 | RrMessageType key, |
| 3851 | boolean bcch_ext := false) |
| 3852 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3853 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3854 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3855 | if (not bcch_ext and fn_mod51 == 2 or |
| 3856 | bcch_ext and fn_mod51 == 6) { |
| 3857 | if (arr[i].si.header.message_type == key) { |
| 3858 | return true; |
| 3859 | } |
| 3860 | } |
| 3861 | } |
| 3862 | return false; |
| 3863 | } |
| 3864 | |
| 3865 | /* 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] | 3866 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3867 | integer tc, RrMessageType key, |
| 3868 | boolean ext_bcch := false) |
| 3869 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3870 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3871 | 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] | 3872 | } |
| 3873 | } |
| 3874 | |
| 3875 | /* 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] | 3876 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3877 | RrMessageType key) |
| 3878 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3879 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3880 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3881 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3882 | return true; |
| 3883 | } |
| 3884 | } |
| 3885 | return false; |
| 3886 | } |
| 3887 | |
| 3888 | /* 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] | 3889 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 3890 | RrMessageType key, |
| 3891 | boolean bcch_ext := false, |
| 3892 | integer n := 1, integer m := 4) |
| 3893 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3894 | var integer count := 0; |
| 3895 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 3896 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 3897 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3898 | } |
| 3899 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3900 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3901 | if (not bcch_ext and fn_mod51 == 2 or |
| 3902 | bcch_ext and fn_mod51 == 6) { |
| 3903 | if (arr[i].si.header.message_type == key) { |
| 3904 | count := count + 1; |
| 3905 | } |
| 3906 | } |
| 3907 | } |
| 3908 | if (count >= n) { |
| 3909 | return true; |
| 3910 | } else { |
| 3911 | return false; |
| 3912 | } |
| 3913 | } |
| 3914 | |
| 3915 | /* 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] | 3916 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 3917 | integer tc, RrMessageType key, |
| 3918 | boolean ext_bcch := false, |
| 3919 | integer n, integer m) |
| 3920 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3921 | 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] | 3922 | 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] | 3923 | } |
| 3924 | } |
| 3925 | |
| 3926 | /* 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] | 3927 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 3928 | RrMessageType key, |
| 3929 | boolean bcch_ext := false) |
| 3930 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3931 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3932 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3933 | if (not bcch_ext and fn_mod51 == 2 or |
| 3934 | bcch_ext and fn_mod51 == 6) { |
| 3935 | if (arr[i].si.header.message_type != key) { |
| 3936 | return false; |
| 3937 | } |
| 3938 | } |
| 3939 | } |
| 3940 | return true; |
| 3941 | } |
| 3942 | |
| 3943 | /* 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] | 3944 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 3945 | integer tc, RrMessageType key, |
| 3946 | boolean ext_bcch := false) |
| 3947 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3948 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3949 | 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] | 3950 | } |
| 3951 | } |
| 3952 | |
| 3953 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3954 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3955 | boolean bcch_extended, |
| 3956 | boolean si1_present, |
| 3957 | boolean si2bis_present, |
| 3958 | boolean si2ter_present, |
| 3959 | boolean si2quater_present, |
| 3960 | boolean si7_present, |
| 3961 | boolean si8_present, |
| 3962 | boolean si9_present, |
| 3963 | boolean si13_present, |
| 3964 | boolean si13alt_present, |
| 3965 | boolean si15_present, |
| 3966 | boolean si16_present, |
| 3967 | boolean si17_present, |
| 3968 | boolean si2n_present, |
| 3969 | boolean si21_present, |
| 3970 | boolean si22_present |
| 3971 | } |
| 3972 | |
| 3973 | /* 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] | 3974 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 3975 | SystemInformationVectorPerTc si_per_tc) |
| 3976 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3977 | var integer i; |
| 3978 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3979 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3980 | 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] | 3981 | } |
| 3982 | } |
| 3983 | if (cfg.si1_present) { |
| 3984 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3985 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3986 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3987 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3988 | /* make sure *ALL* contain SI1 */ |
| 3989 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3990 | } |
| 3991 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3992 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3993 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3994 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3995 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3996 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3997 | |
| 3998 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3999 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4000 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4001 | * consecutive occurrences of TC = 4. */ |
| 4002 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4003 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4004 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4005 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4006 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4007 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4008 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4009 | } |
| 4010 | |
| 4011 | if (cfg.si7_present or cfg.si8_present) { |
| 4012 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4013 | * if System Information type 4 does not contain all information needed for cell |
| 4014 | * selection and reselection. */ |
| 4015 | if (not cfg.bcch_extended) { |
| 4016 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4017 | } |
| 4018 | if (cfg.si7_present) { |
| 4019 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4020 | } |
| 4021 | if (cfg.si8_present) { |
| 4022 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4023 | } |
| 4024 | } |
| 4025 | |
| 4026 | if (cfg.si2quater_present) { |
| 4027 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4028 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4029 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4030 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4031 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4032 | if (not (cfg.bcch_extended)) { |
| 4033 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4034 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4035 | } else { |
| 4036 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4037 | } |
| 4038 | } else { |
| 4039 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4040 | } |
| 4041 | } |
| 4042 | if (cfg.si9_present) { |
| 4043 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4044 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4045 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4046 | } |
| 4047 | if (cfg.si13_present) { |
| 4048 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4049 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4050 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4051 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4052 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4053 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4054 | if (not cfg.bcch_extended) { |
| 4055 | log("not-bccch-extended"); |
| 4056 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4057 | } else { |
| 4058 | log("bccch-extended"); |
| 4059 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4060 | } |
| 4061 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4062 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4063 | } |
| 4064 | } |
| 4065 | if (cfg.si16_present or cfg.si17_present) { |
| 4066 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4067 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4068 | if (cfg.si22_present) { |
| 4069 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4070 | } |
| 4071 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4072 | 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] | 4073 | } |
| 4074 | if (not cfg.bcch_extended) { |
| 4075 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4076 | } |
| 4077 | if (cfg.si16_present) { |
| 4078 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4079 | } |
| 4080 | if (cfg.si17_present) { |
| 4081 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4082 | } |
| 4083 | } |
| 4084 | |
| 4085 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4086 | * broadcast information. The frequency with which they are sent is determined by the |
| 4087 | * system operator. System Information type 9 identifies the scheduling of System |
| 4088 | * Information type 18 and 20 messages. */ |
| 4089 | |
| 4090 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4091 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4092 | * Information Type 9. */ |
| 4093 | |
| 4094 | if (cfg.si15_present) { |
| 4095 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4096 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4097 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4098 | * 4 consecutive occurrences of TC = 1. */ |
| 4099 | if (not cfg.bcch_extended) { |
| 4100 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4101 | } else { |
| 4102 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4103 | } |
| 4104 | } |
| 4105 | if (cfg.si13alt_present) { |
| 4106 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4107 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4108 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4109 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4110 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4111 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4112 | * of TC = 4. */ |
| 4113 | if (cfg.si13_present) { |
| 4114 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4115 | } |
| 4116 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4117 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4118 | } |
| 4119 | if (not cfg.bcch_extended) { |
| 4120 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4121 | } else { |
| 4122 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4123 | } |
| 4124 | } |
| 4125 | if (cfg.si2n_present) { |
| 4126 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4127 | * as determined by the system operator. In the case that the message is sent on the |
| 4128 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4129 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4130 | * consecutive occurrences of TC = 4. */ |
| 4131 | if (not cfg.bcch_extended) { |
| 4132 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4133 | } else { |
| 4134 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4135 | } |
| 4136 | } |
| 4137 | if (cfg.si21_present) { |
| 4138 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4139 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4140 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4141 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4142 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4143 | if (not cfg.bcch_extended) { |
| 4144 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4145 | } else { |
| 4146 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4147 | 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] | 4148 | 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] | 4149 | } |
| 4150 | } |
| 4151 | } |
| 4152 | if (cfg.si22_present) { |
| 4153 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4154 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4155 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4156 | * =2 and TC=6. */ |
| 4157 | if (cfg.si16_present or cfg.si17_present) { |
| 4158 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4159 | } |
| 4160 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4161 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4162 | 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] | 4163 | } |
| 4164 | if (not cfg.bcch_extended) { |
| 4165 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4166 | } else { |
| 4167 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4168 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4169 | } |
| 4170 | } |
| 4171 | } |
| 4172 | |
| 4173 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4174 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4175 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4176 | timer T := duration; |
| 4177 | var SystemInformationVectorPerTc si_per_tc; |
| 4178 | var L1ctlDlMessage l1_dl; |
| 4179 | |
| 4180 | /* initialize all per-TC vectors empty */ |
| 4181 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4182 | si_per_tc[i] := {}; |
| 4183 | } |
| 4184 | |
| 4185 | /* flush all previous L1 queued msgs */ |
| 4186 | pt.clear; |
| 4187 | |
| 4188 | T.start; |
| 4189 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4190 | [] 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] | 4191 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4192 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4193 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4194 | repeat; |
| 4195 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4196 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4197 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4198 | log("SI received at TC=", tc, ": ", sig.si); |
| 4199 | /* append to the per-TC bucket */ |
| 4200 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4201 | repeat; |
| 4202 | } |
| 4203 | [] pt.receive { repeat; } |
| 4204 | [] T.timeout { } |
| 4205 | } |
| 4206 | |
| 4207 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4208 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4209 | } |
| 4210 | log("si_per_tc=", si_per_tc); |
| 4211 | return si_per_tc; |
| 4212 | } |
| 4213 | |
| 4214 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4215 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4216 | 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] | 4217 | var SystemInformationVectorPerTc si_per_tc; |
| 4218 | f_init_l1ctl(); |
| 4219 | f_l1_tune(L1CTL); |
| 4220 | |
| 4221 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4222 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4223 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4224 | |
| 4225 | setverdict(pass); |
| 4226 | } |
| 4227 | |
| 4228 | testcase TC_si_sched_default() runs on test_CT { |
| 4229 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4230 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4231 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4232 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4233 | } |
| 4234 | |
| 4235 | testcase TC_si_sched_1() runs on test_CT { |
| 4236 | f_init(); |
| 4237 | si_cfg.si1_present := true; |
| 4238 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4239 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4241 | } |
| 4242 | |
| 4243 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4244 | f_init(); |
| 4245 | si_cfg.si2bis_present := true; |
| 4246 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4247 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4248 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4252 | f_init(); |
| 4253 | si_cfg.si2ter_present := true; |
| 4254 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4255 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4256 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4257 | } |
| 4258 | |
| 4259 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4260 | f_init(); |
| 4261 | si_cfg.si2bis_present := true; |
| 4262 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4263 | si_cfg.si2ter_present := true; |
| 4264 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4265 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4266 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4267 | } |
| 4268 | |
| 4269 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4270 | f_init(); |
| 4271 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4272 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4273 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4274 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4275 | } |
| 4276 | |
| 4277 | testcase TC_si_sched_13() runs on test_CT { |
| 4278 | f_init(); |
| 4279 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4280 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4281 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4282 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 4286 | f_init(); |
| 4287 | si_cfg.si2bis_present := true; |
| 4288 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4289 | si_cfg.si2ter_present := true; |
| 4290 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4291 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4292 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4293 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4294 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4295 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4296 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4300 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4301 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4302 | /* FIXME: enable / disable individual BCCH info */ |
| 4303 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4304 | /* expect no ERROR REPORT after either of them * |
| 4305 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4306 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4307 | } |
| 4308 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4309 | /*********************************************************************** |
| 4310 | * Low-Level Protocol Errors / ERROR REPORT |
| 4311 | ***********************************************************************/ |
| 4312 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4313 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4314 | timer T := 5.0; |
| 4315 | T.start; |
| 4316 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4317 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4318 | setverdict(pass); |
| 4319 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4320 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4321 | 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] | 4322 | } |
| 4323 | [] RSL_CCHAN.receive { |
| 4324 | repeat; |
| 4325 | } |
| 4326 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4327 | 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] | 4328 | } |
| 4329 | } |
| 4330 | } |
| 4331 | |
| 4332 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4333 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4334 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4335 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4336 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4337 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4338 | |
| 4339 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4340 | } |
| 4341 | |
| 4342 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4343 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4344 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4345 | |
| 4346 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4347 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4348 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4349 | |
| 4350 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4351 | } |
| 4352 | |
| 4353 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4354 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4355 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4356 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4357 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4358 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4359 | |
| 4360 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4361 | } |
| 4362 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4363 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4364 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4365 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4366 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4367 | RSL.send(rsl); |
| 4368 | f_rslem_unregister(0, g_chan_nr); |
| 4369 | } |
| 4370 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4371 | var ConnHdlr vc_conn; |
| 4372 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4373 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4374 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4375 | |
| 4376 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4377 | vc_conn.done; |
| 4378 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4379 | |
| 4380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4381 | } |
| 4382 | |
| 4383 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4384 | 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] | 4385 | var template (value) RSL_Message rsl_tx; |
| 4386 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4387 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4388 | RSL.send(rsl_tx); |
| 4389 | f_rslem_unregister(0, g_chan_nr); |
| 4390 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4391 | 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] | 4392 | var template (value) RSL_Message rsl_tx; |
| 4393 | /* we first have to activate the dedicated channel */ |
| 4394 | f_rsl_chan_act(g_pars.chan_mode); |
| 4395 | /* ... to then send an invalid RLL message */ |
| 4396 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4397 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4398 | RSL.send(rsl_tx); |
| 4399 | f_rslem_unregister(0, g_chan_nr); |
| 4400 | } |
| 4401 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4402 | var ConnHdlr vc_conn; |
| 4403 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4404 | var template (value) RSL_Message rsl_tx; |
| 4405 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4406 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4407 | |
| 4408 | /* Common Channel with wrong message type */ |
| 4409 | RSL_CCHAN.clear; |
| 4410 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4411 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4412 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4413 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4414 | |
| 4415 | /* TRX Management */ |
| 4416 | RSL_CCHAN.clear; |
| 4417 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4418 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4419 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4420 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4421 | |
| 4422 | /* Dedicated Channel */ |
| 4423 | RSL_CCHAN.clear; |
| 4424 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4425 | vc_conn.done; |
| 4426 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4427 | |
| 4428 | /* RLL */ |
| 4429 | RSL_CCHAN.clear; |
| 4430 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4431 | vc_conn.done; |
| 4432 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4433 | } |
| 4434 | |
| 4435 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4436 | 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] | 4437 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4438 | f_rslem_unregister(0, g_chan_nr); |
| 4439 | } |
| 4440 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4441 | var ConnHdlr vc_conn; |
| 4442 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4443 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4444 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4445 | |
| 4446 | RSL_CCHAN.clear; |
| 4447 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4448 | vc_conn.done; |
| 4449 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4450 | } |
| 4451 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4452 | /*********************************************************************** |
| 4453 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4454 | ***********************************************************************/ |
| 4455 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4456 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4457 | 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] | 4458 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4459 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4460 | } |
| 4461 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4462 | 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] | 4463 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4464 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4465 | vc_conn.done; |
| 4466 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4467 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4468 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4469 | 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] | 4470 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4471 | "IPA CRCX ACK"); |
| 4472 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4473 | "IPA CRCX NACK"); |
| 4474 | } |
| 4475 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4476 | 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] | 4477 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4478 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4479 | vc_conn.done; |
| 4480 | } |
| 4481 | |
| 4482 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4483 | 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] | 4484 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4485 | "IPA CRCX ACK"); |
| 4486 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4487 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4488 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4489 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4490 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4491 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4492 | "IPA MDCX ACK"); |
| 4493 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4494 | "IPA DLCX ACK"); |
| 4495 | } |
| 4496 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4497 | 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] | 4498 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4499 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4500 | vc_conn.done; |
| 4501 | } |
| 4502 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4503 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4504 | 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] | 4505 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4506 | "IPA CRCX ACK"); |
| 4507 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4508 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4509 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4510 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4511 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4512 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4513 | "IPA MDCX ACK"); |
| 4514 | /* Second MDCX */ |
| 4515 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4516 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4517 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4518 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4519 | "IPA MDCX ACK"); |
| 4520 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4521 | "IPA DLCX ACK"); |
| 4522 | } |
| 4523 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4524 | 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] | 4525 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4526 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4527 | vc_conn.done; |
| 4528 | } |
| 4529 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4530 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4531 | 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] | 4532 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4533 | "IPA CRCX NACK"); |
| 4534 | } |
| 4535 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4536 | var ConnHdlrPars pars; |
| 4537 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4538 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4539 | |
| 4540 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4541 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4542 | vc_conn.done; |
| 4543 | |
| 4544 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4545 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4546 | vc_conn.done; |
| 4547 | } |
| 4548 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4549 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4550 | /*********************************************************************** |
| 4551 | * PCU Socket related tests |
| 4552 | ***********************************************************************/ |
| 4553 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4554 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4555 | 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] | 4556 | runs on test_CT { |
| 4557 | timer T := 3.0; |
| 4558 | |
| 4559 | /* we don't expect any RTS.req before PDCH are active */ |
| 4560 | T.start; |
| 4561 | alt { |
| 4562 | [] 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] | 4563 | 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] | 4564 | } |
| 4565 | [] PCU.receive { repeat; } |
| 4566 | [] T.timeout { } |
| 4567 | } |
| 4568 | |
| 4569 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4570 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4571 | |
| 4572 | /* we now expect RTS.req for this timeslot (only) */ |
| 4573 | T.start; |
| 4574 | alt { |
| 4575 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4576 | setverdict(pass); |
| 4577 | } |
| 4578 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4579 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4580 | 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] | 4581 | } |
| 4582 | [] 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] | 4583 | 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] | 4584 | } |
| 4585 | [] PCU.receive { repeat; } |
| 4586 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4587 | 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] | 4588 | } |
| 4589 | [not exp_success] T.timeout { |
| 4590 | setverdict(pass); |
| 4591 | } |
| 4592 | } |
| 4593 | } |
| 4594 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4595 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4596 | 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] | 4597 | runs on test_CT { |
| 4598 | timer T := 3.0; |
| 4599 | |
| 4600 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4601 | 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] | 4602 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 4603 | * when it will actually have been executed in the BTS */ |
| 4604 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4605 | PCU.clear; |
| 4606 | /* we now expect no RTS.req for this timeslot */ |
| 4607 | T.start; |
| 4608 | alt { |
| 4609 | [] 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] | 4610 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4611 | } |
| 4612 | [] PCU.receive { repeat; } |
| 4613 | [] T.timeout { |
| 4614 | setverdict(pass); |
| 4615 | } |
| 4616 | } |
| 4617 | } |
| 4618 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4619 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4620 | f_init(); |
| 4621 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4622 | } |
| 4623 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4624 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4625 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4626 | f_init_pcu_test(); |
| 4627 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4628 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4629 | } |
| 4630 | |
| 4631 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4632 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4633 | f_init_pcu_test(); |
| 4634 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4635 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4636 | } |
| 4637 | |
| 4638 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4639 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4640 | f_init_pcu_test(); |
| 4641 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4642 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4643 | } |
| 4644 | |
| 4645 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4646 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4647 | f_init_pcu_test(); |
| 4648 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4649 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4650 | } |
| 4651 | |
| 4652 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4653 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4654 | f_init_pcu_test(); |
| 4655 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4656 | /* Activate PDCH */ |
| 4657 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4658 | f_sleep(1.0); |
| 4659 | /* and De-Activate again */ |
| 4660 | f_TC_pcu_deact_req(0, 0, 7); |
| 4661 | } |
| 4662 | |
| 4663 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4664 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4665 | f_init_pcu_test(); |
| 4666 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4667 | f_TC_pcu_deact_req(0, 0, 1); |
| 4668 | } |
| 4669 | |
| 4670 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4671 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4672 | const octetstring si13 := '00010203040506070909'O; |
| 4673 | var PCUIF_send_data sd; |
| 4674 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4675 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4676 | |
| 4677 | /* Set SI13 via RSL */ |
| 4678 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4679 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4680 | T.start; |
| 4681 | alt { |
| 4682 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4683 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4684 | setverdict(pass); |
| 4685 | } else { |
| 4686 | repeat; |
| 4687 | } |
| 4688 | } |
| 4689 | [] PCU.receive { repeat; } |
| 4690 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4692 | } |
| 4693 | } |
| 4694 | } |
| 4695 | |
| 4696 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4697 | |
| 4698 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4699 | 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] | 4700 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4701 | runs on test_CT |
| 4702 | { |
| 4703 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4704 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4705 | } |
| 4706 | |
| 4707 | /* 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] | 4708 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4709 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4710 | runs on test_CT |
| 4711 | { |
| 4712 | var PCUIF_send_data sd; |
| 4713 | |
| 4714 | timer T := 3.0; |
| 4715 | T.start; |
| 4716 | alt { |
| 4717 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4718 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4719 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4720 | sd.data.u.rts_req.fn, sapi, data); |
| 4721 | } |
| 4722 | [] PCU.receive { repeat; } |
| 4723 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4724 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4725 | } |
| 4726 | } |
| 4727 | } |
| 4728 | |
| 4729 | /* Send DATA.req on invalid BTS */ |
| 4730 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4731 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4732 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4733 | |
| 4734 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4735 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4736 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4737 | f_TfiUsfArrSet(tua, 7, 0); |
| 4738 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4739 | f_sleep(1.0); |
| 4740 | |
| 4741 | 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] | 4742 | } |
| 4743 | |
| 4744 | /* Send DATA.req on invalid TRX */ |
| 4745 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4746 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4747 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4748 | |
| 4749 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4750 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4751 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4752 | f_TfiUsfArrSet(tua, 7, 0); |
| 4753 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4754 | f_sleep(1.0); |
| 4755 | |
| 4756 | 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] | 4757 | } |
| 4758 | |
| 4759 | /* Send DATA.req on invalid timeslot */ |
| 4760 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4761 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4762 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4763 | |
| 4764 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4765 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4766 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4767 | f_TfiUsfArrSet(tua, 7, 0); |
| 4768 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4769 | f_sleep(1.0); |
| 4770 | |
| 4771 | 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] | 4772 | } |
| 4773 | |
| 4774 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4775 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4776 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4777 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4778 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4779 | f_virtphy_common(); |
| 4780 | |
| 4781 | f_TfiUsfArrSet(tua, 7, 0); |
| 4782 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4783 | f_sleep(1.0); |
| 4784 | |
| 4785 | 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] | 4786 | } |
| 4787 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4788 | 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] | 4789 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4790 | boolean wait_rts := true) |
| 4791 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4792 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4793 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4794 | |
| 4795 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4796 | if (wait_rts) { |
| 4797 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4798 | } else { |
| 4799 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4800 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4801 | |
| 4802 | T.start; |
| 4803 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4804 | [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] | 4805 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4806 | setverdict(pass); |
| 4807 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4808 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4809 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4810 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4811 | [] L1CTL.receive { |
| 4812 | repeat; |
| 4813 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4814 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4815 | setverdict(fail, "Timeout waiting for ", data); |
| 4816 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4817 | [not expect_data] T.timeout { |
| 4818 | setverdict(pass); |
| 4819 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4820 | } |
| 4821 | } |
| 4822 | |
| 4823 | private function f_disable_dynamic_ts() runs on test_CT |
| 4824 | { |
| 4825 | f_init_vty_bsc(); |
| 4826 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4827 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4828 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4829 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4830 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4831 | } |
| 4832 | |
| 4833 | private function f_virtphy_common() runs on test_CT { |
| 4834 | f_disable_dynamic_ts(); |
| 4835 | f_init_l1ctl(); |
| 4836 | f_l1_tune(L1CTL); |
| 4837 | } |
| 4838 | |
| 4839 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4840 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4841 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4842 | |
| 4843 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4844 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4845 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4846 | f_TfiUsfArrSet(tua, 7, 0); |
| 4847 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4848 | f_sleep(1.0); |
| 4849 | |
| 4850 | 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] | 4851 | } |
| 4852 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4853 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4854 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4855 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4856 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4857 | |
| 4858 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4859 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4860 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4861 | f_TfiUsfArrSet(tua, 7, 0); |
| 4862 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4863 | f_sleep(1.0); |
| 4864 | |
| 4865 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4866 | } |
| 4867 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4868 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4869 | runs on test_CT { |
| 4870 | var template PCUIF_Message pcu_rach_ind; |
| 4871 | var PCUIF_send_data sd; |
| 4872 | var GsmFrameNumber fn; |
| 4873 | timer T; |
| 4874 | |
| 4875 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4876 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4877 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4878 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4879 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4880 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4881 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4882 | |
| 4883 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4884 | T.start(52.0 * 4.615 / 1000.0); |
| 4885 | alt { |
| 4886 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4887 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4888 | setverdict(pass); |
| 4889 | T.stop; |
| 4890 | } |
| 4891 | [] PCU.receive { repeat; } |
| 4892 | [] T.timeout { |
| 4893 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4894 | /* Keep going, that's not the end of the world */ |
| 4895 | } |
| 4896 | } |
| 4897 | } |
| 4898 | |
| 4899 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4900 | var L1ctlDlMessage dl; |
| 4901 | var octetstring data; |
| 4902 | timer T; |
| 4903 | |
| 4904 | f_init_pcu_test(); |
| 4905 | f_init_l1ctl(); |
| 4906 | f_l1_tune(L1CTL); |
| 4907 | |
| 4908 | /* Activate PDCH channel on TS7 */ |
| 4909 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4910 | |
| 4911 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4912 | 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] | 4913 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 4914 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4915 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4916 | |
| 4917 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4918 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4919 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4920 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4921 | } |
| 4922 | |
| 4923 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4924 | data := f_rnd_octstring(23); |
| 4925 | |
| 4926 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4927 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4928 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4929 | |
| 4930 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4931 | * let's give it more time in case if we miss the beginning. */ |
| 4932 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4933 | alt { |
| 4934 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4935 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4936 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4937 | frame := data)) -> value dl { |
| 4938 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4939 | setverdict(pass); |
| 4940 | T.stop; |
| 4941 | } |
| 4942 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4943 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4944 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4945 | l2_data := data)) -> value dl { |
| 4946 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4947 | setverdict(pass); |
| 4948 | T.stop; |
| 4949 | } |
| 4950 | [] L1CTL.receive { repeat; } |
| 4951 | [] T.timeout { |
| 4952 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4953 | } |
| 4954 | } |
| 4955 | } |
| 4956 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4957 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4958 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4959 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4960 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4961 | f_init_l1ctl(); |
| 4962 | f_l1_tune(L1CTL); |
| 4963 | |
| 4964 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4965 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4966 | |
| 4967 | T.start; |
| 4968 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4969 | [] 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] | 4970 | setverdict(pass); |
| 4971 | } |
| 4972 | [] L1CTL.receive { repeat; } |
| 4973 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4974 | 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] | 4975 | } |
| 4976 | } |
| 4977 | } |
| 4978 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4979 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4980 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4981 | timer T := 3.0; |
| 4982 | f_init_pcu_test(); |
| 4983 | f_init_l1ctl(); |
| 4984 | f_l1_tune(L1CTL); |
| 4985 | |
| 4986 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4987 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4988 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4989 | |
| 4990 | T.start; |
| 4991 | alt { |
| 4992 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4993 | setverdict(pass); |
| 4994 | } |
| 4995 | [] L1CTL.receive { repeat; } |
| 4996 | [] T.timeout { |
| 4997 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4998 | } |
| 4999 | } |
| 5000 | } |
| 5001 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5002 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5003 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5004 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5005 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5006 | f_init_l1ctl(); |
| 5007 | f_l1_tune(L1CTL); |
| 5008 | |
| 5009 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5010 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5011 | |
| 5012 | timer T := 0.5; |
| 5013 | T.start; |
| 5014 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5015 | [] 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] | 5016 | /* TODO: verify paging group */ |
| 5017 | setverdict(pass); |
| 5018 | } |
| 5019 | [] L1CTL.receive { repeat; } |
| 5020 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5021 | 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] | 5022 | } |
| 5023 | } |
| 5024 | } |
| 5025 | |
| 5026 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5027 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5028 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5029 | f_init_l1ctl(); |
| 5030 | f_l1_tune(L1CTL); |
| 5031 | |
| 5032 | var GsmFrameNumber fn_last := 0; |
| 5033 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5034 | var OCT1 ra := f_rnd_ra_ps(); |
| 5035 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5036 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5038 | } |
| 5039 | fn_last := fn; |
| 5040 | |
| 5041 | timer T := 2.0; |
| 5042 | T.start; |
| 5043 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5044 | [] 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] | 5045 | T.stop; |
| 5046 | } |
| 5047 | [] 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] | 5048 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5049 | } |
| 5050 | [] PCU.receive { repeat; } |
| 5051 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5052 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5053 | } |
| 5054 | } |
| 5055 | } |
| 5056 | setverdict(pass); |
| 5057 | } |
| 5058 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5059 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5060 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5061 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5062 | var template PCUIF_Message pcu_rach_ind; |
| 5063 | var GsmFrameNumber fn_last := 0; |
| 5064 | var L1ctlRachSynchSeq synch_seq; |
| 5065 | var PCUIF_BurstType pcu_bt; |
| 5066 | var GsmFrameNumber fn; |
| 5067 | var BIT11 ra11; |
| 5068 | |
| 5069 | f_init_pcu_test(); |
| 5070 | f_init_l1ctl(); |
| 5071 | f_l1_tune(L1CTL); |
| 5072 | |
| 5073 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5074 | /* We need to test both TS1 & TS2 */ |
| 5075 | if (i rem 2 == 0) { |
| 5076 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5077 | pcu_bt := BURST_TYPE_1; |
| 5078 | } else { |
| 5079 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5080 | pcu_bt := BURST_TYPE_2; |
| 5081 | } |
| 5082 | |
| 5083 | ra11 := f_rnd_ra11_ps(); |
| 5084 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5085 | if (fn == fn_last) { |
| 5086 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5087 | "Two RACH in same FN?!?"); |
| 5088 | } |
| 5089 | fn_last := fn; |
| 5090 | |
| 5091 | /* Compose the expected message */ |
| 5092 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5093 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5094 | ra := bit2int(ra11), |
| 5095 | is_11bit := 1, |
| 5096 | burst_type := pcu_bt, |
| 5097 | fn := fn); |
| 5098 | |
| 5099 | timer T := 2.0; |
| 5100 | T.start; |
| 5101 | alt { |
| 5102 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5103 | T.stop; |
| 5104 | } |
| 5105 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5106 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5107 | } |
| 5108 | [] PCU.receive { repeat; } |
| 5109 | [] T.timeout { |
| 5110 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5111 | } |
| 5112 | } |
| 5113 | } |
| 5114 | setverdict(pass); |
| 5115 | } |
| 5116 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5117 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5118 | runs on test_CT { |
| 5119 | var template PCUIF_send_data sdt; |
| 5120 | var PCUIF_send_data sd; |
| 5121 | var int16_t lqual_cb; |
| 5122 | timer T := 1.0; |
| 5123 | |
| 5124 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5125 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5126 | |
| 5127 | /* Send a random PDTCH frame over Um */ |
| 5128 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5129 | '0000'O & f_rnd_octstring(21))); |
| 5130 | |
| 5131 | T.start; |
| 5132 | alt { |
| 5133 | /* If expected link quality is above the threshold */ |
| 5134 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5135 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5136 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5137 | |
| 5138 | /* Make sure the actual link quality matches the expected value */ |
| 5139 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5140 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5141 | "expected value ", lqual_cb_exp)); |
| 5142 | } else { |
| 5143 | setverdict(pass); |
| 5144 | } |
| 5145 | } |
| 5146 | /* If expected link quality is below the threshold */ |
| 5147 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5148 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5149 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5150 | } |
| 5151 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5152 | [] PCU.receive { repeat; } |
| 5153 | [lqual_cb_exp < thresh] T.timeout { |
| 5154 | log("Rx nothing, as expected"); |
| 5155 | setverdict(pass); |
| 5156 | } |
| 5157 | [lqual_cb_exp >= thresh] T.timeout { |
| 5158 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5159 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5160 | } |
| 5161 | } |
| 5162 | } |
| 5163 | |
| 5164 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5165 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 5166 | f_init_pcu_test(); |
| 5167 | PCU.clear; |
| 5168 | |
| 5169 | f_init_l1ctl(); |
| 5170 | f_l1_tune(L1CTL); |
| 5171 | |
| 5172 | /* Activate a PDCH channel on TS7 */ |
| 5173 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5174 | |
| 5175 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5176 | 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] | 5177 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5178 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5179 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5180 | |
| 5181 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5182 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5183 | var TrxcMessage ret; |
| 5184 | |
| 5185 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 5186 | valueof(ts_TRXC_FAKE_CI(i))); |
| 5187 | |
| 5188 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5189 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5190 | } |
| 5191 | } |
| 5192 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5193 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5194 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5195 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5196 | |
| 5197 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5198 | var MobileIdentityLV mi_lv; |
| 5199 | var octetstring mi_lv_enc; |
| 5200 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5201 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5202 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5203 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5204 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5205 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5206 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5207 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5208 | |
| 5209 | /* Fancy encoding for PCUIF */ |
| 5210 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5211 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5212 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5213 | |
| 5214 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5215 | 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] | 5216 | T.start; |
| 5217 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5218 | [] 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] | 5219 | } |
| 5220 | [] 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] | 5221 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5222 | } |
| 5223 | [] PCU.receive { repeat; } |
| 5224 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5226 | } |
| 5227 | } |
| 5228 | } |
| 5229 | setverdict(pass); |
| 5230 | } |
| 5231 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5232 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5233 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5234 | var PCUIF_send_data pcu_sd; |
| 5235 | var integer num_time_ind := 0; |
| 5236 | var integer first_fn, last_fn; |
| 5237 | var float test_duration := 5.0; |
| 5238 | timer T; |
| 5239 | |
| 5240 | f_init_pcu_test(); |
| 5241 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5242 | |
| 5243 | PCU.clear; |
| 5244 | T.start(test_duration); |
| 5245 | alt { |
| 5246 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5247 | num_time_ind := num_time_ind + 1; |
| 5248 | if (not isbound(first_fn)) { |
| 5249 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5250 | } |
| 5251 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5252 | repeat; |
| 5253 | } |
| 5254 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5255 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5256 | repeat; |
| 5257 | } |
| 5258 | [] PCU.receive { |
| 5259 | repeat; |
| 5260 | } |
| 5261 | [] T.timeout {} |
| 5262 | } |
| 5263 | var integer fn_expired := last_fn - first_fn; |
| 5264 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5265 | |
| 5266 | /* verify the number of frames expired matches our expectation */ |
| 5267 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5268 | 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] | 5269 | 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] | 5270 | if (not match(fn_expired, t_fn_expected)) { |
| 5271 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5272 | } |
| 5273 | |
| 5274 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5275 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5276 | /* Add some tolerance */ |
| 5277 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5278 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5279 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5280 | } |
| 5281 | |
| 5282 | setverdict(pass); |
| 5283 | } |
| 5284 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5285 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5286 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5287 | var PCUIF_send_data pcu_sd; |
| 5288 | var integer first_fn, last_fn; |
| 5289 | var integer num_rts_pdtch := 0; |
| 5290 | var integer num_rts_ptcch := 0; |
| 5291 | var float test_duration := 5.0; |
| 5292 | timer T; |
| 5293 | |
| 5294 | f_init_pcu_test(); |
| 5295 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5296 | |
| 5297 | PCU.clear; |
| 5298 | T.start(test_duration); |
| 5299 | alt { |
| 5300 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5301 | -> value pcu_sd { |
| 5302 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5303 | if (not isbound(first_fn)) { |
| 5304 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5305 | } |
| 5306 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5307 | repeat; |
| 5308 | } |
| 5309 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5310 | -> value pcu_sd { |
| 5311 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5312 | if (not isbound(first_fn)) { |
| 5313 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5314 | } |
| 5315 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5316 | repeat; |
| 5317 | } |
| 5318 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5319 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5320 | repeat; |
| 5321 | } |
| 5322 | [] PCU.receive { |
| 5323 | repeat; |
| 5324 | } |
| 5325 | [] T.timeout {} |
| 5326 | } |
| 5327 | var integer fn_expired := last_fn - first_fn; |
| 5328 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5329 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5330 | |
| 5331 | /* verify the number of frames expired matches our expectation */ |
| 5332 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5333 | 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] | 5334 | 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] | 5335 | if (not match(fn_expired, t_fn_expected)) { |
| 5336 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5337 | } |
| 5338 | |
| 5339 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5340 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5341 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5342 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5343 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5344 | t_ptcch_exp); |
| 5345 | } |
| 5346 | |
| 5347 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5348 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5349 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5350 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5351 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5352 | t_pdtch_exp); |
| 5353 | } |
| 5354 | |
| 5355 | setverdict(pass); |
| 5356 | } |
| 5357 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5358 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5359 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5360 | var PCUIF_send_data pcu_sd; |
| 5361 | var integer num_time_ind := 0; |
| 5362 | var integer first_fn, last_fn; |
| 5363 | var float test_duration := 5.0; |
| 5364 | timer T; |
| 5365 | |
| 5366 | f_init_pcu_test(); |
| 5367 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5368 | |
| 5369 | /* re-connect CTRL port from BTS to BSC */ |
| 5370 | f_ipa_ctrl_stop(); |
| 5371 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 5372 | |
| 5373 | /* Send that OML Alert */ |
| 5374 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5375 | |
| 5376 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5377 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5378 | setverdict(pass); |
| 5379 | } |
| 5380 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5381 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5382 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5383 | var PCUIF_Message first_info; |
| 5384 | var integer pcu_conn_id := -1; |
| 5385 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5386 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5387 | var OCT4 tlli := '01020304'O; |
| 5388 | var OCT1 cause := '23'O; |
| 5389 | timer T := 5.0; |
| 5390 | |
| 5391 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5392 | |
| 5393 | f_l1_tune(L1CTL); |
| 5394 | RSL.clear; |
| 5395 | |
| 5396 | f_est_dchan(); |
| 5397 | L1CTL.clear; |
| 5398 | |
| 5399 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5400 | |
| 5401 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5402 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5403 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5404 | |
| 5405 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5406 | T.start; |
| 5407 | alt { |
| 5408 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5409 | setverdict(pass); |
| 5410 | } |
| 5411 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5412 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5413 | } |
| 5414 | [] PCU.receive { |
| 5415 | repeat; |
| 5416 | } |
| 5417 | [] T.timeout { |
| 5418 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5419 | } |
| 5420 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5421 | |
| 5422 | /* release the channel */ |
| 5423 | f_rsl_chan_deact(); |
| 5424 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5425 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5426 | } |
| 5427 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5428 | var ConnHdlrPars pars; |
| 5429 | var ConnHdlr vc_conn; |
| 5430 | |
| 5431 | f_init(); |
| 5432 | |
| 5433 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5434 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5435 | vc_conn.done; |
| 5436 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5437 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5438 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5439 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 5440 | timer T := 5.0; |
| 5441 | |
| 5442 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5443 | f_init(); |
| 5444 | |
| 5445 | /* try to establish a second connection, expect it to fail */ |
| 5446 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5447 | T.start; |
| 5448 | alt { |
| 5449 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 5450 | setverdict(pass); |
| 5451 | } |
| 5452 | [] PCU.receive(UD_connect_result:?) { |
| 5453 | setverdict(fail, "Unexpected unix domain connect result"); |
| 5454 | } |
| 5455 | [] T.timeout { |
| 5456 | setverdict(pass); |
| 5457 | } |
| 5458 | } |
| 5459 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5460 | } |
| 5461 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5462 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5463 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5464 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5465 | f_init(); |
| 5466 | |
| 5467 | f_sleep(1.0); |
| 5468 | |
| 5469 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5470 | g_pcu_conn_id := -1; |
| 5471 | |
| 5472 | f_sleep(1.0); |
| 5473 | |
| 5474 | /* re-connect */ |
| 5475 | PCU.clear; |
| 5476 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5477 | setverdict(pass); |
| 5478 | |
| 5479 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5480 | } |
| 5481 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5482 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5483 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5484 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5485 | var L1ctlDlMessage l1_dl; |
| 5486 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5487 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5488 | timer T := 5.0; |
| 5489 | T.start; |
| 5490 | alt { |
| 5491 | [] 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] | 5492 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 5493 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5494 | repeat; |
| 5495 | } |
| 5496 | } |
| 5497 | [] pt.receive { |
| 5498 | repeat; |
| 5499 | } |
| 5500 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5501 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5502 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5503 | } |
| 5504 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5505 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5506 | } |
| 5507 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5508 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5509 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5510 | runs on test_CT return boolean { |
| 5511 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5512 | |
| 5513 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5514 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5515 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5516 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5517 | } |
| 5518 | |
| 5519 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5520 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5521 | } |
| 5522 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5523 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5524 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5525 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5526 | /* don't call f_init() as this would connect PCU socket */ |
| 5527 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5528 | |
| 5529 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5530 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5531 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5532 | |
| 5533 | f_init_l1ctl(); |
| 5534 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5535 | f_sleep(2.0); |
| 5536 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5537 | |
| 5538 | if (f_si_has_gprs_indicator(si_type)) { |
| 5539 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5540 | } else { |
| 5541 | setverdict(pass); |
| 5542 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5543 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5544 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5545 | } |
| 5546 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5547 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5548 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5549 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5550 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5551 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5552 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5553 | } |
| 5554 | |
| 5555 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5556 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5557 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5558 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5559 | f_init(); |
| 5560 | f_init_l1ctl(); |
| 5561 | f_l1_tune(L1CTL); |
| 5562 | |
| 5563 | f_sleep(2.0); |
| 5564 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5565 | |
| 5566 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5567 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5568 | } else { |
| 5569 | setverdict(pass); |
| 5570 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5571 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5572 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5573 | } |
| 5574 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5575 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5576 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5577 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5578 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5579 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5580 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5581 | } |
| 5582 | |
| 5583 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5584 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5585 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5586 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5587 | f_init(); |
| 5588 | f_init_l1ctl(); |
| 5589 | f_l1_tune(L1CTL); |
| 5590 | |
| 5591 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5592 | g_pcu_conn_id := -1; |
| 5593 | |
| 5594 | f_sleep(1.0); |
| 5595 | |
| 5596 | /* re-connect */ |
| 5597 | PCU.clear; |
| 5598 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5599 | |
| 5600 | f_sleep(2.0); |
| 5601 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5602 | |
| 5603 | if (f_si_has_gprs_indicator(si_type)) { |
| 5604 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5605 | } else { |
| 5606 | setverdict(pass); |
| 5607 | } |
| 5608 | |
| 5609 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5610 | } |
| 5611 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5612 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5613 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5614 | } |
| 5615 | |
| 5616 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5617 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5618 | } |
| 5619 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5620 | /* 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) */ |
| 5621 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5622 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5623 | |
| 5624 | f_init(); |
| 5625 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 5626 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 5627 | * information */ |
| 5628 | timer T := 2.0; |
| 5629 | T.start; |
| 5630 | alt { |
| 5631 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 5632 | [] T.timeout {} |
| 5633 | } |
| 5634 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5635 | /* Verify cell_id */ |
| 5636 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5637 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5638 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5639 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5640 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5641 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5642 | } |
| 5643 | |
| 5644 | /* Verify LAC */ |
| 5645 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5646 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5647 | if (lac_si3 != lac_pcu) { |
| 5648 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5649 | } |
| 5650 | |
| 5651 | setverdict(pass); |
| 5652 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5653 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5654 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 5655 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 5656 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5657 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5658 | |
| 5659 | f_init(); |
| 5660 | |
| 5661 | info_ind := g_pcu_last_info.u.info_ind; |
| 5662 | |
| 5663 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 5664 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
| 5665 | if (info_ind.trx.v10[i].pdch_mask[tn] != '1'B) { |
| 5666 | /* Skip inactive timeslots */ |
| 5667 | continue; |
| 5668 | } |
| 5669 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5670 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 5671 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5672 | else |
| 5673 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5674 | |
| 5675 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5676 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5677 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5678 | hsn := fhp.maio_hsn.hsn, |
| 5679 | maio := fhp.maio_hsn.maio, |
| 5680 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 5681 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5682 | } else { |
| 5683 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 5684 | } |
| 5685 | |
| 5686 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[i].ts[tn]; |
| 5687 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 5688 | if (not match(ts, tr_ts)) { |
| 5689 | setverdict(fail, "Hopping parameters do not match: ", |
| 5690 | "received ", ts, " vs expected ", tr_ts); |
| 5691 | } else { |
| 5692 | setverdict(pass); |
| 5693 | } |
| 5694 | } |
| 5695 | } |
| 5696 | } |
| 5697 | |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5698 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5699 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 5700 | f_init_vty_bsc(); |
| 5701 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5702 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 5703 | |
| 5704 | f_init(); |
| 5705 | |
| 5706 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5707 | if (not ischosen(remote_addr.v10)) { |
| 5708 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5709 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5710 | } |
| 5711 | |
| 5712 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV4) { |
| 5713 | setverdict(fail, "Received address family is not IPv4"); |
| 5714 | } |
| 5715 | |
| 5716 | if (substr(remote_addr.v10.addr[0], 0, 4) != f_inet_addr("127.127.127.127")) { |
| 5717 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5718 | } |
| 5719 | |
| 5720 | setverdict(pass); |
| 5721 | } |
| 5722 | |
| 5723 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5724 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 5725 | f_init_vty_bsc(); |
| 5726 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 5727 | |
| 5728 | f_init(); |
| 5729 | |
| 5730 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5731 | if (not ischosen(remote_addr.v10)) { |
| 5732 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5733 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5734 | } |
| 5735 | |
| 5736 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV6) { |
| 5737 | setverdict(fail, "Received address family is not IPv6"); |
| 5738 | } |
| 5739 | |
| 5740 | if (remote_addr.v10.addr[0] != f_inet6_addr("fd00::ca:ff:ee")) { |
| 5741 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5742 | } |
| 5743 | |
| 5744 | setverdict(pass); |
| 5745 | } |
| 5746 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5747 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5748 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5749 | ***********************************************************************/ |
| 5750 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5751 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 5752 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5753 | runs on ConnHdlr { |
| 5754 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5755 | |
| 5756 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
Vadim Yanitskiy | 2a9acce | 2020-10-31 20:19:06 +0700 | [diff] [blame] | 5757 | var BIT8 pdch_mask := f_PCUIF_ver_INFO_PDCHMask_get(sd.data.u.info_ind, trx_nr); |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5758 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 5759 | repeat; |
| 5760 | } |
| 5761 | } |
| 5762 | } |
| 5763 | |
| 5764 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5765 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5766 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5767 | PCU.clear; |
| 5768 | f_rsl_chan_act(g_pars.chan_mode); |
| 5769 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5770 | timer T_wait := 2.0; |
| 5771 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5772 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5773 | [] 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] | 5774 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5775 | [] T_wait.timeout { |
| 5776 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5777 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5778 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5779 | } |
| 5780 | /* try to activate this PDCH from the PCU point of view */ |
| 5781 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5782 | /* FIXME: is there a response? */ |
| 5783 | } |
| 5784 | |
| 5785 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5786 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5787 | /* Send RSL CHAN REL (deactivate) */ |
| 5788 | PCU.clear; |
| 5789 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5790 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5791 | timer T_wait := 2.0; |
| 5792 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5793 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5794 | [] 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] | 5795 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5796 | [] T_wait.timeout { |
| 5797 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5798 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5799 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5800 | } |
| 5801 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5802 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5803 | alt { |
| 5804 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5805 | setverdict(pass); |
| 5806 | } |
| 5807 | [] RSL.receive { repeat; } |
| 5808 | } |
| 5809 | } |
| 5810 | |
| 5811 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5812 | 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] | 5813 | var PCUIF_Message first_info; |
| 5814 | var integer ts_nr := g_chan_nr.tn; |
| 5815 | var integer trx_nr := 0; |
| 5816 | var integer bts_nr := 0; |
| 5817 | var integer pcu_conn_id := -1; |
| 5818 | |
| 5819 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5820 | |
| 5821 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5822 | f_sleep(3.0); |
| 5823 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5824 | setverdict(pass); |
| 5825 | } |
| 5826 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5827 | var ConnHdlrPars pars; |
| 5828 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5829 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5830 | |
| 5831 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5832 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5833 | vc_conn.done; |
| 5834 | } |
| 5835 | |
| 5836 | /* 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] | 5837 | 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] | 5838 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5839 | var integer pcu_conn_id := -1; |
| 5840 | |
| 5841 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5842 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5843 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5844 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5845 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5846 | setverdict(pass); |
| 5847 | } |
| 5848 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5849 | var ConnHdlrPars pars; |
| 5850 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5851 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5852 | |
| 5853 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5854 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5855 | vc_conn.done; |
| 5856 | } |
| 5857 | |
| 5858 | /* 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] | 5859 | 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] | 5860 | var PCUIF_Message first_info; |
| 5861 | var integer ts_nr := g_chan_nr.tn; |
| 5862 | var integer trx_nr := 0; |
| 5863 | var integer bts_nr := 0; |
| 5864 | var integer pcu_conn_id := -1; |
| 5865 | |
| 5866 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5867 | |
| 5868 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5869 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5870 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5871 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5872 | setverdict(pass); |
| 5873 | } |
| 5874 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5875 | var ConnHdlrPars pars; |
| 5876 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5877 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5878 | |
| 5879 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5880 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5881 | vc_conn.done; |
| 5882 | } |
| 5883 | |
| 5884 | /* 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] | 5885 | 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] | 5886 | var PCUIF_Message first_info; |
| 5887 | var integer ts_nr := g_chan_nr.tn; |
| 5888 | var integer trx_nr := 0; |
| 5889 | var integer bts_nr := 0; |
| 5890 | var integer pcu_conn_id := -1; |
| 5891 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5892 | |
| 5893 | /* register for the TCH/F channel number */ |
| 5894 | f_rslem_register(0, chan_nr); |
| 5895 | |
| 5896 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5897 | |
| 5898 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5899 | "RSL CHAN ACT"); |
| 5900 | setverdict(pass); |
| 5901 | } |
| 5902 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5903 | var ConnHdlrPars pars; |
| 5904 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5905 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5906 | |
| 5907 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5908 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5909 | vc_conn.done; |
| 5910 | } |
| 5911 | |
| 5912 | /* 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] | 5913 | 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] | 5914 | var PCUIF_Message first_info; |
| 5915 | var integer ts_nr := g_chan_nr.tn; |
| 5916 | var integer trx_nr := 0; |
| 5917 | var integer bts_nr := 0; |
| 5918 | var integer pcu_conn_id := -1; |
| 5919 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5920 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5921 | |
| 5922 | /* register for the TCH/H channel numbers */ |
| 5923 | f_rslem_register(0, chan_nr[0]); |
| 5924 | f_rslem_register(0, chan_nr[1]); |
| 5925 | |
| 5926 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5927 | |
| 5928 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5929 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5930 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5931 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5932 | setverdict(pass); |
| 5933 | } |
| 5934 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5935 | var ConnHdlrPars pars; |
| 5936 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5937 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5938 | |
| 5939 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5940 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5941 | vc_conn.done; |
| 5942 | } |
| 5943 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5944 | /*********************************************************************** |
| 5945 | * IPA Style Dynamic Timeslot Support |
| 5946 | ***********************************************************************/ |
| 5947 | |
| 5948 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5949 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5950 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5951 | PCU.clear; |
| 5952 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5953 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5954 | timer T_wait := 2.0; |
| 5955 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5956 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5957 | [] 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] | 5958 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5959 | [] T_wait.timeout { |
| 5960 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5961 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5962 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5963 | } |
| 5964 | /* try to activate this PDCH from the PCU point of view */ |
| 5965 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5966 | /* FIXME: is there a response? */ |
| 5967 | |
| 5968 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5969 | } |
| 5970 | |
| 5971 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5972 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5973 | /* Send RSL CHAN REL (deactivate) */ |
| 5974 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5975 | PCU.clear; |
| 5976 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5977 | timer T_wait := 2.0; |
| 5978 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5979 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5980 | [] 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] | 5981 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5982 | [] T_wait.timeout { |
| 5983 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5984 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5985 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5986 | } |
| 5987 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5988 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5989 | alt { |
| 5990 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5991 | setverdict(pass); |
| 5992 | } |
| 5993 | [] RSL.receive { repeat; } |
| 5994 | } |
| 5995 | } |
| 5996 | |
| 5997 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5998 | 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] | 5999 | var PCUIF_Message first_info; |
| 6000 | var integer ts_nr := g_chan_nr.tn; |
| 6001 | var integer trx_nr := 0; |
| 6002 | var integer bts_nr := 0; |
| 6003 | var integer pcu_conn_id := -1; |
| 6004 | |
| 6005 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6006 | |
| 6007 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6008 | f_sleep(3.0); |
| 6009 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6010 | |
| 6011 | setverdict(pass); |
| 6012 | |
| 6013 | } |
| 6014 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6015 | var ConnHdlrPars pars; |
| 6016 | var ConnHdlr vc_conn; |
| 6017 | f_init(); |
| 6018 | |
| 6019 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6020 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6021 | vc_conn.done; |
| 6022 | } |
| 6023 | |
| 6024 | /* 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] | 6025 | 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] | 6026 | var PCUIF_Message first_info; |
| 6027 | var integer ts_nr := g_chan_nr.tn; |
| 6028 | var integer trx_nr := 0; |
| 6029 | var integer bts_nr := 0; |
| 6030 | var integer pcu_conn_id := -1; |
| 6031 | |
| 6032 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6033 | |
| 6034 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6035 | "RSL CHAN ACT"); |
| 6036 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6037 | "RF CHAN REL", true); |
| 6038 | setverdict(pass); |
| 6039 | } |
| 6040 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6041 | var ConnHdlrPars pars; |
| 6042 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6043 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6044 | |
| 6045 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6046 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6047 | vc_conn.done; |
| 6048 | } |
| 6049 | |
| 6050 | /* 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] | 6051 | 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] | 6052 | var PCUIF_Message first_info; |
| 6053 | var integer ts_nr := g_chan_nr.tn; |
| 6054 | var integer trx_nr := 0; |
| 6055 | var integer bts_nr := 0; |
| 6056 | var integer pcu_conn_id := -1; |
| 6057 | |
| 6058 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6059 | |
| 6060 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6061 | "RSL CHAN ACT"); |
| 6062 | |
| 6063 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6064 | alt { |
| 6065 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6066 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6067 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6068 | } |
| 6069 | [] RSL.receive { repeat; } |
| 6070 | } |
| 6071 | |
| 6072 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6073 | "RF CHAN REL", true); |
| 6074 | setverdict(pass); |
| 6075 | } |
| 6076 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6077 | var ConnHdlrPars pars; |
| 6078 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6079 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6080 | |
| 6081 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6082 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 6083 | vc_conn.done; |
| 6084 | } |
| 6085 | |
| 6086 | /* 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] | 6087 | 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] | 6088 | var PCUIF_Message first_info; |
| 6089 | var integer ts_nr := g_chan_nr.tn; |
| 6090 | var integer trx_nr := 0; |
| 6091 | var integer bts_nr := 0; |
| 6092 | var integer pcu_conn_id := -1; |
| 6093 | |
| 6094 | /* register for the TCH/F channel number */ |
| 6095 | f_rslem_register(0, g_chan_nr); |
| 6096 | |
| 6097 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6098 | |
| 6099 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6100 | |
| 6101 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6102 | "RSL CHAN ACT"); |
| 6103 | |
| 6104 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6105 | |
| 6106 | setverdict(pass); |
| 6107 | } |
| 6108 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6109 | var ConnHdlrPars pars; |
| 6110 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6111 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6112 | |
| 6113 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6114 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6115 | vc_conn.done; |
| 6116 | } |
| 6117 | |
| 6118 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6119 | /*********************************************************************** |
| 6120 | * LAPDm / RLL related |
| 6121 | ***********************************************************************/ |
| 6122 | |
| 6123 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6124 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6125 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6126 | var template (value) SacchL1Header l1h; |
| 6127 | |
| 6128 | /* 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] | 6129 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6130 | /* Compose dummy L1 header */ |
| 6131 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 6132 | 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] | 6133 | } else { |
| 6134 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6135 | 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] | 6136 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6137 | } |
| 6138 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6139 | private type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6140 | uint3_t sapi, |
| 6141 | RslLinkId link_id, |
| 6142 | octetstring l3, |
| 6143 | boolean exp |
| 6144 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6145 | private type record of RllTestCase RllTestCases; |
| 6146 | private template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, |
| 6147 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6148 | sapi := sapi, |
| 6149 | link_id := id, |
| 6150 | l3 := l3, |
| 6151 | exp := exp |
| 6152 | } |
| 6153 | |
| 6154 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6155 | * variety of logical channels */ |
| 6156 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6157 | var ConnHdlrPars pars; |
| 6158 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6159 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6160 | |
| 6161 | /* test on each of the channels we have */ |
| 6162 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6163 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6164 | |
| 6165 | /* test each of the test cases on the current channel */ |
| 6166 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6167 | pars.spec.rll := tcs[j]; |
| 6168 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6169 | vc_conn := f_start_handler(fn, pars); |
| 6170 | vc_conn.done; |
| 6171 | } |
| 6172 | } |
| 6173 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6174 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6175 | } |
| 6176 | |
| 6177 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6178 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6179 | var RllTestCase tc := g_pars.spec.rll; |
| 6180 | timer T := 3.0; |
| 6181 | |
| 6182 | f_l1_tune(L1CTL); |
| 6183 | RSL.clear; |
| 6184 | |
| 6185 | /* activate the logical channel */ |
| 6186 | f_est_dchan(); |
| 6187 | L1CTL.clear; |
| 6188 | |
| 6189 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6190 | T.start; |
| 6191 | alt { |
| 6192 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6193 | if (tc.exp) { |
| 6194 | setverdict(pass); |
| 6195 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6196 | 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] | 6197 | } |
| 6198 | } |
| 6199 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6200 | if (tc.exp) { |
| 6201 | setverdict(pass); |
| 6202 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6203 | 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] | 6204 | } |
| 6205 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6206 | /* We also expect to receive the measurements */ |
| 6207 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6208 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6209 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6210 | } |
| 6211 | [not tc.exp] T.timeout { |
| 6212 | setverdict(pass); |
| 6213 | } |
| 6214 | } |
| 6215 | |
| 6216 | f_rsl_chan_deact(); |
| 6217 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6218 | f_rslem_unregister(0, g_chan_nr); |
| 6219 | } |
| 6220 | testcase TC_rll_est_ind() runs on test_CT { |
| 6221 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6222 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6223 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6224 | /* normal SAPI0 establishment */ |
| 6225 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6226 | /* SAPI 3 doesn't support contention resolution */ |
| 6227 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 6228 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 6229 | /* normal SAPI3 establishment on main DCCH */ |
| 6230 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6231 | /* normal SAPI3 establishment on SACCH */ |
| 6232 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6233 | }; |
| 6234 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6235 | } |
| 6236 | |
| 6237 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6238 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6239 | var RllTestCase tc := g_pars.spec.rll; |
| 6240 | var L1ctlDlMessage dl; |
| 6241 | timer T := 3.0; |
| 6242 | |
| 6243 | f_l1_tune(L1CTL); |
| 6244 | RSL.clear; |
| 6245 | |
| 6246 | /* activate the logical channel */ |
| 6247 | f_est_dchan(); |
| 6248 | L1CTL.clear; |
| 6249 | |
| 6250 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6251 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 6252 | T.start; |
| 6253 | alt { |
| 6254 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6255 | var LapdmFrame lapdm; |
| 6256 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6257 | if (dl.dl_info.link_id.c == SACCH) { |
| 6258 | /* remove L1 header */ |
| 6259 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6260 | } |
| 6261 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6262 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 6263 | setverdict(pass); |
| 6264 | } else { |
| 6265 | repeat; |
| 6266 | } |
| 6267 | } |
| 6268 | [] L1CTL.receive { repeat; } |
| 6269 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6270 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6271 | } |
| 6272 | } |
| 6273 | |
| 6274 | f_rsl_chan_deact(); |
| 6275 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6276 | f_rslem_unregister(0, g_chan_nr); |
| 6277 | } |
| 6278 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 6279 | var RllTestCases tcs := { |
| 6280 | /* normal SAPI3 establishment on main DCCH */ |
| 6281 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 6282 | }; |
| 6283 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6284 | } |
| 6285 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 6286 | var RllTestCases tcs := { |
| 6287 | /* normal SAPI3 establishment on SACCH */ |
| 6288 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6289 | } |
| 6290 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6291 | } |
| 6292 | |
| 6293 | /* altstep to receive a LAPDm frame matching the given template */ |
| 6294 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 6295 | var L1ctlDlMessage dl; |
| 6296 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6297 | var LapdmFrame lapdm; |
| 6298 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6299 | if (dl.dl_info.link_id.c == SACCH) { |
| 6300 | /* remove L1 header */ |
| 6301 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6302 | } |
| 6303 | if (ischosen(exp.ab)) { |
| 6304 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6305 | } else if (ischosen(exp.b4)) { |
| 6306 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 6307 | } else if (ischosen(exp.bbis)) { |
| 6308 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 6309 | } |
| 6310 | log("Rx LAPDm ", lapdm); |
| 6311 | if (match(lapdm, exp)) { |
| 6312 | setverdict(pass); |
| 6313 | } else { |
| 6314 | repeat; |
| 6315 | } |
| 6316 | } |
| 6317 | [] L1CTL.receive { repeat; } |
| 6318 | } |
| 6319 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 6320 | timer T := t; |
| 6321 | T.start; |
| 6322 | alt { |
| 6323 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6324 | 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] | 6325 | } |
| 6326 | [] as_l1_exp_lapdm(exp); |
| 6327 | } |
| 6328 | } |
| 6329 | |
| 6330 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 6331 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 6332 | /* send SABM from MS -> BTS */ |
| 6333 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 6334 | /* expect RLL EST IND on Abis */ |
| 6335 | alt { |
| 6336 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 6337 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 6338 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6339 | 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] | 6340 | } |
| 6341 | [] RSL.receive { repeat; } |
| 6342 | } |
| 6343 | /* expect UA from BTS -> MS */ |
| 6344 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 6345 | } |
| 6346 | |
| 6347 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 6348 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 6349 | var RllTestCase tc := g_pars.spec.rll; |
| 6350 | |
| 6351 | f_l1_tune(L1CTL); |
| 6352 | RSL.clear; |
| 6353 | |
| 6354 | /* activate the logical channel */ |
| 6355 | f_est_dchan(); |
| 6356 | L1CTL.clear; |
| 6357 | |
| 6358 | /* first establish the link-layer */ |
| 6359 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6360 | |
| 6361 | /* then send the DISC */ |
| 6362 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 6363 | /* ... and expect the REL IND on the RSL side */ |
| 6364 | alt { |
| 6365 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 6366 | setverdict(pass); |
| 6367 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6368 | /* We also expect to receive the measurements */ |
| 6369 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6370 | } |
| 6371 | |
| 6372 | /* release the channel */ |
| 6373 | f_rsl_chan_deact(); |
| 6374 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6375 | f_rslem_unregister(0, g_chan_nr); |
| 6376 | } |
| 6377 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6378 | var RllTestCases tcs := { |
| 6379 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 6380 | }; |
| 6381 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6382 | } |
| 6383 | |
| 6384 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6385 | var RllTestCases tcs := { |
| 6386 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 6387 | }; |
| 6388 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6389 | } |
| 6390 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6391 | var RllTestCases tcs := { |
| 6392 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 6393 | }; |
| 6394 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6395 | } |
| 6396 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6397 | var RllTestCases tcs := { |
| 6398 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6399 | }; |
| 6400 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6401 | } |
| 6402 | |
| 6403 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6404 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6405 | var RllTestCase tc := g_pars.spec.rll; |
| 6406 | f_l1_tune(L1CTL); |
| 6407 | RSL.clear; |
| 6408 | |
| 6409 | /* activate the logical channel */ |
| 6410 | f_est_dchan(); |
| 6411 | L1CTL.clear; |
| 6412 | |
| 6413 | /* first establish the link-layer */ |
| 6414 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6415 | |
| 6416 | /* then send the REL REQ via RSL */ |
| 6417 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6418 | /* ... and expect the DISC on the Um side */ |
| 6419 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6420 | [] 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] | 6421 | /* FIXME: send a UA in resposne to the DISC */ |
| 6422 | } |
| 6423 | } |
| 6424 | |
| 6425 | /* release the channel */ |
| 6426 | f_rsl_chan_deact(); |
| 6427 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6428 | f_rslem_unregister(0, g_chan_nr); |
| 6429 | } |
| 6430 | testcase TC_rll_rel_req() runs on test_CT { |
| 6431 | var RllTestCases tcs := { |
| 6432 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 6433 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 6434 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6435 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6436 | }; |
| 6437 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6438 | } |
| 6439 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6440 | /* 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] | 6441 | testcase TC_rll_data_req() runs on test_CT { |
| 6442 | } |
| 6443 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6444 | /* 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] | 6445 | testcase TC_rll_data_ind() runs on test_CT { |
| 6446 | } |
| 6447 | |
| 6448 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6449 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6450 | var RllTestCase tc := g_pars.spec.rll; |
| 6451 | |
| 6452 | f_l1_tune(L1CTL); |
| 6453 | RSL.clear; |
| 6454 | |
| 6455 | f_est_dchan(); |
| 6456 | L1CTL.clear; |
| 6457 | |
| 6458 | /* Send UNITDATA REQ on RSL side */ |
| 6459 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6460 | /* Expect it to arrive on the other side */ |
| 6461 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6462 | 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] | 6463 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6464 | 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] | 6465 | } |
| 6466 | |
| 6467 | /* release the channel */ |
| 6468 | f_rsl_chan_deact(); |
| 6469 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6470 | f_rslem_unregister(0, g_chan_nr); |
| 6471 | } |
| 6472 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6473 | var octetstring l3 := f_rnd_octstring(15); |
| 6474 | var RllTestCases tcs := { |
| 6475 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6476 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6477 | }; |
| 6478 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6479 | } |
| 6480 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6481 | var octetstring l3 := f_rnd_octstring(19); |
| 6482 | var RllTestCases tcs := { |
| 6483 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6484 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6485 | }; |
| 6486 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6487 | } |
| 6488 | |
| 6489 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6490 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6491 | var RllTestCase tc := g_pars.spec.rll; |
| 6492 | |
| 6493 | f_l1_tune(L1CTL); |
| 6494 | RSL.clear; |
| 6495 | |
| 6496 | f_est_dchan(); |
| 6497 | L1CTL.clear; |
| 6498 | |
| 6499 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6500 | 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] | 6501 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6502 | alt { |
| 6503 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6504 | setverdict(pass); |
| 6505 | } |
| 6506 | [] RSL.receive { repeat; } |
| 6507 | } |
| 6508 | |
| 6509 | /* release the channel */ |
| 6510 | f_rsl_chan_deact(); |
| 6511 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6512 | f_rslem_unregister(0, g_chan_nr); |
| 6513 | } |
| 6514 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6515 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6516 | var RllTestCases tcs := { |
| 6517 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6518 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6519 | }; |
| 6520 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6521 | } |
| 6522 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6523 | var octetstring l3 := f_rnd_octstring(18); |
| 6524 | var RllTestCases tcs := { |
| 6525 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6526 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6527 | }; |
| 6528 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6529 | } |
| 6530 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6531 | /*********************************************************************** |
| 6532 | * Encryption Related |
| 6533 | ***********************************************************************/ |
| 6534 | |
| 6535 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6536 | 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] | 6537 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6538 | if (link_id.c == SACCH) { |
| 6539 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6540 | } else { |
| 6541 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6542 | } |
| 6543 | } |
| 6544 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6545 | /* Expect (or not expect) other kinds of messages */ |
| 6546 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6547 | [exp_any] RSL.receive { repeat; } |
| 6548 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6550 | } |
| 6551 | } |
| 6552 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6553 | /* 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] | 6554 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6555 | RslLinkId link_id, |
| 6556 | octetstring l3, |
| 6557 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6558 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6559 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6560 | timer T := 3.0; |
| 6561 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6562 | T.start; |
| 6563 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6564 | alt { |
| 6565 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6566 | setverdict(pass); |
| 6567 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6568 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6569 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6570 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6571 | 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] | 6572 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6573 | } |
| 6574 | } |
| 6575 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6576 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6577 | private function f_data_mo( |
| 6578 | RslLinkId link_id, |
| 6579 | boolean p, uint3_t nr, uint3_t ns, |
| 6580 | octetstring l3, |
| 6581 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6582 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6583 | ) runs on ConnHdlr { |
| 6584 | timer T := 3.0; |
| 6585 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6586 | T.start; |
| 6587 | /* Expect RLL DATA IND on RSL side */ |
| 6588 | alt { |
| 6589 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6590 | setverdict(pass); |
| 6591 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6592 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6593 | [] as_rsl_any_ind(exp_any); |
| 6594 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6595 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6596 | } |
| 6597 | } |
| 6598 | } |
| 6599 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6600 | /* 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] | 6601 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6602 | f_l1_tune(L1CTL); |
| 6603 | f_est_dchan(true); |
| 6604 | |
| 6605 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6606 | var L1ctlDlMessage dl; |
| 6607 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6608 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6609 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6610 | |
| 6611 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6612 | f_unitdata_mt(link_id, l3); |
| 6613 | |
| 6614 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6615 | f_unitdata_mo(link_id, l3); |
| 6616 | |
| 6617 | /* release the channel */ |
| 6618 | f_rsl_chan_deact(); |
| 6619 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6620 | f_rslem_unregister(0, g_chan_nr); |
| 6621 | } |
| 6622 | testcase TC_chan_act_a51() runs on test_CT { |
| 6623 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6624 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6625 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6626 | } |
| 6627 | testcase TC_chan_act_a52() runs on test_CT { |
| 6628 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6629 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6630 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6631 | } |
| 6632 | testcase TC_chan_act_a53() runs on test_CT { |
| 6633 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6634 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6635 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6636 | } |
| 6637 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6638 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6639 | 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] | 6640 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6641 | f_l1_tune(L1CTL); |
| 6642 | f_est_dchan(true); |
| 6643 | |
| 6644 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6645 | var L1ctlDlMessage dl; |
| 6646 | |
| 6647 | var octetstring l3 := f_rnd_octstring(20); |
| 6648 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6649 | |
| 6650 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6651 | f_unitdata_mt(link_id, l3); |
| 6652 | |
| 6653 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6654 | f_unitdata_mo(link_id, l3); |
| 6655 | |
| 6656 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6657 | 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] | 6658 | |
| 6659 | /* modify key to break proper encryption */ |
| 6660 | g_pars.encr.key := f_rnd_octstring(8); |
| 6661 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6662 | rsl.ies := rsl.ies & { ei }; |
| 6663 | RSL.send(rsl); |
| 6664 | |
| 6665 | timer T0 := 1.0; |
| 6666 | T0.start; |
| 6667 | /* Expect RSL MODIFY ACK */ |
| 6668 | alt { |
| 6669 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6670 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6671 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6672 | } |
| 6673 | [] T0.timeout { |
| 6674 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6675 | } |
| 6676 | } |
| 6677 | |
| 6678 | var octetstring l3msg := f_rnd_octstring(15); |
| 6679 | timer T1 := 3.0; |
| 6680 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6681 | due to broken encryption */ |
| 6682 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6683 | T1.start; |
| 6684 | alt { |
| 6685 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6686 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6687 | } |
| 6688 | [] T1.timeout { |
| 6689 | setverdict(pass); |
| 6690 | } |
| 6691 | } |
| 6692 | |
| 6693 | /* release the channel */ |
| 6694 | f_rsl_chan_deact(); |
| 6695 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6696 | f_rslem_unregister(0, g_chan_nr); |
| 6697 | } |
| 6698 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6699 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6700 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6701 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6702 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6703 | |
| 6704 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6705 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6706 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6707 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6708 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6709 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6710 | |
| 6711 | f_l1_tune(L1CTL); |
| 6712 | |
| 6713 | /* first establish a dedicated channel in the clear */ |
| 6714 | f_est_dchan(false); |
| 6715 | |
| 6716 | /* Establish ABM */ |
| 6717 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6718 | |
| 6719 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6720 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6721 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6722 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6723 | |
| 6724 | /* configure L1 to apply ciphering */ |
| 6725 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6726 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6727 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6728 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6729 | 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] | 6730 | |
| 6731 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6732 | * and hence enable encryption also on the downlink */ |
| 6733 | |
| 6734 | /* expect bi-directional communication work in encrypted mode */ |
| 6735 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6736 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6737 | |
| 6738 | /* release the channel */ |
| 6739 | f_rsl_chan_deact(); |
| 6740 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6741 | f_rslem_unregister(0, g_chan_nr); |
| 6742 | } |
| 6743 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6744 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6745 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6746 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6747 | } |
| 6748 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6749 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6750 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6751 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6752 | } |
| 6753 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6754 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6755 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6756 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6757 | } |
| 6758 | |
| 6759 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6760 | var LapdmFrame lf; |
| 6761 | var octetstring reenc; |
| 6762 | |
| 6763 | /* decode the LAPDm frame */ |
| 6764 | if (ischosen(exp_match.ab)) { |
| 6765 | lf.ab := dec_LapdmFrameAB(enc); |
| 6766 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6767 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6768 | } |
| 6769 | |
| 6770 | /* check if decoder result matches expectation */ |
| 6771 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6772 | 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] | 6773 | } else { |
| 6774 | log(name, ": matched"); |
| 6775 | setverdict(pass); |
| 6776 | } |
| 6777 | |
| 6778 | /* test if re-encoded frame equals original input */ |
| 6779 | reenc := enc_LapdmFrame(lf); |
| 6780 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6781 | 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] | 6782 | } else { |
| 6783 | setverdict(pass); |
| 6784 | } |
| 6785 | } |
| 6786 | |
| 6787 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6788 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6789 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6790 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6791 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6792 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6793 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6794 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6795 | } |
| 6796 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6797 | /*********************************************************************** |
| 6798 | * DTX Related (see GSM 05.08, section 8.3) |
| 6799 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6800 | 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] | 6801 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6802 | var GsmFrameNumber first_fn; |
| 6803 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6804 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6805 | 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] | 6806 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6807 | 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] | 6808 | const integer frame_dtx_tchf_mod := 104; |
| 6809 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6810 | * which operates in terms of blocks rather than frames. */ |
| 6811 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6812 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6813 | timer T := 5.0; |
| 6814 | |
| 6815 | f_l1_tune(L1CTL); |
| 6816 | RSL.clear; |
| 6817 | L1CTL.clear; |
| 6818 | |
| 6819 | /* activate TCHF signalling channel */ |
| 6820 | f_est_dchan(false); |
| 6821 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6822 | /* A template for matching dummy LAPDm func=UA frames */ |
| 6823 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 6824 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 6825 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 6826 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6827 | T.start; |
| 6828 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6829 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6830 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6831 | |
| 6832 | if (is_first_frame) { |
| 6833 | is_first_frame := false; |
| 6834 | first_fn := dl.dl_info.frame_nr; |
| 6835 | } |
| 6836 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6837 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6838 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6839 | T.stop; |
| 6840 | f_rsl_chan_deact(); |
| 6841 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6842 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6843 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 6844 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6845 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6846 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6847 | setverdict(fail, "Not enough fill frames received: ", |
| 6848 | nfill_frames, " out of ", expected_fill_frames); |
| 6849 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6850 | } else { |
| 6851 | setverdict(pass); |
| 6852 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6853 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6854 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6855 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6856 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6857 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6858 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6859 | 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] | 6860 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6861 | repeat; |
| 6862 | } |
| 6863 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6864 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 6865 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6866 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6867 | f_rsl_chan_deact(); |
| 6868 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6869 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6870 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6871 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6872 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6873 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6874 | |
| 6875 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6876 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 6877 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6878 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 6879 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 6880 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6881 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 6882 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6883 | case else { |
| 6884 | /* This shall not happen, just to be sure */ |
| 6885 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6886 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6887 | } |
| 6888 | |
| 6889 | f_rsl_chan_deact(); |
| 6890 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6891 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6892 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6893 | setverdict(pass); |
| 6894 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 6895 | setverdict(fail, "Not enough fill frames received: ", |
| 6896 | nfill_frames, " out of ", expected_fill_frames); |
| 6897 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6898 | } |
| 6899 | } else { |
| 6900 | repeat; |
| 6901 | } |
| 6902 | } |
| 6903 | } |
| 6904 | [] L1CTL.receive { repeat; } |
| 6905 | [] T.timeout { |
| 6906 | f_rsl_chan_deact(); |
| 6907 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6908 | 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] | 6909 | } |
| 6910 | } |
| 6911 | } |
| 6912 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6913 | 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] | 6914 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6915 | var ConnHdlr vc_conn; |
| 6916 | var ConnHdlrPars pars; |
| 6917 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6918 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6919 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6920 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6921 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6922 | if (dtxd) { |
| 6923 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6924 | break; |
| 6925 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6926 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 6927 | 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] | 6928 | vc_conn.done; |
| 6929 | } |
| 6930 | } |
| 6931 | |
| 6932 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6933 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6934 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6935 | f_tch_sign_l2_fill_frame(false); |
| 6936 | } |
| 6937 | |
| 6938 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6939 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6940 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6941 | f_tch_sign_l2_fill_frame(true); |
| 6942 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6943 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6944 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6945 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6946 | } |
| 6947 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6948 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6949 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6950 | } |
| 6951 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 6952 | |
| 6953 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 6954 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 6955 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 6956 | runs on ConnHdlr return octetstring; |
| 6957 | |
| 6958 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 6959 | runs on ConnHdlr { |
| 6960 | var L1ctlDlMessage l1_dl; |
| 6961 | var SacchL1Header l1h; |
| 6962 | var octetstring l2; |
| 6963 | |
| 6964 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 6965 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 6966 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 6967 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 6968 | |
| 6969 | /* Pass it to the user specified call-back function */ |
| 6970 | l2 := cb.apply(l1h, num_blocks); |
| 6971 | /* Send a Measurement Report generated by the call-back */ |
| 6972 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 6973 | l1_dl.dl_info.link_id, |
| 6974 | l1h, l2)); |
| 6975 | |
| 6976 | /* Shall we keep going? */ |
| 6977 | num_blocks := num_blocks - 1; |
| 6978 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 6979 | if (num_blocks > 0) { repeat; } |
| 6980 | } |
| 6981 | [] L1CTL.receive { repeat; } |
| 6982 | } |
| 6983 | |
| 6984 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 6985 | runs on ConnHdlr return octetstring { |
| 6986 | /* Command the L1 to apply received parameters */ |
| 6987 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 6988 | |
| 6989 | /* Dummy measurement report (the results are invalid) */ |
| 6990 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 6991 | } |
| 6992 | |
| 6993 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 6994 | runs on ConnHdlr return octetstring { |
| 6995 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 6996 | setverdict(fail, "Unexpected MS Power level change: ", |
| 6997 | g_pars.l1_pars.ms_power_level, " -> ", |
| 6998 | l1h.ms_power_lvl); |
| 6999 | } |
| 7000 | |
| 7001 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7002 | } |
| 7003 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7004 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7005 | runs on ConnHdlr return octetstring { |
| 7006 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7007 | if (num_blocks rem 2 == 0) { |
| 7008 | f_trxc_fake_rssi(-100); |
| 7009 | } else { |
| 7010 | f_trxc_fake_rssi(-50); |
| 7011 | } |
| 7012 | |
| 7013 | /* Make sure that MS power level remains constant */ |
| 7014 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7015 | } |
| 7016 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7017 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7018 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7019 | runs on ConnHdlr { |
| 7020 | var integer num_blocks := 8; |
| 7021 | timer T := int2float(num_blocks); |
| 7022 | |
| 7023 | f_l1_tune(L1CTL); |
| 7024 | RSL.clear; |
| 7025 | |
| 7026 | /* These IEs are needed for autonomous MS power control */ |
| 7027 | var template (value) RSL_IE_List ies := { |
| 7028 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7029 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7030 | }), |
| 7031 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7032 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7033 | }) |
| 7034 | }; |
| 7035 | |
| 7036 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7037 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7038 | |
| 7039 | /* Establish a dedicated channel */ |
| 7040 | f_est_dchan(more_ies := valueof(ies)); |
| 7041 | |
| 7042 | L1CTL.clear; |
| 7043 | T.start; |
| 7044 | alt { |
| 7045 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 7046 | [] T.timeout { |
| 7047 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7048 | num_blocks, " were not handled"); |
| 7049 | } |
| 7050 | } |
| 7051 | } |
| 7052 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 7053 | var ConnHdlr vc_conn; |
| 7054 | var ConnHdlrPars pars; |
| 7055 | |
| 7056 | f_init(); |
| 7057 | |
| 7058 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 7059 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 7060 | |
| 7061 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7062 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7063 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7064 | |
| 7065 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 7066 | pars, trxc_comp := true); |
| 7067 | vc_conn.done; |
| 7068 | } |
| 7069 | |
| 7070 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7071 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7072 | } |
| 7073 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7074 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 7075 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7076 | runs on ConnHdlr { |
| 7077 | var integer num_blocks := 16; |
| 7078 | timer T := int2float(num_blocks); |
| 7079 | |
| 7080 | f_l1_tune(L1CTL); |
| 7081 | RSL.clear; |
| 7082 | |
| 7083 | /* These IEs are needed for autonomous MS power control */ |
| 7084 | var template (value) RSL_IE_List ies := { |
| 7085 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7086 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7087 | }), |
| 7088 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7089 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7090 | }) |
| 7091 | }; |
| 7092 | |
| 7093 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7094 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7095 | |
| 7096 | /* Establish a dedicated channel */ |
| 7097 | f_est_dchan(more_ies := valueof(ies)); |
| 7098 | |
| 7099 | L1CTL.clear; |
| 7100 | T.start; |
| 7101 | alt { |
| 7102 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7103 | [] T.timeout { |
| 7104 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7105 | num_blocks, " were not handled"); |
| 7106 | } |
| 7107 | } |
| 7108 | } |
| 7109 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7110 | var ConnHdlr vc_conn; |
| 7111 | var ConnHdlrPars pars; |
| 7112 | |
| 7113 | f_init(); |
| 7114 | |
| 7115 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7116 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7117 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7118 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7119 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7120 | |
| 7121 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7122 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7123 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7124 | |
| 7125 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7126 | pars, trxc_comp := true); |
| 7127 | vc_conn.done; |
| 7128 | } |
| 7129 | |
| 7130 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7131 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7132 | } |
| 7133 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7134 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7135 | var template L1ctlDlMessage tr_bad_frame; |
| 7136 | var L1ctlDlMessage l1_dl; |
| 7137 | timer T := 8.0; |
| 7138 | |
| 7139 | f_l1_tune(L1CTL); |
| 7140 | RSL.clear; |
| 7141 | |
| 7142 | f_est_dchan(); |
| 7143 | |
| 7144 | /* There may be a few errors right after the channel activation */ |
| 7145 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 7146 | L1CTL.clear; |
| 7147 | |
| 7148 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 7149 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 7150 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 7151 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 7152 | tr_bad_frame.payload := ?; |
| 7153 | |
| 7154 | T.start; |
| 7155 | alt { |
| 7156 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 7157 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 7158 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 7159 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 7160 | } |
| 7161 | [] as_l1_sacch(); |
| 7162 | [] L1CTL.receive { repeat; } |
| 7163 | [] T.timeout { |
| 7164 | /* We're done, break the loop */ |
| 7165 | setverdict(pass); |
| 7166 | } |
| 7167 | } |
| 7168 | |
| 7169 | f_rsl_chan_deact(); |
| 7170 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7171 | } |
| 7172 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 7173 | var ConnHdlr vc_conn; |
| 7174 | var ConnHdlrPars pars; |
| 7175 | |
| 7176 | f_init(); |
| 7177 | |
| 7178 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7179 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7180 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7181 | vc_conn.done; |
| 7182 | } |
| 7183 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 7184 | var ConnHdlr vc_conn; |
| 7185 | var ConnHdlrPars pars; |
| 7186 | |
| 7187 | f_init(); |
| 7188 | |
| 7189 | /* TS5, TCH/H, V1 (HR codec) */ |
| 7190 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7191 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7192 | vc_conn.done; |
| 7193 | } |
| 7194 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7195 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 7196 | /* protocol error as per 44.006 */ |
| 7197 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 7198 | /* repetition of SABM or DISC N200 times without ACK */ |
| 7199 | /* receptiom of SABM in multi-frame established state */ |
| 7200 | |
| 7201 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7202 | /* TODO Areas: |
| 7203 | |
| 7204 | * channel activation |
| 7205 | ** with BS_Power / MS_Power, bypassing power control loop |
| 7206 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7207 | ** with timing advance from initial activation on |
| 7208 | * mode modify |
| 7209 | ** encryption |
| 7210 | ** multirate |
| 7211 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7212 | ** unsupported algorithm |
| 7213 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7214 | * BS Power Control |
| 7215 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7216 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7217 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7218 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7219 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7220 | ** DATA_IND from BTS->PCU |
| 7221 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7222 | |
| 7223 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7224 | |
| 7225 | control { |
| 7226 | execute( TC_chan_act_stress() ); |
| 7227 | execute( TC_chan_act_react() ); |
| 7228 | execute( TC_chan_deact_not_active() ); |
| 7229 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 7230 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 7231 | execute( TC_sacch_filling() ); |
| 7232 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 7233 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 7234 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 7235 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 7236 | execute( TC_sacch_chan_act_ho_async() ); |
| 7237 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7238 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 7239 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7240 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 7241 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 7242 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 7243 | execute( TC_rach_load_idle_thresh0() ); |
| 7244 | execute( TC_rach_load_idle_below_thresh() ); |
| 7245 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7246 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7247 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7248 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7249 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 7250 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7251 | execute( TC_meas_res_sign_tchf() ); |
| 7252 | execute( TC_meas_res_sign_tchh() ); |
| 7253 | execute( TC_meas_res_sign_sdcch4() ); |
| 7254 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 7255 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 7256 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 7257 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 7258 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 7259 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 7260 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 7261 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 7262 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 7263 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 7264 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 7265 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 7266 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 7267 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 7268 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 7269 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7270 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7271 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7272 | execute( TC_paging_imsi_80percent() ); |
| 7273 | execute( TC_paging_tmsi_80percent() ); |
| 7274 | execute( TC_paging_imsi_200percent() ); |
| 7275 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 7276 | execute( TC_rsl_protocol_error() ); |
| 7277 | execute( TC_rsl_mand_ie_error() ); |
| 7278 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7279 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 7280 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7281 | execute( TC_si_sched_2bis() ); |
| 7282 | execute( TC_si_sched_2ter() ); |
| 7283 | execute( TC_si_sched_2ter_2bis() ); |
| 7284 | execute( TC_si_sched_2quater() ); |
| 7285 | execute( TC_si_sched_13() ); |
| 7286 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 7287 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 7288 | execute( TC_ipa_crcx_twice_not_active() ); |
| 7289 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 7290 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 7291 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7292 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7293 | if (mp_pcu_socket != "") { |
| 7294 | execute( TC_pcu_act_req() ); |
| 7295 | execute( TC_pcu_act_req_wrong_ts() ); |
| 7296 | execute( TC_pcu_act_req_wrong_bts() ); |
| 7297 | execute( TC_pcu_act_req_wrong_trx() ); |
| 7298 | execute( TC_pcu_deact_req() ); |
| 7299 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 7300 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7301 | if (mp_l1_supports_gprs) { |
| 7302 | execute( TC_pcu_data_req_pdtch() ); |
| 7303 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 7304 | execute( TC_pcu_data_req_wrong_bts() ); |
| 7305 | execute( TC_pcu_data_req_wrong_trx() ); |
| 7306 | execute( TC_pcu_data_req_wrong_ts() ); |
| 7307 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7308 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 7309 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7310 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 7311 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7312 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 7313 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 7314 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 7315 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7316 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 7317 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 7318 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 7319 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 7320 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 7321 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 7322 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7323 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7324 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7325 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7326 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7327 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7328 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 7329 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 7330 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 7331 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 7332 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 7333 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 7334 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 7335 | if (PCUIF_Types.mp_pcuif_version >= 10) { |
| 7336 | execute( TC_pcu_info_ind_fh_params() ); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 7337 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 7338 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 7339 | } |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7340 | } else { |
| 7341 | log("PCU socket path not available, skipping PCU tests"); |
| 7342 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7343 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7344 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7345 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 7346 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7347 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 7348 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7349 | |
| 7350 | execute( TC_rll_est_ind() ); |
| 7351 | execute( TC_rll_est_req_DCCH_3() ); |
| 7352 | execute( TC_rll_est_req_ACCH_3() ); |
| 7353 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 7354 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 7355 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 7356 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 7357 | execute( TC_rll_rel_req() ); |
| 7358 | execute( TC_rll_unit_data_req_DCCH() ); |
| 7359 | execute( TC_rll_unit_data_req_ACCH() ); |
| 7360 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 7361 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7362 | |
| 7363 | execute( TC_chan_act_a51() ); |
| 7364 | execute( TC_chan_act_a52() ); |
| 7365 | execute( TC_chan_act_a53() ); |
| 7366 | execute( TC_encr_cmd_a51() ); |
| 7367 | execute( TC_encr_cmd_a52() ); |
| 7368 | execute( TC_encr_cmd_a53() ); |
| 7369 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 7370 | execute( TC_err_rep_wrong_mdisc() ); |
| 7371 | execute( TC_err_rep_wrong_msg_type() ); |
| 7372 | execute( TC_err_rep_wrong_sequence() ); |
| 7373 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7374 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7375 | |
| 7376 | execute( TC_tch_sign_l2_fill_frame() ); |
| 7377 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7378 | |
| 7379 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7380 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7381 | |
| 7382 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7383 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7384 | |
| 7385 | execute( TC_speech_no_rtp_tchf() ); |
| 7386 | execute( TC_speech_no_rtp_tchh() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7387 | } |
| 7388 | |
| 7389 | |
| 7390 | } |