Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 3 | /* Integration Tests for OsmoBTS |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 4 | * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 5 | * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 13 | * This test suite tests OsmoBTS by attaching to the external interfaces |
| 14 | * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation |
| 15 | * using the L1CTL protocol/interface. |
| 16 | * |
| 17 | * You can run the tests with |
| 18 | * a) osmo-bts-trx + trxcon + fake_trx (without any hardware) |
| 19 | * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware) |
| 20 | * c) osmo-bts-virtual + virt_phy (without any hardware) |
| 21 | * |
| 22 | * Some of the tests will only run on a subset of those three configurations |
| 23 | * due to limitations in the respective L1. |
| 24 | */ |
| 25 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 26 | import from Misc_Helpers all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 27 | import from General_Types all; |
| 28 | import from GSM_Types all; |
| 29 | import from GSM_RR_Types all; |
| 30 | import from Osmocom_Types all; |
| 31 | import from GSM_Types all; |
Vadim Yanitskiy | 5d2cf44 | 2020-05-02 16:49:17 +0700 | [diff] [blame] | 32 | import from GSM_RestOctets all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 33 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 34 | import from L1CTL_PortType all; |
| 35 | import from L1CTL_Types all; |
| 36 | import from LAPDm_Types all; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 37 | import from LAPDm_RAW_PT all; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 38 | import from Native_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 39 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 40 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 41 | |
| 42 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 43 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 44 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 45 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 46 | import from RSL_Emulation all; |
| 47 | |
| 48 | import from IPL4asp_Types all; |
| 49 | import from TRXC_Types all; |
| 50 | import from TRXC_CodecPort all; |
| 51 | import from TRXC_CodecPort_CtrlFunct all; |
| 52 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 53 | import from PCUIF_Types all; |
| 54 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 55 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 56 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 57 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 58 | import from MobileL3_RRM_Types all; |
| 59 | import from MobileL3_Types all; |
| 60 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 61 | import from L3_Common all; |
| 62 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 63 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 64 | import from Osmocom_VTY_Functions all; |
| 65 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 66 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 67 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 68 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 69 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 70 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 71 | friend module BTS_Tests_perf; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 72 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 73 | /* The tests assume a BTS with the following timeslot configuration: |
| 74 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 75 | * TS1 : TCH/F |
| 76 | * TS2 : TCH/F |
| 77 | * TS3 : TCH/F_PDCH (IPA Style) |
| 78 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 79 | * TS5 : TCH/H |
| 80 | * TS6 : SDCCH/8 |
| 81 | * TS7 : PDCH |
| 82 | */ |
| 83 | |
| 84 | modulepar { |
| 85 | charstring mp_rsl_ip := "127.0.0.2"; |
| 86 | integer mp_rsl_port := 3003; |
| 87 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 88 | integer mp_trx1_arfcn := 873; |
| 89 | integer mp_trx2_arfcn := 875; |
| 90 | integer mp_trx3_arfcn := 877; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 91 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 92 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 93 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 94 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 95 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 96 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 97 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 98 | integer mp_tolerance_rxqual := 1; |
| 99 | integer mp_tolerance_rxlev := 3; |
| 100 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 101 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 102 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 103 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 104 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 105 | integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */ |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 106 | integer mp_ms_actual_ta_exp := 0; |
| 107 | integer mp_timing_offset_256syms_exp := 512; |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 108 | integer mp_uplink_power_target := -75; |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 109 | integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */ |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 110 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 111 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 112 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 113 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 114 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 115 | /* how many transceivers do we expect to connect */ |
| 116 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 117 | /* frequency hopping status */ |
| 118 | boolean mp_freq_hop_enabled := false; |
| 119 | /* frequency hopping parameters */ |
| 120 | FreqHopConfig mp_fh_config; |
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 | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 259 | friend type record FreqHopPars { |
| 260 | /* Whether frequency hopping is in use */ |
| 261 | boolean enabled, |
| 262 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 263 | MaioHsn maio_hsn, |
| 264 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 265 | MobileAllocationLV ma_map, |
| 266 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 267 | L1ctlMA ma |
| 268 | }; |
| 269 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 270 | type record ConnHdlrPars { |
| 271 | RslChannelNr chan_nr, |
| 272 | RSL_IE_ChannelMode chan_mode, |
| 273 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 274 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 275 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 276 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 277 | BtsBand bts0_band optional, |
| 278 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 279 | /* Frequency hopping parameters */ |
| 280 | FreqHopPars fhp |
| 281 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 282 | |
| 283 | /* Test-specific parameters */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 284 | private type union TestSpecUnion { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 285 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 288 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 289 | max_retrans := RACH_MAX_RETRANS_7, |
| 290 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 291 | cell_barr_access := false, |
| 292 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 293 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 294 | }; |
| 295 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 296 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 297 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 298 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 299 | acs := '0'B, |
| 300 | neci := true, |
| 301 | rxlev_access_min := 0 |
| 302 | } |
| 303 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 304 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 305 | mcc_mnc := '262F42'H, |
| 306 | lac := 42 |
| 307 | } |
| 308 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 309 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 310 | ra_colour := 0, |
| 311 | si13_pos := '0'B |
| 312 | } |
| 313 | |
| 314 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 315 | modifies ts_SI3RestOctets := { |
| 316 | gprs_ind := { |
| 317 | presence := CSN1_H, |
| 318 | ind := ts_GPRSIndicator_def |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 323 | modifies ts_SI4RestOctets := { |
| 324 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 325 | presence := CSN1_H, |
| 326 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 330 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 331 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 332 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 333 | payload := { |
| 334 | si3 := { |
| 335 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 336 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 337 | ctrl_chan_desc := { |
| 338 | msc_r99 := true, |
| 339 | att := true, |
| 340 | bs_ag_blks_res := 1, |
| 341 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 342 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 343 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 344 | spare := '00'B, |
| 345 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 346 | t3212 := 1 /* 6 minutes */ |
| 347 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 348 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 349 | dn_ind := false, |
| 350 | pwrc := false, |
| 351 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 352 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 353 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 354 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 355 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 356 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 360 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 361 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 362 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 363 | payload := { |
| 364 | si2 := { |
| 365 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 366 | ncc_permitted := '11111111'B, |
| 367 | rach_control := ts_RachCtrl_default |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 372 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 373 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 374 | payload := { |
| 375 | si4 := { |
| 376 | lai := ts_LAI_default, |
| 377 | cell_sel_par := ts_CellSelPar_default, |
| 378 | rach_control := ts_RachCtrl_default, |
| 379 | cbch_chan_desc := omit, |
| 380 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 381 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 386 | 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] | 387 | runs on test_CT { |
| 388 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 389 | 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] | 390 | } |
| 391 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 392 | 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] | 393 | runs on test_CT { |
| 394 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 395 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 396 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 397 | } |
| 398 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 399 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 400 | map(self:BTSVTY, system:BTSVTY); |
| 401 | f_vty_set_prompts(BTSVTY); |
| 402 | f_vty_transceive(BTSVTY, "enable"); |
| 403 | } |
| 404 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 405 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 406 | map(self:BSCVTY, system:BSCVTY); |
| 407 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 408 | f_vty_transceive(BSCVTY, "enable"); |
| 409 | } |
| 410 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 411 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 412 | map(self:BSCVTY, system:BSCVTY); |
| 413 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 414 | f_vty_transceive(BSCVTY, "enable"); |
| 415 | } |
| 416 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 417 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 418 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 419 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 420 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 421 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 422 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 423 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 424 | [] 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] | 425 | 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] | 426 | } |
| 427 | } |
| 428 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 429 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 430 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 431 | timer T := 2.0; |
| 432 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 433 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 434 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 435 | return; |
| 436 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 437 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 438 | |
| 439 | T.start; |
| 440 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 441 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 442 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 443 | 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] | 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 448 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 449 | out integer trxc_conn_id) { |
| 450 | var Result res; |
| 451 | |
| 452 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 453 | "", -1, -1, { udp := {} }, {}); |
| 454 | if (not ispresent(res.connId)) { |
| 455 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 456 | "Could not connect to the control (TRXC) interface " & |
| 457 | "of FakeTRX, check your configuration"); |
| 458 | } |
| 459 | trxc_conn_id := res.connId; |
| 460 | } |
| 461 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 462 | /* global init function */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 463 | friend function f_init() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 464 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 465 | g_AllChannels := { |
| 466 | /* TS 1..4: TCH/F */ |
| 467 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 468 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 469 | /* TS 5: TCH/H */ |
| 470 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 471 | /* TS 0: SDCCH/4 */ |
| 472 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 473 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 474 | /* TS 6: SDCCH/8 */ |
| 475 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 476 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 477 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 478 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 479 | }; |
| 480 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 481 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 482 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 483 | g_AllChanTypes := { |
| 484 | /* TS 1..4: TCH/F */ |
| 485 | valueof(ts_RslChanNr_Bm(1)), |
| 486 | /* TS 5: TCH/H */ |
| 487 | valueof(ts_RslChanNr_Lm(5,1)), |
| 488 | /* TS 0: SDCCH/4 */ |
| 489 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 490 | /* TS 6: SDCCH/8 */ |
| 491 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 492 | }; |
| 493 | } else { |
| 494 | g_AllChanTypes := { |
| 495 | /* TS 1..4: TCH/F */ |
| 496 | valueof(ts_RslChanNr_Bm(1)), |
| 497 | /* TS 0: SDCCH/4 */ |
| 498 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 499 | /* TS 6: SDCCH/8 */ |
| 500 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 501 | }; |
| 502 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 503 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 504 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 505 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 506 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 507 | |
| 508 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 509 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 510 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 511 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 512 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 513 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 514 | map(self:PCU, system:PCU); |
| 515 | 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] | 516 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 517 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 518 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 519 | |
| 520 | /* Init TRXC interface to FakeTRX */ |
| 521 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 522 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 523 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 524 | /* 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] | 525 | 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] | 526 | 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] | 527 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 528 | 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] | 529 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 530 | |
| 531 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 532 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 533 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 534 | } |
| 535 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 536 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 537 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 538 | map(self:L1CTL, system:L1CTL); |
| 539 | f_connect_reset(L1CTL); |
| 540 | } |
| 541 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 542 | private type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 543 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 544 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 545 | |
| 546 | private type record of FreqHopGroup FreqHopGroups; |
| 547 | private type record FreqHopGroup { |
| 548 | uint6_t hsn, |
| 549 | FreqHopGroupItems trx_maio |
| 550 | }; |
| 551 | |
| 552 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 553 | private type record FreqHopGroupItem { |
| 554 | uint8_t trx_nr, |
| 555 | uint6_t maio |
| 556 | }; |
| 557 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 558 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 559 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 560 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 561 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 562 | var integer i, j; |
| 563 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 564 | fhp.enabled := false; |
| 565 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 566 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 567 | var FreqHopGroup g := groups[i]; |
| 568 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 569 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 570 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 571 | fhp.maio_hsn.maio := gi.maio; |
| 572 | fhp.maio_hsn.hsn := g.hsn; |
| 573 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 574 | break; |
| 575 | } |
| 576 | } |
| 577 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 578 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 579 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 580 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 581 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 582 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 583 | |
| 584 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 585 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 586 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 587 | fhp.ma := fhp.ma & { l1ctl_ma_def[gi.trx_nr] }; |
| 588 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 589 | } |
| 590 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 591 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 592 | break; /* We're done */ |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 597 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 598 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 599 | boolean pcu_comp := false, |
| 600 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 601 | runs on test_CT return ConnHdlr { |
| 602 | var charstring id := testcasename(); |
| 603 | var ConnHdlr vc_conn; |
| 604 | |
| 605 | vc_conn := ConnHdlr.create(id); |
| 606 | /* connect to RSL Emulation main component */ |
| 607 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 608 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 609 | |
| 610 | /* The ConnHdlr component may want to talk to some ports directly, |
| 611 | * so we disconnect it from the test_CT and connect it to the component. |
| 612 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 613 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 614 | unmap(self:PCU, system:PCU); |
| 615 | map(vc_conn:PCU, system:PCU); |
| 616 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 617 | if (trxc_comp) { |
| 618 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 619 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 620 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 621 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 622 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 623 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 624 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 625 | } |
| 626 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 627 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 628 | return vc_conn; |
| 629 | } |
| 630 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 631 | private altstep as_Tguard() runs on ConnHdlr { |
| 632 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 633 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 634 | } |
| 635 | } |
| 636 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 637 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 638 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 639 | } |
| 640 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 641 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 642 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 643 | 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] | 644 | } |
| 645 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 646 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 647 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 648 | 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] | 649 | } |
| 650 | |
| 651 | /* first function started in ConnHdlr component */ |
| 652 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 653 | runs on ConnHdlr { |
| 654 | g_pars := pars; |
| 655 | g_chan_nr := pars.chan_nr; |
| 656 | |
| 657 | map(self:L1CTL, system:L1CTL); |
| 658 | f_connect_reset(L1CTL); |
| 659 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 660 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 661 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 662 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 663 | |
| 664 | g_Tguard.start(pars.t_guard); |
| 665 | activate(as_Tguard()); |
| 666 | |
| 667 | f_rslem_register(0, pars.chan_nr); |
| 668 | |
| 669 | /* call the user-supplied test case function */ |
| 670 | fn.apply(id); |
| 671 | } |
| 672 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 673 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 674 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 675 | runs on ConnHdlr return RSL_Message { |
| 676 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 677 | timer T := 3.0; |
| 678 | RSL.send(tx); |
| 679 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 680 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 681 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 682 | T.stop; |
| 683 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 684 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 685 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 686 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 687 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 688 | [not ignore_other] as_l1_sacch(); |
| 689 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 690 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 691 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 692 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 694 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 695 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 696 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 697 | return rx; |
| 698 | } |
| 699 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 700 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 701 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 702 | runs on ConnHdlr { |
| 703 | 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] | 704 | } |
| 705 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 706 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 707 | boolean encr_enable := false, |
| 708 | RSL_IE_List more_ies := {}, |
| 709 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 710 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 711 | 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] | 712 | if (encr_enable) { |
| 713 | /* append encryption related IEs, if requested */ |
| 714 | var RSL_IE_EncryptionInfo encr_info; |
| 715 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 716 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 717 | encr_info})) }; |
| 718 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 719 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 720 | 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] | 721 | } |
| 722 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 723 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 724 | 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] | 725 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 726 | } |
| 727 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 728 | /* Default Mobile Allocation to be used for frequency hopping */ |
| 729 | private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn }, |
| 730 | { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } }; |
| 731 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 732 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 733 | template RSL_IE_ChannelMode chan_mode, |
| 734 | float t_guard := 20.0) := { |
| 735 | chan_nr := valueof(chan_nr), |
| 736 | chan_mode := valueof(chan_mode), |
| 737 | t_guard := t_guard, |
| 738 | l1_pars := { |
| 739 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 740 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 741 | meas_ul := { |
| 742 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 743 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 744 | rxqual := 0 |
| 745 | }, |
| 746 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 747 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 748 | rxqual := 0 |
| 749 | } |
| 750 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 751 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 752 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 753 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 754 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 755 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 756 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 757 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 758 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 759 | bts0_band := omit, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 760 | fhp := { |
| 761 | enabled := false, |
| 762 | maio_hsn := ts_HsnMaio(0, 0), |
| 763 | ma_map := c_MA_null, |
| 764 | ma := l1ctl_ma_def |
| 765 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 766 | } |
| 767 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 768 | /*********************************************************************** |
| 769 | * Channel Activation / Deactivation |
| 770 | ***********************************************************************/ |
| 771 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 772 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 773 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 774 | for (var integer i := 0; i < 500; i := i+1) { |
| 775 | f_rsl_chan_act(g_pars.chan_mode); |
| 776 | f_rsl_chan_deact(); |
| 777 | } |
| 778 | setverdict(pass); |
| 779 | } |
| 780 | testcase TC_chan_act_stress() runs on test_CT { |
| 781 | var ConnHdlr vc_conn; |
| 782 | 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] | 783 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 784 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 785 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 786 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 790 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 791 | f_rsl_chan_act(g_pars.chan_mode); |
| 792 | /* attempt to activate the same lchan again -> expect reject */ |
| 793 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 794 | alt { |
| 795 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 796 | 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] | 797 | } |
| 798 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 799 | setverdict(pass); |
| 800 | } |
| 801 | } |
| 802 | f_rsl_chan_deact(); |
| 803 | } |
| 804 | testcase TC_chan_act_react() runs on test_CT { |
| 805 | var ConnHdlr vc_conn; |
| 806 | 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] | 807 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 808 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 809 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 810 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 814 | 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] | 815 | timer T := 3.0; |
| 816 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 817 | T.start; |
| 818 | alt { |
| 819 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 820 | setverdict(pass); |
| 821 | } |
| 822 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 823 | 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] | 824 | } |
| 825 | } |
| 826 | } |
| 827 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 828 | 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] | 829 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 830 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 831 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 832 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 836 | 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] | 837 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 838 | alt { |
| 839 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 840 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 841 | } |
| 842 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 843 | setverdict(pass); |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | private type record WrongChanNrCase { |
| 848 | RslChannelNr chan_nr, |
| 849 | charstring description |
| 850 | } |
| 851 | private type record of WrongChanNrCase WrongChanNrCases; |
| 852 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 853 | chan_nr := chan_nr, |
| 854 | description := desc |
| 855 | } |
| 856 | |
| 857 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 858 | var ConnHdlr vc_conn; |
| 859 | var ConnHdlrPars pars; |
| 860 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 861 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 862 | |
| 863 | var WrongChanNrCases wrong := { |
| 864 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 865 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 866 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 867 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 868 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 869 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 870 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 871 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 872 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 873 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 874 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 875 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 876 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 877 | }; |
| 878 | |
| 879 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 880 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 881 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 882 | vc_conn.done; |
| 883 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 884 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 885 | } |
| 886 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 887 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 888 | 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] | 889 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 890 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 891 | |
| 892 | /* test on each of the channels we have */ |
| 893 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 894 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 895 | |
| 896 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 897 | vc_conn := f_start_handler(fn, pars); |
| 898 | vc_conn.done; |
| 899 | } |
| 900 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 901 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 902 | } |
| 903 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 904 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 905 | * SACCH handling |
| 906 | ***********************************************************************/ |
| 907 | |
| 908 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 909 | timer T_sacch := 3.0; |
| 910 | T_sacch.start; |
| 911 | alt { |
| 912 | [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] | 913 | 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] | 914 | } |
| 915 | [not exp] T_sacch.timeout { |
| 916 | setverdict(pass); |
| 917 | } |
| 918 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 919 | setverdict(pass); |
| 920 | } |
| 921 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 922 | 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] | 923 | } |
| 924 | [] L1CTL.receive { repeat; } |
| 925 | [] RSL.receive { repeat; } |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 930 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 931 | f_l1_tune(L1CTL); |
| 932 | RSL.clear; |
| 933 | |
| 934 | /* activate the logical channel */ |
| 935 | f_est_dchan(); |
| 936 | L1CTL.clear; |
| 937 | |
| 938 | /* check that SACCH actually are received as expected */ |
| 939 | f_exp_sacch(true); |
| 940 | |
| 941 | /* deactivate SACCH on the logical channel */ |
| 942 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 943 | f_sleep(1.0); |
| 944 | L1CTL.clear; |
| 945 | |
| 946 | /* check that no SACCH are received anymore */ |
| 947 | f_exp_sacch(false); |
| 948 | |
| 949 | /* release the channel */ |
| 950 | f_rsl_chan_deact(); |
| 951 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 952 | } |
| 953 | testcase TC_deact_sacch() runs on test_CT { |
| 954 | var ConnHdlr vc_conn; |
| 955 | var ConnHdlrPars pars; |
| 956 | f_init(); |
| 957 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 958 | //for (var integer i := 0; i < 1; i := i+1) { |
| 959 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 960 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 961 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 962 | vc_conn.done; |
| 963 | } |
| 964 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 965 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 966 | } |
| 967 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 968 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 969 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 970 | var L1ctlDlMessage dl; |
| 971 | /* check that the specified SI5 value is actually sent */ |
| 972 | timer T_sacch := 3.0; |
| 973 | L1CTL.clear; |
| 974 | T_sacch.start; |
| 975 | alt { |
| 976 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 977 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 978 | if (match(l3, l3_exp)) { |
| 979 | setverdict(pass); |
| 980 | } else { |
| 981 | repeat; |
| 982 | } |
| 983 | } |
| 984 | [] L1CTL.receive { repeat; } |
| 985 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 986 | 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] | 987 | } |
| 988 | } |
| 989 | } |
| 990 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 991 | /* verify that given SACCH payload is not present */ |
| 992 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 993 | var L1ctlDlMessage dl; |
| 994 | /* check that the specified SI5 value is actually sent */ |
| 995 | timer T_sacch := 3.0; |
| 996 | L1CTL.clear; |
| 997 | T_sacch.start; |
| 998 | alt { |
| 999 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1000 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1001 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1002 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1003 | } else { |
| 1004 | repeat; |
| 1005 | } |
| 1006 | } |
| 1007 | [] L1CTL.receive { repeat; } |
| 1008 | [] T_sacch.timeout { |
| 1009 | setverdict(pass); |
| 1010 | } |
| 1011 | } |
| 1012 | } |
| 1013 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1014 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1015 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1016 | /* Set a known default SACCH filling for SI5 */ |
| 1017 | var octetstring si5 := f_rnd_octstring(19); |
| 1018 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1019 | |
| 1020 | f_l1_tune(L1CTL); |
| 1021 | RSL.clear; |
| 1022 | |
| 1023 | /* activate the logical channel */ |
| 1024 | f_est_dchan(); |
| 1025 | |
| 1026 | /* check that the specified SI5 value is actually sent */ |
| 1027 | f_sacch_present(si5); |
| 1028 | |
| 1029 | /* release the channel */ |
| 1030 | RSL.clear; |
| 1031 | f_rsl_chan_deact(); |
| 1032 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1033 | } |
| 1034 | testcase TC_sacch_filling() runs on test_CT { |
| 1035 | var ConnHdlr vc_conn; |
| 1036 | var ConnHdlrPars pars; |
| 1037 | f_init(); |
| 1038 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1039 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1040 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1041 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1042 | vc_conn.done; |
| 1043 | } |
| 1044 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1045 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1046 | } |
| 1047 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1048 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1049 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1050 | /* Set a known default SACCH filling for SI5 */ |
| 1051 | var octetstring si5 := f_rnd_octstring(19); |
| 1052 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1053 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1054 | |
| 1055 | f_l1_tune(L1CTL); |
| 1056 | RSL.clear; |
| 1057 | |
| 1058 | log("Activating channel, expecting standard SI5"); |
| 1059 | /* activate the logical channel */ |
| 1060 | f_est_dchan(); |
| 1061 | /* check that the specified SI5 value is actually sent */ |
| 1062 | f_sacch_present(si5); |
| 1063 | |
| 1064 | /* set channel-specific different SI5 */ |
| 1065 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1066 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1067 | /* check that the specified lchan-specific value is now used */ |
| 1068 | f_sacch_present(si5_diff); |
| 1069 | |
| 1070 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1071 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1072 | f_rsl_chan_deact(); |
| 1073 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1074 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1075 | f_sacch_present(si5); |
| 1076 | |
| 1077 | /* release the channel */ |
| 1078 | RSL.clear; |
| 1079 | f_rsl_chan_deact(); |
| 1080 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1081 | } |
| 1082 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1083 | var ConnHdlr vc_conn; |
| 1084 | var ConnHdlrPars pars; |
| 1085 | f_init(); |
| 1086 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1087 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1088 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1089 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1090 | vc_conn.done; |
| 1091 | } |
| 1092 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1093 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1094 | } |
| 1095 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1096 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1097 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1098 | var octetstring si5 := f_rnd_octstring(19); |
| 1099 | var octetstring si5bis := f_rnd_octstring(19); |
| 1100 | var octetstring si5ter := f_rnd_octstring(19); |
| 1101 | var octetstring si6 := f_rnd_octstring(19); |
| 1102 | |
| 1103 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1104 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1105 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1106 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1107 | |
| 1108 | f_l1_tune(L1CTL); |
| 1109 | RSL.clear; |
| 1110 | |
| 1111 | /* activate the logical channel */ |
| 1112 | f_est_dchan(); |
| 1113 | L1CTL.clear; |
| 1114 | |
| 1115 | /* check that SACCH actually are received as expected */ |
| 1116 | f_sacch_present(si5); |
| 1117 | f_sacch_present(si5bis); |
| 1118 | f_sacch_present(si5ter); |
| 1119 | f_sacch_present(si6); |
| 1120 | |
| 1121 | /* release the channel */ |
| 1122 | f_rsl_chan_deact(); |
| 1123 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1124 | } |
| 1125 | testcase TC_sacch_multi() 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_multi), 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 | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1139 | /* Test if SACH information is modified as expected */ |
| 1140 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1141 | var octetstring si5 := f_rnd_octstring(19); |
| 1142 | var octetstring si6 := f_rnd_octstring(19); |
| 1143 | |
| 1144 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1145 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1146 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1147 | |
| 1148 | f_l1_tune(L1CTL); |
| 1149 | RSL.clear; |
| 1150 | |
| 1151 | /* activate the logical channel */ |
| 1152 | f_est_dchan(); |
| 1153 | L1CTL.clear; |
| 1154 | |
| 1155 | /* check that SACCH actually are received as expected */ |
| 1156 | f_sacch_present(si5); |
| 1157 | f_sacch_present(si6); |
| 1158 | |
| 1159 | /* disable SI6 */ |
| 1160 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1161 | |
| 1162 | /* check that SI5 is still transmitted */ |
| 1163 | f_sacch_present(si5); |
| 1164 | /* check if SI6 is now gone */ |
| 1165 | f_sacch_missing(si6); |
| 1166 | |
| 1167 | /* release the channel */ |
| 1168 | f_rsl_chan_deact(); |
| 1169 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1170 | } |
| 1171 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1172 | var ConnHdlr vc_conn; |
| 1173 | var ConnHdlrPars pars; |
| 1174 | f_init(); |
| 1175 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1176 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1177 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1178 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1179 | vc_conn.done; |
| 1180 | } |
| 1181 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1182 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1183 | } |
| 1184 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1185 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1186 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1187 | var octetstring si5 := f_rnd_octstring(19); |
| 1188 | var octetstring si6 := f_rnd_octstring(19); |
| 1189 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1190 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1191 | |
| 1192 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1193 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1194 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1195 | |
| 1196 | f_l1_tune(L1CTL); |
| 1197 | RSL.clear; |
| 1198 | |
| 1199 | /* activate channel with different SACCH filling */ |
| 1200 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1201 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1202 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1203 | })); |
| 1204 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1205 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1206 | f_est_dchan(more_ies := addl_ies); |
| 1207 | |
| 1208 | /* check that SACCH actually are received as expected */ |
| 1209 | f_sacch_present(si5_specific); |
| 1210 | f_sacch_present(si6_specific); |
| 1211 | |
| 1212 | /* release the channel */ |
| 1213 | f_rsl_chan_deact(); |
| 1214 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1215 | } |
| 1216 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1217 | var ConnHdlr vc_conn; |
| 1218 | var ConnHdlrPars pars; |
| 1219 | f_init(); |
| 1220 | |
| 1221 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1222 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1223 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1224 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1225 | vc_conn.done; |
| 1226 | } |
| 1227 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1228 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1229 | } |
| 1230 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1231 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1232 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1233 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1234 | var octetstring si5 := f_rnd_octstring(19); |
| 1235 | |
| 1236 | f_l1_tune(L1CTL); |
| 1237 | RSL.clear; |
| 1238 | |
| 1239 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1240 | |
| 1241 | /* Activate channel on BTS side */ |
| 1242 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1243 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1244 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1245 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1246 | |
| 1247 | /* Verify that no DL SACCH is being received */ |
| 1248 | f_sacch_missing(?); |
| 1249 | |
| 1250 | f_rsl_chan_deact(); |
| 1251 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1252 | |
| 1253 | |
| 1254 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1255 | |
| 1256 | /* Activate channel on BTS side */ |
| 1257 | var RSL_IE_List addl_ies := { |
| 1258 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1259 | }; |
| 1260 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1261 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1262 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1263 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1264 | |
| 1265 | /* Verify that DL SACCH is being received */ |
| 1266 | f_sacch_present(si5); |
| 1267 | |
| 1268 | f_rsl_chan_deact(); |
| 1269 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1270 | } |
| 1271 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1272 | var ConnHdlr vc_conn; |
| 1273 | var ConnHdlrPars pars; |
| 1274 | f_init(); |
| 1275 | |
| 1276 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1277 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1278 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1279 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1280 | vc_conn.done; |
| 1281 | } |
| 1282 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1283 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1284 | } |
| 1285 | |
| 1286 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1287 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1288 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1289 | var octetstring si5 := f_rnd_octstring(19); |
| 1290 | var RSL_IE_List addl_ies; |
| 1291 | |
| 1292 | f_l1_tune(L1CTL); |
| 1293 | RSL.clear; |
| 1294 | |
| 1295 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1296 | |
| 1297 | /* Activate channel on BTS side */ |
| 1298 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1299 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1300 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1301 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1302 | |
| 1303 | /* Verify that no DL SACCH is being received */ |
| 1304 | f_sacch_missing(?); |
| 1305 | |
| 1306 | f_rsl_chan_deact(); |
| 1307 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1308 | |
| 1309 | |
| 1310 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1311 | |
| 1312 | /* Activate channel on BTS side */ |
| 1313 | addl_ies := { |
| 1314 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1315 | }; |
| 1316 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1317 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1318 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1319 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1320 | |
| 1321 | /* Verify that no DL SACCH is being received */ |
| 1322 | f_sacch_missing(?); |
| 1323 | |
| 1324 | f_rsl_chan_deact(); |
| 1325 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1326 | |
| 1327 | |
| 1328 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1329 | |
| 1330 | /* Activate channel on BTS side */ |
| 1331 | addl_ies := { |
| 1332 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1333 | }; |
| 1334 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1335 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1336 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1337 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1338 | |
| 1339 | /* Verify that no DL SACCH is being received */ |
| 1340 | f_sacch_missing(?); |
| 1341 | |
| 1342 | f_rsl_chan_deact(); |
| 1343 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1344 | |
| 1345 | |
| 1346 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1347 | |
| 1348 | /* Activate channel on BTS side */ |
| 1349 | addl_ies := { |
| 1350 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1351 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1352 | }; |
| 1353 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1354 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1355 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1356 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1357 | |
| 1358 | /* Verify that DL SACCH is being received */ |
| 1359 | f_sacch_present(si5); |
| 1360 | |
| 1361 | f_rsl_chan_deact(); |
| 1362 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1363 | } |
| 1364 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1365 | var ConnHdlr vc_conn; |
| 1366 | var ConnHdlrPars pars; |
| 1367 | f_init(); |
| 1368 | |
| 1369 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1370 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1371 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1372 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1373 | vc_conn.done; |
| 1374 | } |
| 1375 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1376 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1377 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1378 | |
| 1379 | |
| 1380 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1381 | * RACH Handling |
| 1382 | ***********************************************************************/ |
| 1383 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1384 | /* 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] | 1385 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1386 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1387 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1388 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1389 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1390 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1391 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1392 | for (var integer i := 0; i < 1000; i := i+1) { |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1393 | var OCT1 ra := f_rnd_ra_emerg(); |
| 1394 | if (emerg == true) { |
| 1395 | ra := f_rnd_ra_emerg(); |
| 1396 | } else { |
| 1397 | ra := f_rnd_ra_cs(); |
| 1398 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1399 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1400 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1401 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1402 | } |
| 1403 | fn_last := fn; |
| 1404 | |
| 1405 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1406 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1407 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1408 | [] 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] | 1409 | T.stop; |
| 1410 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1411 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1413 | } |
| 1414 | [] RSL_CCHAN.receive { repeat; } |
| 1415 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1416 | test_failed := true; |
| 1417 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1418 | } |
| 1419 | } |
| 1420 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1421 | if (test_failed) { |
| 1422 | 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] | 1423 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1424 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1425 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1426 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1427 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1428 | /* Normal variant */ |
| 1429 | testcase TC_rach_content() runs on test_CT { |
| 1430 | f_TC_rach_content(emerg := false); |
| 1431 | } |
| 1432 | |
| 1433 | /* Emergency call variant */ |
| 1434 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1435 | f_TC_rach_content(emerg := true); |
| 1436 | } |
| 1437 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1438 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1439 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1440 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1441 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1442 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1443 | f_l1_tune(L1CTL); |
| 1444 | |
| 1445 | var GsmFrameNumber fn_last := 0; |
| 1446 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1447 | var OCT1 ra := f_rnd_ra_cs(); |
| 1448 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1449 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1450 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1451 | } |
| 1452 | fn_last := fn; |
| 1453 | } |
| 1454 | var integer rsl_chrqd := 0; |
| 1455 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1456 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1457 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1458 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1459 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1460 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1461 | repeat; |
| 1462 | } |
| 1463 | [] RSL_CCHAN.receive { repeat; } |
| 1464 | [] T.timeout { } |
| 1465 | } |
| 1466 | if (rsl_chrqd == 1000) { |
| 1467 | setverdict(pass); |
| 1468 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1469 | 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] | 1470 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1471 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1472 | } |
| 1473 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1474 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1475 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1476 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1477 | } |
| 1478 | |
| 1479 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1480 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1481 | |
| 1482 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1483 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1484 | var ASP_RSL_Unitdata rx_ud; |
| 1485 | |
| 1486 | f_init_vty_bsc(); |
| 1487 | /* send load indications even at 0% load */ |
| 1488 | f_vty_load_ind_thresh(0); |
| 1489 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1490 | f_sleep(2.0); |
| 1491 | |
| 1492 | f_init(); |
| 1493 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1494 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1495 | alt { |
| 1496 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1497 | [] RSL_CCHAN.receive { repeat } |
| 1498 | } |
| 1499 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1500 | timer T := 5.0; |
| 1501 | T.start; |
| 1502 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1503 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1504 | setverdict(pass); |
| 1505 | repeat; |
| 1506 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1507 | [] 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] | 1508 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1509 | repeat; |
| 1510 | } |
| 1511 | [] RSL_CCHAN.receive { |
| 1512 | repeat; |
| 1513 | } |
| 1514 | [] T.timeout { } |
| 1515 | } |
| 1516 | |
| 1517 | f_vty_load_ind_thresh(10); |
| 1518 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1519 | } |
| 1520 | |
| 1521 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1522 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1523 | var ASP_RSL_Unitdata rx_ud; |
| 1524 | |
| 1525 | f_init_vty_bsc(); |
| 1526 | f_init(); |
| 1527 | |
| 1528 | timer T := 5.0; |
| 1529 | T.start; |
| 1530 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1531 | [] 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] | 1532 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1533 | repeat; |
| 1534 | } |
| 1535 | [] RSL_CCHAN.receive { |
| 1536 | repeat; |
| 1537 | } |
| 1538 | [] T.timeout { |
| 1539 | setverdict(pass); |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1544 | } |
| 1545 | |
| 1546 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1547 | testcase TC_rach_load_count() runs on test_CT { |
| 1548 | var ASP_RSL_Unitdata rx_ud; |
| 1549 | var integer load_access_count := 0; |
| 1550 | |
| 1551 | f_init_vty_bsc(); |
| 1552 | /* send load indications even at 0% load */ |
| 1553 | f_vty_load_ind_thresh(0); |
| 1554 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1555 | f_sleep(2.0); |
| 1556 | f_init(); |
| 1557 | |
| 1558 | f_init_l1ctl(); |
| 1559 | f_sleep(1.0); |
| 1560 | f_l1_tune(L1CTL); |
| 1561 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1562 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1563 | alt { |
| 1564 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1565 | [] RSL_CCHAN.receive { repeat } |
| 1566 | } |
| 1567 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1568 | var GsmFrameNumber fn_last := 0; |
| 1569 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1570 | var OCT1 ra := f_rnd_ra_cs(); |
| 1571 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1572 | if (fn == fn_last) { |
| 1573 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1574 | } |
| 1575 | fn_last := fn; |
| 1576 | } |
| 1577 | |
| 1578 | timer T := 5.0; |
| 1579 | T.start; |
| 1580 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1581 | [] 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] | 1582 | -> value rx_ud { |
| 1583 | var RSL_IE_Body ie; |
| 1584 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1585 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1586 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1587 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1588 | } |
| 1589 | repeat; |
| 1590 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1591 | [] 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] | 1592 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1593 | repeat; |
| 1594 | } |
| 1595 | [] RSL_CCHAN.receive { |
| 1596 | repeat; |
| 1597 | } |
| 1598 | [] T.timeout { } |
| 1599 | } |
| 1600 | if (load_access_count == 1000) { |
| 1601 | setverdict(pass); |
| 1602 | } else { |
| 1603 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1604 | } |
| 1605 | |
| 1606 | f_vty_load_ind_thresh(10); |
| 1607 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1608 | } |
| 1609 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1610 | 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] | 1611 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1612 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1613 | 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] | 1614 | f_sleep(0.5); |
| 1615 | |
| 1616 | /* Transmit RACH request + wait for confirmation */ |
| 1617 | var OCT1 ra := f_rnd_ra_cs(); |
| 1618 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1619 | |
| 1620 | /* Check for expected result */ |
| 1621 | timer T := 1.5; |
| 1622 | T.start; |
| 1623 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1624 | [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] | 1625 | setverdict(pass); |
| 1626 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1627 | [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] | 1628 | 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] | 1629 | } |
| 1630 | [] RSL_CCHAN.receive { repeat; } |
| 1631 | [not expect_pass] T.timeout { |
| 1632 | setverdict(pass); |
| 1633 | } |
| 1634 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1635 | 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] | 1636 | } |
| 1637 | } |
| 1638 | } |
| 1639 | |
| 1640 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1641 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1642 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1643 | f_init_l1ctl(); |
| 1644 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1645 | f_sleep(1.0); |
| 1646 | |
| 1647 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1648 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1649 | /* We allow early arrival up to 2 symbols */ |
| 1650 | f_rach_toffs(-1*256, true); |
| 1651 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1652 | f_rach_toffs(-10*256, false); |
| 1653 | |
| 1654 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1655 | f_rach_toffs(0, true); |
| 1656 | f_rach_toffs(32*256, true); |
| 1657 | f_rach_toffs(63*256, true); |
| 1658 | |
| 1659 | /* more than 63 bits is not legal / permitted */ |
| 1660 | f_rach_toffs(64*256, false); |
| 1661 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1662 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1663 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1664 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1665 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1666 | var GsmFrameNumber fn; |
| 1667 | var RSL_Message rm; |
| 1668 | |
| 1669 | f_l1_tune(L1CTL); |
| 1670 | RSL.clear; |
| 1671 | |
| 1672 | /* Generate a random Handover Reference */ |
| 1673 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1674 | |
| 1675 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1676 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1677 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1678 | |
| 1679 | /* Activate a channel on the BTS side (no encryption) */ |
| 1680 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1681 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1682 | |
| 1683 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1684 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1685 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1686 | |
| 1687 | /* Send handover Access Burst */ |
| 1688 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1689 | |
| 1690 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1691 | |
| 1692 | /* Wait for handover detection */ |
| 1693 | timer T := 3.0; |
| 1694 | T.start; |
| 1695 | alt { |
| 1696 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1697 | log("Handover RACH has been detected: ", rm); |
| 1698 | setverdict(pass); |
| 1699 | } |
| 1700 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1701 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1702 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1703 | } |
| 1704 | [] RSL.receive { repeat; } |
| 1705 | [] T.timeout { |
| 1706 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1707 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1708 | } |
| 1709 | } |
| 1710 | |
| 1711 | /* Release the channel */ |
| 1712 | f_rsl_chan_deact(); |
| 1713 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1714 | } |
| 1715 | |
| 1716 | /* Test handover RACH detection */ |
| 1717 | testcase TC_ho_rach() runs on test_CT { |
| 1718 | var ConnHdlrPars pars; |
| 1719 | var ConnHdlr vc_conn; |
| 1720 | |
| 1721 | f_init(); |
| 1722 | |
| 1723 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1724 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1725 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1726 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1727 | vc_conn.done; |
| 1728 | } |
| 1729 | |
| 1730 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1731 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1732 | } |
| 1733 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1734 | /*********************************************************************** |
| 1735 | * Measurement Processing / Reporting |
| 1736 | ***********************************************************************/ |
| 1737 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1738 | private template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1739 | spare := '0'B, |
| 1740 | lpd := 0, |
| 1741 | sapi := sapi, |
| 1742 | c_r := c_r, |
| 1743 | ea := true |
| 1744 | } |
| 1745 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1746 | 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] | 1747 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1748 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1749 | len := 0, /* overwritten */ |
| 1750 | m := false, |
| 1751 | el := 1, |
| 1752 | payload := pl |
| 1753 | } |
| 1754 | |
| 1755 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1756 | private altstep as_l1_sacch() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1757 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1758 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1759 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1760 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp, 0, 0, omit)); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1761 | 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] | 1762 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1763 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1764 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1765 | g_pars.l1_pars.ms_power_level, false, |
| 1766 | g_pars.l1_pars.ms_actual_ta); |
| 1767 | |
| 1768 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1769 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1770 | |
| 1771 | log("Sending Measurement Report: ", l1h, l2); |
| 1772 | 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] | 1773 | repeat; |
| 1774 | } |
| 1775 | } |
| 1776 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 1777 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1778 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1779 | [] 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] | 1780 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1781 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1782 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1783 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1784 | repeat; |
| 1785 | } |
| 1786 | } |
| 1787 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1788 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 1789 | var L1ctlDlMessage l1_dl; |
| 1790 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 1791 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1792 | |
| 1793 | /* occasionaly inject FACCH frames into the uplink */ |
| 1794 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 1795 | var octetstring pl := '010301'O; |
| 1796 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1797 | f_pad_oct(pl, 23, '2B'O))); |
| 1798 | } else { |
| 1799 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 1800 | l1_dl.payload.traffic_ind.data)); |
| 1801 | } |
| 1802 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 1803 | repeat; |
| 1804 | } |
| 1805 | } |
| 1806 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1807 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1808 | uint6_t rxlev, |
| 1809 | uint3_t rxqual |
| 1810 | } |
| 1811 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1812 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1813 | MeasElem full, |
| 1814 | MeasElem sub |
| 1815 | } |
| 1816 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1817 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1818 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1819 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1820 | MeasElemFS meas_ul, |
| 1821 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 1822 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1823 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 1824 | uint8_t ms_actual_ta, |
| 1825 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1826 | } |
| 1827 | |
| 1828 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1829 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1830 | return 63 + (toffs256s/256); |
| 1831 | } |
| 1832 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1833 | private function f_max(integer a, integer b) return integer { |
| 1834 | if (a > b) { |
| 1835 | return a; |
| 1836 | } else { |
| 1837 | return b; |
| 1838 | } |
| 1839 | } |
| 1840 | |
| 1841 | private function f_min(integer a, integer b) return integer { |
| 1842 | if (a < b) { |
| 1843 | return a; |
| 1844 | } else { |
| 1845 | return b; |
| 1846 | } |
| 1847 | } |
| 1848 | |
| 1849 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1850 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1851 | val := val - tolerance; |
| 1852 | return f_max(val, min); |
| 1853 | } |
| 1854 | |
| 1855 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1856 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1857 | val := val + tolerance; |
| 1858 | return f_min(val, max); |
| 1859 | } |
| 1860 | |
| 1861 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1862 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1863 | return template integer { |
| 1864 | var template integer ret; |
| 1865 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1866 | return ret; |
| 1867 | } |
| 1868 | |
| 1869 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1870 | /* build a template for matching measurement results against */ |
| 1871 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1872 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1873 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1874 | len := 3, |
| 1875 | rfu := '0'B, |
| 1876 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1877 | 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] | 1878 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1879 | 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] | 1880 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1881 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1882 | 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] | 1883 | supp_meas_info := omit |
| 1884 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1885 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1886 | ul_meas.len := (3+8); |
| 1887 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1888 | 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] | 1889 | toa256_min := ?, |
| 1890 | toa256_max := ?, |
| 1891 | toa256_std_dev := ? |
| 1892 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1893 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1894 | var template RSL_IE_BS_Power bs_power := { |
| 1895 | reserved := 0, |
| 1896 | epc := false, |
| 1897 | fpc := false, |
| 1898 | power_level := l1p.bs_power_level |
| 1899 | }; |
| 1900 | var template RSL_IE_L1Info l1_info := { |
| 1901 | ms_power_lvl := l1p.ms_power_level, |
| 1902 | fpc := false, |
| 1903 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1904 | 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] | 1905 | }; |
| 1906 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1907 | 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] | 1908 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1909 | ?, t_toffs); |
| 1910 | } |
| 1911 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1912 | /* build a template for matching measurement results that do not contain any |
| 1913 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 1914 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 1915 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1916 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1917 | len := 3, |
| 1918 | rfu := '0'B, |
| 1919 | dtx_d := l1p.dtx_enabled, |
| 1920 | rxlev_f_u := ?, |
| 1921 | reserved1 := '00'B, |
| 1922 | rxlev_s_u := ?, |
| 1923 | reserved2 := '00'B, |
| 1924 | rxq_f_u := ?, |
| 1925 | rxq_s_u := ?, |
| 1926 | supp_meas_info := omit |
| 1927 | }; |
| 1928 | if (l1p.toa256_enabled) { |
| 1929 | ul_meas.len := (3+8); |
| 1930 | ul_meas.supp_meas_info := { |
| 1931 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 1932 | toa256_min := ?, |
| 1933 | toa256_max := ?, |
| 1934 | toa256_std_dev := ? |
| 1935 | } |
| 1936 | } |
| 1937 | var template RSL_IE_BS_Power bs_power := { |
| 1938 | reserved := 0, |
| 1939 | epc := false, |
| 1940 | fpc := false, |
| 1941 | power_level := l1p.bs_power_level |
| 1942 | }; |
| 1943 | |
| 1944 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 1945 | } |
| 1946 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1947 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 1948 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1949 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1950 | var boolean chan_est := false; |
| 1951 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1952 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1953 | |
| 1954 | /* Receive osmocom specific measurement reports. This is the normal |
| 1955 | * case. Here we verify that the measurement reports we sent are |
| 1956 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1957 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1958 | /* increment counter of next to-be-expected meas rep */ |
| 1959 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1960 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1961 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1962 | |
| 1963 | /* The following two cases may only happen in the beginning |
| 1964 | * of the channel establishment phase. Once we have received |
| 1965 | * the "our" measurement report the first time, the channel |
| 1966 | * is established and empty or hardcoded TRXCON reports must |
| 1967 | * not occur anymore. */ |
| 1968 | chan_est := true; |
| 1969 | |
| 1970 | repeat; |
| 1971 | } |
| 1972 | |
| 1973 | /* When the BTS has established the channel, the MS might need slightly |
| 1974 | * more time to establish the channel and actually start sending. The |
| 1975 | * result is then a measurement report that just lacks the measurement |
| 1976 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 1977 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 1978 | /* increment counter of next to-be-expected meas rep */ |
| 1979 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1980 | /* Re-start the timer expecting the next MEAS RES */ |
| 1981 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1982 | repeat; |
| 1983 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1984 | |
| 1985 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 1986 | * measurements if the TTCN3 side does not supply measurement input in |
| 1987 | * time. In those cases TRXCON will either use a cached measurement |
| 1988 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 1989 | * report the templates above will not match. We tolerate this |
| 1990 | * behavior, but only once. */ |
| 1991 | [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] | 1992 | /* increment counter of next to-be-expected meas rep */ |
| 1993 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1994 | if (g_first_meas_res) { |
| 1995 | g_first_meas_res := false; |
| 1996 | repeat; |
| 1997 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1998 | 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] | 1999 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2000 | } |
| 2001 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2002 | 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] | 2003 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2004 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2005 | 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] | 2006 | } |
| 2007 | } |
| 2008 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2009 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2010 | select (rsl_alg_id) { |
| 2011 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2012 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2013 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2014 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2015 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2016 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2017 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2018 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2019 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2020 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2021 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2022 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2023 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2024 | } |
| 2025 | } |
| 2026 | } |
| 2027 | |
| 2028 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2029 | select (rsl_alg_id) { |
| 2030 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2031 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2032 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2033 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2034 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2035 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2036 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2037 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2038 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2039 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2040 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2041 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2042 | } |
| 2043 | } |
| 2044 | } |
| 2045 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2046 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2047 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2048 | var GsmFrameNumber fn; |
| 2049 | timer T := 8.0; |
| 2050 | |
| 2051 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2052 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2053 | |
| 2054 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2055 | /* Send the actual RACH */ |
| 2056 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2057 | |
| 2058 | T.start; |
| 2059 | alt { |
| 2060 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2061 | [] T.timeout { |
| 2062 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2063 | } |
| 2064 | } |
| 2065 | T.stop |
| 2066 | return fn; |
| 2067 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2068 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2069 | /* Tune to a dedicated channel: L1CTL only */ |
| 2070 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2071 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2072 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, |
| 2073 | 7 /* TODO: mp_tsc */, |
| 2074 | mp_trx0_arfcn)); |
| 2075 | } else { |
| 2076 | pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, |
| 2077 | 7 /* TODO: mp_tsc */, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2078 | pars.fhp.maio_hsn.hsn, |
| 2079 | pars.fhp.maio_hsn.maio, |
| 2080 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2081 | } |
| 2082 | } |
| 2083 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2084 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2085 | 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] | 2086 | var GsmFrameNumber fn; |
| 2087 | var ImmediateAssignment imm_ass; |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2088 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2089 | var integer ra := 23; |
| 2090 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2091 | /* Send RACH request and wait for ChanReq */ |
| 2092 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2093 | |
| 2094 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2095 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2096 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2097 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2098 | if (g_pars.fhp.enabled) { |
| 2099 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2100 | } else { |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 2101 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx0_arfcn)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2102 | } |
| 2103 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2104 | /* Send IMM.ASS via CCHAN */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2105 | 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] | 2106 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 2107 | |
| 2108 | /* receive IMM.ASS on MS side */ |
| 2109 | var ImmediateAssignment ia_um; |
| 2110 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2111 | |
| 2112 | /* Make sure that IMM.ASS contains hopping parameters (if enabled) */ |
| 2113 | if (ch_desc.h != ia_um.chan_desc.h) { |
| 2114 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch"); |
| 2115 | } |
| 2116 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2117 | /* enable dedicated mode */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2118 | 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] | 2119 | /* enable encryption, if requested */ |
| 2120 | if (encr_enable) { |
| 2121 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2122 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2123 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2124 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2125 | /* Send TCH Mode Request to the L1 if needed */ |
| 2126 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2127 | var L1ctlTchMode tch_mode; |
| 2128 | |
| 2129 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2130 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2131 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2132 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2133 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2134 | case else { |
| 2135 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2136 | " is not supported by the L1, falling back to signalling"); |
| 2137 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2142 | } |
| 2143 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2144 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2145 | } |
| 2146 | |
| 2147 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2148 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2149 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2150 | RSL.clear; |
| 2151 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2152 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2153 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2154 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2155 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2156 | |
| 2157 | f_est_dchan(); |
| 2158 | |
| 2159 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2160 | * RSL measurement reports on Abis side */ |
| 2161 | timer T := 8.0; |
| 2162 | T.start; |
| 2163 | alt { |
| 2164 | [] as_l1_sacch(); |
| 2165 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2166 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2167 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2168 | [] L1CTL.receive { repeat; } |
| 2169 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2170 | /* 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] | 2171 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2172 | setverdict(pass); |
| 2173 | } |
| 2174 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2175 | 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] | 2176 | } |
| 2177 | } |
| 2178 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2179 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2180 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2181 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2182 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2183 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2184 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2185 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2186 | timer Tup := 10.0; |
| 2187 | Tup.start; |
| 2188 | alt { |
| 2189 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2190 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2191 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2192 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2193 | if (rx_lvl != max_rx_lvl) { |
| 2194 | repeat; |
| 2195 | } |
| 2196 | Tup.stop; |
| 2197 | } |
| 2198 | [] L1CTL.receive { repeat; } |
| 2199 | [] Tup.timeout { |
| 2200 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2201 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2202 | } |
| 2203 | } |
| 2204 | return max_rx_lvl; |
| 2205 | } |
| 2206 | |
| 2207 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2208 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2209 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2210 | var integer initial_rx_lvl := -1; |
| 2211 | var integer last_rx_lvl := -1; |
| 2212 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2213 | |
| 2214 | timer T := 2.0; |
| 2215 | alt { |
| 2216 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2217 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2218 | log("Received rx_level=", rx_lvl); |
| 2219 | if (initial_rx_lvl == -1) { |
| 2220 | initial_rx_lvl := rx_lvl; |
| 2221 | last_rx_lvl := rx_lvl; |
| 2222 | |
| 2223 | /* Expect a somehow low value during first received messages */ |
| 2224 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2226 | log2str("Detected high initial tx power during ramp up: ", |
| 2227 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2232 | if (rx_lvl > max_rx_lvl) { |
| 2233 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2234 | log2str("Detected Tx power higher than full power: ", |
| 2235 | rx_lvl , " > ", max_rx_lvl)); |
| 2236 | } |
| 2237 | |
| 2238 | /* Make sure it never decreases, since we are rumping up */ |
| 2239 | if (last_rx_lvl > rx_lvl) { |
| 2240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2241 | log2str("Detected Tx power decrease during ramp up: ", |
| 2242 | last_rx_lvl , " -> ", rx_lvl)); |
| 2243 | } |
| 2244 | |
| 2245 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2246 | /* We reached the maximum power, start timer and receive |
| 2247 | /* a few more to make sure we don't surpass it */ |
| 2248 | log("Reached full power, wating a bit more until success"); |
| 2249 | T.start; |
| 2250 | } |
| 2251 | |
| 2252 | last_rx_lvl := rx_lvl; |
| 2253 | repeat; |
| 2254 | } |
| 2255 | [] L1CTL.receive { repeat; } |
| 2256 | [] T.timeout { } |
| 2257 | } |
| 2258 | |
| 2259 | /* We didn't increase tx power during ramp up */ |
| 2260 | if (initial_rx_lvl < last_rx_lvl) { |
| 2261 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2262 | } else { |
| 2263 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2264 | log2str("No Tx power increase during whole ramp up: ", |
| 2265 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2266 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | /* verify BTS ramps power down to rx_level 0 */ |
| 2270 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2271 | var L1ctlDlMessage l1_dl; |
| 2272 | var integer last_rx_lvl := max_rx_lvl; |
| 2273 | |
| 2274 | timer Tdown := 5.0; |
| 2275 | Tdown.start; |
| 2276 | alt { |
| 2277 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2278 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2279 | log("Received rx_level=", rx_lvl); |
| 2280 | |
| 2281 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2282 | if (rx_lvl > max_rx_lvl) { |
| 2283 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2284 | log2str("Detected Tx power higher than full power: ", |
| 2285 | rx_lvl , " > ", max_rx_lvl)); |
| 2286 | } |
| 2287 | |
| 2288 | /* Make sure it never increases, since we are rumping down */ |
| 2289 | if (last_rx_lvl < rx_lvl) { |
| 2290 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2291 | log2str("Detected Tx power increase during ramp up: ", |
| 2292 | last_rx_lvl , " -> ", rx_lvl)); |
| 2293 | } |
| 2294 | |
| 2295 | last_rx_lvl := rx_lvl; |
| 2296 | if (last_rx_lvl != 0) { |
| 2297 | repeat; |
| 2298 | } |
| 2299 | /* we reached power level 0, we are done */ |
| 2300 | Tdown.stop; |
| 2301 | } |
| 2302 | [] L1CTL.receive { repeat; } |
| 2303 | [] Tdown.timeout { } |
| 2304 | } |
| 2305 | |
| 2306 | /* We didn't increase tx power during ramp down */ |
| 2307 | if (max_rx_lvl > last_rx_lvl) { |
| 2308 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2309 | } else { |
| 2310 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2311 | log2str("No Tx power decrease during whole ramp down: ", |
| 2312 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2313 | } |
| 2314 | } |
| 2315 | |
| 2316 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2317 | 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] | 2318 | f_l1_tune(L1CTL); |
| 2319 | RSL.clear; |
| 2320 | |
| 2321 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2322 | |
| 2323 | setverdict(pass); |
| 2324 | } |
| 2325 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2326 | var ConnHdlr vc_conn; |
| 2327 | var ConnHdlrPars pars; |
| 2328 | f_init(); |
| 2329 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2330 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2331 | pcu_comp := false, trxc_comp := true); |
| 2332 | vc_conn.done; |
| 2333 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2334 | } |
| 2335 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2336 | /* 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] | 2337 | 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] | 2338 | f_connhdlr_init_vty_bsc(); |
| 2339 | |
| 2340 | f_l1_tune(L1CTL); |
| 2341 | RSL.clear; |
| 2342 | |
| 2343 | /* Wait until BTS is started and at full power */ |
| 2344 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2345 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2346 | |
| 2347 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2348 | f_verify_ramp_down(max_rx_lvl); |
| 2349 | |
| 2350 | setverdict(pass); |
| 2351 | } |
| 2352 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2353 | var ConnHdlr vc_conn; |
| 2354 | var ConnHdlrPars pars; |
| 2355 | f_init(); |
| 2356 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2357 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2358 | pcu_comp := false, trxc_comp := true); |
| 2359 | vc_conn.done; |
| 2360 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2361 | } |
| 2362 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2363 | /* Verify Tx power: |
| 2364 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2365 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2366 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2367 | 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] | 2368 | var L1ctlDlMessage l1_dl; |
| 2369 | var integer last_rx_lvl; |
| 2370 | |
| 2371 | f_connhdlr_init_vty_bsc(); |
| 2372 | |
| 2373 | f_l1_tune(L1CTL); |
| 2374 | RSL.clear; |
| 2375 | |
| 2376 | /* Wait until BTS is started and at full power */ |
| 2377 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2378 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2379 | |
| 2380 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2381 | f_vty_enter_cfg_trx(BSCVTY); |
| 2382 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2383 | last_rx_lvl := max_rx_lvl; |
| 2384 | f_verify_ramp_down(max_rx_lvl); |
| 2385 | |
| 2386 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2387 | * anymore because scheduler has stopped after ramping down */ |
| 2388 | f_sleep(2.0); |
| 2389 | L1CTL.clear; |
| 2390 | timer Tlocked := 2.0; |
| 2391 | Tlocked.start; |
| 2392 | alt { |
| 2393 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2394 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2395 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2396 | } |
| 2397 | [] L1CTL.receive { repeat; } |
| 2398 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2399 | } |
| 2400 | |
| 2401 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2402 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2403 | f_verify_ramp_up(); |
| 2404 | setverdict(pass); |
| 2405 | } |
| 2406 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2407 | var ConnHdlr vc_conn; |
| 2408 | var ConnHdlrPars pars; |
| 2409 | f_init(); |
| 2410 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2411 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2412 | pcu_comp := false, trxc_comp := true); |
| 2413 | vc_conn.done; |
| 2414 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2415 | } |
| 2416 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2417 | 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] | 2418 | timer T := 8.0; |
| 2419 | T.start; |
| 2420 | var RSL_Message rsl; |
| 2421 | alt { |
| 2422 | [] as_l1_sacch(); |
| 2423 | [] L1CTL.receive { repeat; } |
| 2424 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2425 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2426 | setverdict(pass) |
| 2427 | } else { |
| 2428 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2429 | } |
| 2430 | } |
| 2431 | [] T.timeout { |
| 2432 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2433 | } |
| 2434 | } |
| 2435 | } |
| 2436 | |
| 2437 | /* see if the rsl meas res contains our expeced bs power level |
| 2438 | bs power set during assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2439 | 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] | 2440 | f_l1_tune(L1CTL); |
| 2441 | RSL.clear; |
| 2442 | |
| 2443 | if (mp_bts_trxc_port != -1) { |
| 2444 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2445 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2446 | } |
| 2447 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2448 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2449 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2450 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2451 | |
| 2452 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2453 | |
| 2454 | f_check_meas_bs_power_level(pwr_var); |
| 2455 | |
| 2456 | f_rsl_chan_deact(); |
| 2457 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2458 | } |
| 2459 | |
| 2460 | /* see if the rsl meas res contains our expeced bs power level |
| 2461 | bs power set after assignment */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2462 | 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] | 2463 | f_l1_tune(L1CTL); |
| 2464 | RSL.clear; |
| 2465 | |
| 2466 | if (mp_bts_trxc_port != -1) { |
| 2467 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2468 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2469 | } |
| 2470 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2471 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2472 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2473 | |
| 2474 | f_est_dchan(); |
| 2475 | |
| 2476 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2477 | |
| 2478 | f_check_meas_bs_power_level(pwr_var); |
| 2479 | |
| 2480 | f_rsl_chan_deact(); |
| 2481 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2482 | } |
| 2483 | |
| 2484 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2485 | var ConnHdlr vc_conn; |
| 2486 | var ConnHdlrPars pars; |
| 2487 | f_init(); |
| 2488 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2489 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2490 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2491 | pcu_comp := false, trxc_comp := true); |
| 2492 | vc_conn.done; |
| 2493 | } |
| 2494 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2495 | } |
| 2496 | |
| 2497 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2498 | var ConnHdlr vc_conn; |
| 2499 | var ConnHdlrPars pars; |
| 2500 | f_init(); |
| 2501 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2502 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2503 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2504 | pcu_comp := false, trxc_comp := true); |
| 2505 | vc_conn.done; |
| 2506 | } |
| 2507 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2508 | } |
| 2509 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2510 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2511 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2512 | 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] | 2513 | 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] | 2514 | var uint5_t pwr_var := 7; |
| 2515 | var L1ctlDlMessage l1_dl; |
| 2516 | |
| 2517 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2518 | f_l1_tune(L1CTL); |
| 2519 | RSL.clear; |
| 2520 | |
| 2521 | var RSL_IE_List addl_ies; |
| 2522 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2523 | |
| 2524 | addl_ies := { |
| 2525 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2526 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2527 | }; |
| 2528 | |
| 2529 | /* establish with power parameters */ |
| 2530 | f_est_dchan(more_ies := addl_ies); |
| 2531 | |
| 2532 | /* set a high value to ensure L1 power control level increases */ |
| 2533 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2534 | |
| 2535 | timer T2 := 6.0; |
| 2536 | T2.start; |
| 2537 | alt { |
| 2538 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2539 | /* Update sent MS power to follow what BTS requests */ |
| 2540 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2541 | if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2542 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2543 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2544 | T2.stop; |
| 2545 | } |
| 2546 | [] L1CTL.receive { repeat; } |
| 2547 | [] T2.timeout { |
| 2548 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2549 | "Power Level in L1 header has not increased sufficiently"); |
| 2550 | } |
| 2551 | } |
| 2552 | |
| 2553 | /* set a low value to ensure L1 power control level decreases */ |
| 2554 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2555 | |
| 2556 | timer T4 := 6.0; |
| 2557 | T4.start; |
| 2558 | alt { |
| 2559 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2560 | /* Update sent MS power to follow what BTS requests */ |
| 2561 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2562 | if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2563 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2564 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2565 | T4.stop; |
| 2566 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2567 | } |
| 2568 | [] L1CTL.receive { repeat; } |
| 2569 | [] T4.timeout { |
| 2570 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2571 | "Power Level in L1 header has not decreased sufficiently"); |
| 2572 | } |
| 2573 | } |
| 2574 | |
| 2575 | f_rsl_chan_deact(); |
| 2576 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2577 | |
| 2578 | } |
| 2579 | |
| 2580 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2581 | 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] | 2582 | var uint5_t pwr_var := 7; |
| 2583 | var L1ctlDlMessage l1_dl; |
| 2584 | |
| 2585 | /* set a low value to ensure power increases */ |
| 2586 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2587 | f_l1_tune(L1CTL); |
| 2588 | RSL.clear; |
| 2589 | |
| 2590 | var RSL_IE_List addl_ies; |
| 2591 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2592 | |
| 2593 | addl_ies := { |
| 2594 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2595 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2596 | }; |
| 2597 | |
| 2598 | /* establish with power parameters */ |
| 2599 | f_est_dchan(more_ies := addl_ies); |
| 2600 | |
| 2601 | timer T1 := 10.0; |
| 2602 | T1.start; |
| 2603 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2604 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2605 | /* Update sent MS power to follow what BTS requests */ |
| 2606 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2607 | repeat; |
| 2608 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2609 | [] L1CTL.receive { repeat; } |
| 2610 | [] T1.timeout { |
| 2611 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2612 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2613 | } |
| 2614 | } |
| 2615 | } |
| 2616 | |
| 2617 | f_rsl_chan_deact(); |
| 2618 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2619 | |
| 2620 | } |
| 2621 | |
| 2622 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2623 | private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2624 | var L1ctlDlMessage l1_dl; |
| 2625 | var uint5_t pwr_var := 15; |
| 2626 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2627 | |
| 2628 | /* set a low value to ensure power increases */ |
| 2629 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2630 | f_l1_tune(L1CTL); |
| 2631 | RSL.clear; |
| 2632 | |
| 2633 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2634 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2635 | |
| 2636 | /* establish with fixed power level */ |
| 2637 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2638 | |
| 2639 | /* check our initial power level */ |
| 2640 | f_wait_for_l1_power_level(pwr_var); |
| 2641 | |
| 2642 | /* update power param to enable power loop |
| 2643 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2644 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2645 | |
| 2646 | /* wait, then check that our power level was reduced */ |
| 2647 | timer T1 := 10.0; |
| 2648 | T1.start; |
| 2649 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2650 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2651 | /* Update sent MS power to follow what BTS requests */ |
| 2652 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2653 | repeat; |
| 2654 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2655 | [] L1CTL.receive { repeat; } |
| 2656 | [] T1.timeout { |
| 2657 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2658 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2659 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2660 | } else { |
| 2661 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2662 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2663 | } |
| 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | f_rsl_chan_deact(); |
| 2668 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2669 | |
| 2670 | } |
| 2671 | |
| 2672 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2673 | private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2674 | var L1ctlDlMessage l1_dl; |
| 2675 | |
| 2676 | /* set a high value to ensure power decreases */ |
| 2677 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2678 | f_l1_tune(L1CTL); |
| 2679 | RSL.clear; |
| 2680 | |
| 2681 | var uint5_t pwr_var := 5; |
| 2682 | var uint5_t pwr_target_val := 15; |
| 2683 | |
| 2684 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2685 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2686 | |
| 2687 | /* establish with fixed power level */ |
| 2688 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2689 | |
| 2690 | /* check our initial power level */ |
| 2691 | f_wait_for_l1_power_level(pwr_var); |
| 2692 | |
| 2693 | /* update power param to enable power loop |
| 2694 | 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] | 2695 | 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] | 2696 | |
| 2697 | /* wait, then check that our power level was increased */ |
| 2698 | timer T1 := 10.0; |
| 2699 | T1.start; |
| 2700 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2701 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2702 | /* Update sent MS power to follow what BTS requests */ |
| 2703 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2704 | repeat; |
| 2705 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2706 | [] L1CTL.receive { repeat; } |
| 2707 | [] T1.timeout { |
| 2708 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2709 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2710 | } else { |
| 2711 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2712 | "Power level in L1 header NOT increased to lowest power value"); |
| 2713 | } |
| 2714 | } |
| 2715 | } |
| 2716 | |
| 2717 | f_rsl_chan_deact(); |
| 2718 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2719 | |
| 2720 | } |
| 2721 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2722 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2723 | rsl chan act WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2724 | private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2725 | var L1ctlDlMessage l1_dl; |
| 2726 | |
| 2727 | /* set a high value to ensure power decreases */ |
| 2728 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2729 | f_l1_tune(L1CTL); |
| 2730 | RSL.clear; |
| 2731 | |
| 2732 | var uint5_t pwr_var := 5; |
| 2733 | |
| 2734 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2735 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2736 | |
| 2737 | /* establish with fixed power level */ |
| 2738 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2739 | |
| 2740 | /* check our initial power level */ |
| 2741 | f_wait_for_l1_power_level(pwr_var); |
| 2742 | |
| 2743 | /* wait, then check that our power level did not change */ |
| 2744 | timer T1 := 10.0; |
| 2745 | T1.start; |
| 2746 | alt { |
| 2747 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2748 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2749 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2750 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2751 | } |
| 2752 | repeat; |
| 2753 | } |
| 2754 | [] L1CTL.receive { repeat; } |
| 2755 | [] T1.timeout { setverdict(pass); } |
| 2756 | } |
| 2757 | |
| 2758 | f_rsl_chan_deact(); |
| 2759 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2760 | |
| 2761 | } |
| 2762 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2763 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2764 | ms power control WITHOUT power parameters */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2765 | private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2766 | var L1ctlDlMessage l1_dl; |
| 2767 | |
| 2768 | /* set a high value to ensure power decreases */ |
| 2769 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2770 | f_l1_tune(L1CTL); |
| 2771 | RSL.clear; |
| 2772 | |
| 2773 | var uint5_t pwr_var := 5; |
| 2774 | |
| 2775 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2776 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2777 | |
| 2778 | /* establish with fixed power level */ |
| 2779 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2780 | |
| 2781 | /* check our initial power level */ |
| 2782 | f_wait_for_l1_power_level(pwr_var); |
| 2783 | |
| 2784 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2785 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2786 | |
| 2787 | /* wait, then check that our power level did not change */ |
| 2788 | timer T1 := 10.0; |
| 2789 | T1.start; |
| 2790 | alt { |
| 2791 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2792 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2793 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2794 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2795 | } |
| 2796 | repeat; |
| 2797 | } |
| 2798 | [] L1CTL.receive { repeat; } |
| 2799 | [] T1.timeout { setverdict(pass); } |
| 2800 | } |
| 2801 | |
| 2802 | f_rsl_chan_deact(); |
| 2803 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2804 | |
| 2805 | } |
| 2806 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2807 | private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2808 | var L1ctlDlMessage l1_dl; |
| 2809 | timer T0 := 10.0; |
| 2810 | T0.start; |
| 2811 | alt { |
| 2812 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2813 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2814 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2815 | "Power level in L1 header != signaled (RSL) power level."); |
| 2816 | } |
| 2817 | } |
| 2818 | [] L1CTL.receive { repeat; } |
| 2819 | [] T0.timeout { |
| 2820 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2821 | "Timeout waiting for initial power level"); |
| 2822 | } |
| 2823 | } |
| 2824 | T0.stop; |
| 2825 | } |
| 2826 | |
| 2827 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2828 | var IntegerRecord min_dbm_level; |
| 2829 | var IntegerRecord max_dbm_level; |
| 2830 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2831 | |
| 2832 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2833 | if (min_dbm_level[i] == level) { |
| 2834 | return true; |
| 2835 | } |
| 2836 | } |
| 2837 | return false; |
| 2838 | } |
| 2839 | |
| 2840 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2841 | var IntegerRecord min_dbm_level; |
| 2842 | var IntegerRecord max_dbm_level; |
| 2843 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2844 | |
| 2845 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2846 | if (max_dbm_level[i] == level) { |
| 2847 | return true; |
| 2848 | } |
| 2849 | } |
| 2850 | return false; |
| 2851 | } |
| 2852 | |
| 2853 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2854 | var IntegerRecord min_dbm_level; |
| 2855 | var IntegerRecord max_dbm_level; |
| 2856 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2857 | return max_dbm_level[0]; |
| 2858 | } |
| 2859 | |
| 2860 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2861 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2862 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2863 | // 45.005 4.1.1 |
| 2864 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2865 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2866 | 2, 1, 0}; |
| 2867 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2868 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2869 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2870 | var IntegerRecord rv; |
| 2871 | |
| 2872 | select(band){ |
| 2873 | case (BtsBand_allGSM){ |
| 2874 | rv := gsm_power; |
| 2875 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2876 | max_dbm_level := {2, 1, 0}; |
| 2877 | } |
| 2878 | case("DCS1800"){ |
| 2879 | rv := dcs_power; |
| 2880 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2881 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2882 | } |
| 2883 | case("PCS1900"){ |
| 2884 | rv := pcs_power; |
| 2885 | min_dbm_level := {15}; |
| 2886 | max_dbm_level := {30}; |
| 2887 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 2888 | case else { |
| 2889 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 2890 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | return rv; |
| 2894 | } |
| 2895 | |
| 2896 | 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] | 2897 | 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] | 2898 | } |
| 2899 | |
| 2900 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2901 | var ConnHdlr vc_conn; |
| 2902 | var ConnHdlrPars pars; |
| 2903 | f_init(); |
| 2904 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2905 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2906 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2907 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2908 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2909 | vc_conn.done; |
| 2910 | } |
| 2911 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2912 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2913 | } |
| 2914 | |
| 2915 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2916 | var ConnHdlr vc_conn; |
| 2917 | var ConnHdlrPars pars; |
| 2918 | f_init(); |
| 2919 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2920 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2921 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2922 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2923 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2924 | vc_conn.done; |
| 2925 | } |
| 2926 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2927 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2928 | } |
| 2929 | |
| 2930 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2931 | var ConnHdlr vc_conn; |
| 2932 | var ConnHdlrPars pars; |
| 2933 | f_init(); |
| 2934 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2935 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2936 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2937 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2938 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2939 | vc_conn.done; |
| 2940 | } |
| 2941 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2942 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2943 | } |
| 2944 | |
| 2945 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2946 | var ConnHdlr vc_conn; |
| 2947 | var ConnHdlrPars pars; |
| 2948 | f_init(); |
| 2949 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2950 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2951 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2952 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2953 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2954 | vc_conn.done; |
| 2955 | } |
| 2956 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2957 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2958 | } |
| 2959 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2960 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2961 | var ConnHdlr vc_conn; |
| 2962 | var ConnHdlrPars pars; |
| 2963 | f_init(); |
| 2964 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2965 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2966 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2967 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2968 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2969 | vc_conn.done; |
| 2970 | } |
| 2971 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2972 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2973 | } |
| 2974 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2975 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2976 | var ConnHdlr vc_conn; |
| 2977 | var ConnHdlrPars pars; |
| 2978 | f_init(); |
| 2979 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2980 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2981 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2982 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2983 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2984 | vc_conn.done; |
| 2985 | } |
| 2986 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2987 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2988 | } |
| 2989 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2990 | 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] | 2991 | var template RSL_IE_ChannelMode ch_mode; |
| 2992 | var ConnHdlr vc_conn; |
| 2993 | var ConnHdlrPars pars; |
| 2994 | f_init(); |
| 2995 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 2996 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 2997 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2998 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 2999 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3000 | pcu_comp := false, trxc_comp := true); |
| 3001 | vc_conn.done; |
| 3002 | } |
| 3003 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3004 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3005 | |
| 3006 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3007 | f_TC_meas_res_speech_tchf(false); |
| 3008 | } |
| 3009 | |
| 3010 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3011 | f_TC_meas_res_speech_tchf(true); |
| 3012 | } |
| 3013 | |
| 3014 | 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] | 3015 | var template RSL_IE_ChannelMode ch_mode; |
| 3016 | var ConnHdlr vc_conn; |
| 3017 | var ConnHdlrPars pars; |
| 3018 | f_init(); |
| 3019 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3020 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3021 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3022 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3023 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3024 | pcu_comp := false, trxc_comp := true); |
| 3025 | vc_conn.done; |
| 3026 | } |
| 3027 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3028 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3029 | |
| 3030 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3031 | f_TC_meas_res_speech_tchh(false) |
| 3032 | } |
| 3033 | |
| 3034 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3035 | f_TC_meas_res_speech_tchh(true) |
| 3036 | } |
| 3037 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3038 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3039 | var template RSL_IE_ChannelMode ch_mode; |
| 3040 | var ConnHdlr vc_conn; |
| 3041 | var ConnHdlrPars pars; |
| 3042 | f_init(); |
| 3043 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3044 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3045 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3046 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3047 | pars.l1_pars.toa256_enabled := true; |
| 3048 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3049 | pcu_comp := false, trxc_comp := true); |
| 3050 | vc_conn.done; |
| 3051 | } |
| 3052 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3053 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3054 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3055 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3056 | var ConnHdlr vc_conn; |
| 3057 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3058 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3059 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3060 | 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] | 3061 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3062 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3063 | vc_conn.done; |
| 3064 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3065 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3066 | } |
| 3067 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3068 | var ConnHdlr vc_conn; |
| 3069 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3070 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3071 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3072 | 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] | 3073 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3074 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3075 | vc_conn.done; |
| 3076 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3077 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3078 | } |
| 3079 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3080 | var ConnHdlr vc_conn; |
| 3081 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3082 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3083 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3084 | 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] | 3085 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3086 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3087 | vc_conn.done; |
| 3088 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3089 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3090 | } |
| 3091 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3092 | var ConnHdlr vc_conn; |
| 3093 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3094 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3095 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3096 | 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] | 3097 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3098 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3099 | vc_conn.done; |
| 3100 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3101 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3102 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3103 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3104 | var ConnHdlr vc_conn; |
| 3105 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3106 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3107 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3108 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3109 | 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] | 3110 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3111 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3112 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3113 | vc_conn.done; |
| 3114 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3115 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3116 | } |
| 3117 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3118 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3119 | * 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] | 3120 | private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3121 | var L1ctlDlMessage l1_dl; |
| 3122 | var RSL_IE_MS_Power ms_power; |
| 3123 | var RSL_Message rsl; |
| 3124 | var uint5_t power_level := 0; |
| 3125 | |
| 3126 | f_l1_tune(L1CTL); |
| 3127 | RSL.clear; |
| 3128 | |
| 3129 | f_est_dchan(); |
| 3130 | |
| 3131 | ms_power.reserved := 0; |
| 3132 | ms_power.fpc_epc := false; |
| 3133 | |
| 3134 | /* Send the first power control command. This will disable any BTS/TRX |
| 3135 | * internal power control and switch the MS (which is not in scope of |
| 3136 | * this test) to a constant power level. We start with a power level |
| 3137 | * of 0 */ |
| 3138 | ms_power.power_level := power_level; |
| 3139 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3140 | RSL.send(rsl); |
| 3141 | |
| 3142 | alt { |
| 3143 | |
| 3144 | /* Pick all SACCH blocks for checking */ |
| 3145 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3146 | |
| 3147 | /* The first byte of the L1 header contains the power level. |
| 3148 | * The reserved bits and the fpc bit is set to 0, so we may |
| 3149 | * compare directly. */ |
| 3150 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 3151 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 3152 | } |
| 3153 | |
| 3154 | /* Signal a new power level via RSL for the next turn. */ |
| 3155 | if (power_level < 31) { |
| 3156 | power_level := power_level + 1; |
| 3157 | ms_power.power_level := power_level; |
| 3158 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3159 | RSL.send(rsl); |
| 3160 | repeat; |
| 3161 | } |
| 3162 | |
| 3163 | } |
| 3164 | |
| 3165 | /* Ignore all other blocks */ |
| 3166 | [] L1CTL.receive { repeat; } |
| 3167 | |
| 3168 | } |
| 3169 | |
| 3170 | f_rsl_chan_deact(); |
| 3171 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3172 | |
| 3173 | setverdict(pass); |
| 3174 | } |
| 3175 | |
| 3176 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3177 | var ConnHdlr vc_conn; |
| 3178 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3179 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3180 | |
| 3181 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3182 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3183 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3184 | vc_conn.done; |
| 3185 | } |
| 3186 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3187 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3188 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3189 | /* 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] | 3190 | 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] | 3191 | 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] | 3192 | var L1ctlDlMessage l1_dl; |
| 3193 | var uint5_t ta_to_test := 16; |
| 3194 | |
| 3195 | |
| 3196 | f_l1_tune(L1CTL); |
| 3197 | RSL.clear; |
| 3198 | |
| 3199 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3200 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3201 | |
| 3202 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3203 | |
| 3204 | |
| 3205 | alt { |
| 3206 | |
| 3207 | /* Pick all SACCH blocks for checking */ |
| 3208 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3209 | |
| 3210 | /* The second byte of the L1 header contains the TA. */ |
| 3211 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 3212 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3213 | } |
| 3214 | |
| 3215 | } |
| 3216 | |
| 3217 | /* Ignore all other blocks */ |
| 3218 | [] L1CTL.receive { repeat; } |
| 3219 | |
| 3220 | } |
| 3221 | |
| 3222 | f_rsl_chan_deact(); |
| 3223 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3224 | |
| 3225 | setverdict(pass); |
| 3226 | } |
| 3227 | |
| 3228 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3229 | var ConnHdlr vc_conn; |
| 3230 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3231 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3232 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3233 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3234 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3235 | vc_conn.done; |
| 3236 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3237 | } |
| 3238 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3239 | /* 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] | 3240 | 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] | 3241 | var L1ctlDlMessage l1_dl; |
| 3242 | var uint5_t ms_power_level := 7; |
| 3243 | |
| 3244 | var RSL_IE_MS_Power ms_power; |
| 3245 | ms_power.reserved := 0; |
| 3246 | ms_power.fpc_epc := false; |
| 3247 | ms_power.power_level := ms_power_level; |
| 3248 | |
| 3249 | f_l1_tune(L1CTL); |
| 3250 | RSL.clear; |
| 3251 | |
| 3252 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3253 | |
| 3254 | timer T := 1.0; |
| 3255 | T.start; |
| 3256 | alt { |
| 3257 | /* Pick all SACCH blocks for checking */ |
| 3258 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 3259 | /* The first byte of the L1 header contains the power level.. */ |
| 3260 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 3261 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3262 | } |
| 3263 | } |
| 3264 | /* Ignore all other blocks */ |
| 3265 | [] L1CTL.receive { repeat; } |
| 3266 | [] T.timeout { |
| 3267 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3268 | } |
| 3269 | } |
| 3270 | |
| 3271 | f_rsl_chan_deact(); |
| 3272 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3273 | setverdict(pass); |
| 3274 | } |
| 3275 | |
| 3276 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3277 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3278 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3279 | } |
| 3280 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3281 | /* 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] | 3282 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3283 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3284 | RSL.clear; |
| 3285 | |
| 3286 | f_est_dchan(); |
| 3287 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3288 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3289 | |
| 3290 | timer T := 40.0; |
| 3291 | T.start; |
| 3292 | alt { |
| 3293 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3294 | setverdict(pass) |
| 3295 | } |
| 3296 | [] RSL.receive { repeat }; |
| 3297 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3298 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3299 | } |
| 3300 | } |
| 3301 | f_rsl_chan_deact(); |
| 3302 | } |
| 3303 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3304 | var ConnHdlr vc_conn; |
| 3305 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3306 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3307 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3308 | pars.t_guard := 60.0; |
| 3309 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3310 | vc_conn.done; |
| 3311 | } |
| 3312 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3313 | /*********************************************************************** |
| 3314 | * Paging |
| 3315 | ***********************************************************************/ |
| 3316 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3317 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3318 | if (tmsi == 'FFFFFFFF'O) { |
| 3319 | return true; |
| 3320 | } else { |
| 3321 | return false; |
| 3322 | } |
| 3323 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3324 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3325 | private type record allowedFn { integer frame_nr } |
| 3326 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3327 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3328 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3329 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3330 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3331 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3332 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3333 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3334 | 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] | 3335 | { |
| 3336 | var integer frame_nr_51; |
| 3337 | frame_nr_51 := frame_nr mod 51 |
| 3338 | |
| 3339 | var allowedFn fn_check; |
| 3340 | fn_check.frame_nr := frame_nr_51; |
| 3341 | |
| 3342 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3343 | 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] | 3344 | return; |
| 3345 | } |
| 3346 | |
| 3347 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3348 | return; |
| 3349 | } |
| 3350 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3351 | return; |
| 3352 | } |
| 3353 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3354 | return; |
| 3355 | } |
| 3356 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3357 | return; |
| 3358 | } |
| 3359 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3360 | return; |
| 3361 | } |
| 3362 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3363 | return; |
| 3364 | } |
| 3365 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3366 | return; |
| 3367 | } |
| 3368 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3369 | return; |
| 3370 | } |
| 3371 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3372 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3373 | return; |
| 3374 | } |
| 3375 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3376 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3377 | inout integer num_paging_rcv_ids, |
| 3378 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3379 | runs on test_CT { |
| 3380 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3381 | [] 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] | 3382 | repeat; |
| 3383 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3384 | [] 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] | 3385 | var octetstring without_plen := |
| 3386 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3387 | 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] | 3388 | |
| 3389 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3390 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3391 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3392 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3393 | * TODO: does it make sense to count them? */ |
| 3394 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3395 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3396 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3397 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3398 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3399 | } |
| 3400 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3401 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3402 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3403 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3404 | } |
| 3405 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3406 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3407 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3408 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3409 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3410 | } |
| 3411 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3412 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3413 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3414 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3415 | } |
| 3416 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3417 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3418 | } |
| 3419 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3420 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3421 | } |
| 3422 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3423 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3424 | } |
| 3425 | } |
| 3426 | repeat; |
| 3427 | } |
| 3428 | } |
| 3429 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3430 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3431 | boolean combined_ccch, |
| 3432 | integer bs_ag_blks_res, |
| 3433 | float load_factor, |
| 3434 | boolean exp_load_ind, |
| 3435 | boolean exp_overload, |
| 3436 | boolean use_tmsi |
| 3437 | } |
| 3438 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3439 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3440 | integer num_paging_sent, |
| 3441 | integer num_paging_rcv_msgs, |
| 3442 | integer num_paging_rcv_ids, |
| 3443 | integer num_overload |
| 3444 | } |
| 3445 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3446 | /* Helper function for paging related testing */ |
| 3447 | 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] | 3448 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3449 | f_init_l1ctl(); |
| 3450 | f_l1_tune(L1CTL); |
| 3451 | |
| 3452 | var PagingTestState st := { |
| 3453 | num_paging_sent := 0, |
| 3454 | num_paging_rcv_msgs := 0, |
| 3455 | num_paging_rcv_ids := 0, |
| 3456 | num_overload := 0 |
| 3457 | }; |
| 3458 | |
| 3459 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 3460 | var float max_pch_imsi_per_sec; |
| 3461 | if (cfg.use_tmsi) { |
| 3462 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 3463 | } else { |
| 3464 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 3465 | } |
| 3466 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 3467 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3468 | var float time_total := 20.0; |
| 3469 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 3470 | 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] | 3471 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3472 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 3473 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3474 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3475 | timer T_itv := 0.0; |
| 3476 | T_itv.start; |
| 3477 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3478 | alt { |
| 3479 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3480 | [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] | 3481 | st.num_overload := st.num_overload + 1; |
| 3482 | repeat; |
| 3483 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3484 | [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] | 3485 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3486 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3487 | [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] | 3488 | log("Rx LOAD_IND"); |
| 3489 | /* FIXME: analyze/verify interval + contents */ |
| 3490 | repeat; |
| 3491 | } |
| 3492 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3493 | [] 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] | 3494 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3495 | [] T_itv.timeout { |
| 3496 | /* Send paging cmds based on elapsed time */ |
| 3497 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 3498 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3499 | var MobileIdentityV mi; |
| 3500 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3501 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3502 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3503 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3504 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3505 | 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] | 3506 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3507 | |
| 3508 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3509 | 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] | 3510 | |
| 3511 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3512 | } |
| 3513 | if (st.num_paging_sent < pkt_total) { |
| 3514 | /* Wait for interval to next PAGING COMMAND */ |
| 3515 | var float time_now := T_total.read; |
| 3516 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3517 | if (next_sched > time_now) { |
| 3518 | T_itv.start(next_sched - time_now); |
| 3519 | } else { |
| 3520 | T_itv.start(0.0); |
| 3521 | } |
| 3522 | } else { |
| 3523 | /* We are done, no need to keep counting */ |
| 3524 | T_total.stop; |
| 3525 | } |
| 3526 | } |
| 3527 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3528 | } |
| 3529 | } |
| 3530 | |
| 3531 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3532 | timer T_wait := 18.0; |
| 3533 | T_wait.start; |
| 3534 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3535 | [] 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] | 3536 | [] L1CTL.receive { repeat; } |
| 3537 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3538 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3539 | [] 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] | 3540 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3541 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3542 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3543 | } |
| 3544 | |
| 3545 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3546 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3547 | return st; |
| 3548 | } |
| 3549 | |
| 3550 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3551 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3552 | * - that CCCH LOAD IND (PCH) are being generated |
| 3553 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3554 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3555 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3556 | var PagingTestCfg cfg := { |
| 3557 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3558 | 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] | 3559 | load_factor := 0.8, |
| 3560 | exp_load_ind := true, |
| 3561 | exp_overload := false, |
| 3562 | use_tmsi := false |
| 3563 | }; |
| 3564 | var PagingTestState st := f_TC_paging(cfg); |
| 3565 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3566 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3567 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3568 | } else { |
| 3569 | setverdict(pass); |
| 3570 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3571 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3572 | } |
| 3573 | |
| 3574 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3575 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3576 | * - that CCCH LOAD IND (PCH) are being generated |
| 3577 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3578 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3579 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3580 | var PagingTestCfg cfg := { |
| 3581 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3582 | 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] | 3583 | load_factor := 0.8, |
| 3584 | exp_load_ind := true, |
| 3585 | exp_overload := false, |
| 3586 | use_tmsi := true |
| 3587 | }; |
| 3588 | var PagingTestState st := f_TC_paging(cfg); |
| 3589 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3590 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3591 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3592 | } else { |
| 3593 | setverdict(pass); |
| 3594 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3595 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3596 | } |
| 3597 | |
| 3598 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3599 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3600 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3601 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3602 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3603 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3604 | var PagingTestCfg cfg := { |
| 3605 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3606 | 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] | 3607 | load_factor := 2.0, |
| 3608 | exp_load_ind := true, |
| 3609 | exp_overload := true, |
| 3610 | use_tmsi := false |
| 3611 | }; |
| 3612 | var PagingTestState st := f_TC_paging(cfg); |
| 3613 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3614 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3615 | 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] | 3616 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3617 | 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] | 3618 | } else { |
| 3619 | setverdict(pass); |
| 3620 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3621 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3625 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3626 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3627 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3628 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3629 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3630 | var PagingTestCfg cfg := { |
| 3631 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3632 | 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] | 3633 | load_factor := 2.0, |
| 3634 | exp_load_ind := true, |
| 3635 | exp_overload := true, |
| 3636 | use_tmsi := true |
| 3637 | }; |
| 3638 | var PagingTestState st := f_TC_paging(cfg); |
| 3639 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3640 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3641 | 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] | 3642 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3643 | 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] | 3644 | } else { |
| 3645 | setverdict(pass); |
| 3646 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3647 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3651 | /*********************************************************************** |
| 3652 | * Immediate Assignment / AGCH |
| 3653 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 3654 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3655 | len := 0, |
| 3656 | ma := ''B |
| 3657 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3658 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3659 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3660 | return int2str(num_tx) & " sent, " |
| 3661 | & int2str(num_rx) & " received, " |
| 3662 | & int2str(num_del) & " deleted"; |
| 3663 | } |
| 3664 | |
| 3665 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3666 | var L1ctlDlMessage l1_dl; |
| 3667 | timer T := 10.0; |
| 3668 | var integer num_tx := 0; |
| 3669 | var integer num_rx := 0; |
| 3670 | var integer num_del := 0; |
| 3671 | var charstring res_str; |
| 3672 | var float rx_ratio; |
| 3673 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3674 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3675 | f_init_l1ctl(); |
| 3676 | f_l1_tune(L1CTL); |
| 3677 | |
| 3678 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | dd82be3 | 2020-10-18 16:09:58 +0700 | [diff] [blame] | 3679 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), mp_trx0_arfcn)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3680 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3681 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3682 | 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] | 3683 | num_tx := num_tx+1; |
| 3684 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3685 | } |
| 3686 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3687 | T.start; |
| 3688 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3689 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3690 | num_del := num_del+1; |
| 3691 | repeat; |
| 3692 | } |
| 3693 | [] RSL_CCHAN.receive { |
| 3694 | repeat; |
| 3695 | } |
| 3696 | [] 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] | 3697 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3698 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3699 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3700 | //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] | 3701 | } else { |
| 3702 | num_rx := num_rx+1; |
| 3703 | } |
| 3704 | repeat; |
| 3705 | } |
| 3706 | [] L1CTL.receive { repeat; } |
| 3707 | [] T.timeout { } |
| 3708 | } |
| 3709 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3710 | log("AGCH test: " & res_str); |
| 3711 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3712 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3713 | } |
| 3714 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3715 | 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] | 3716 | 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] | 3717 | } else { |
| 3718 | setverdict(pass); |
| 3719 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3720 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3721 | } |
| 3722 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3723 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3724 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3725 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3726 | } |
| 3727 | |
| 3728 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3729 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3730 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3731 | } |
| 3732 | |
| 3733 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3734 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3735 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3736 | } |
| 3737 | |
| 3738 | |
| 3739 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3740 | /*********************************************************************** |
| 3741 | * BCCH |
| 3742 | ***********************************************************************/ |
| 3743 | |
| 3744 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3745 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3746 | GsmFrameNumber frame_number, |
| 3747 | SystemInformation si |
| 3748 | } |
| 3749 | |
| 3750 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3751 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3752 | |
| 3753 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3754 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3755 | |
| 3756 | /* 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] | 3757 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 3758 | RrMessageType key, |
| 3759 | boolean bcch_ext := false) |
| 3760 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3761 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3762 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3763 | if (not bcch_ext and fn_mod51 == 2 or |
| 3764 | bcch_ext and fn_mod51 == 6) { |
| 3765 | if (arr[i].si.header.message_type == key) { |
| 3766 | return true; |
| 3767 | } |
| 3768 | } |
| 3769 | } |
| 3770 | return false; |
| 3771 | } |
| 3772 | |
| 3773 | /* 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] | 3774 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3775 | integer tc, RrMessageType key, |
| 3776 | boolean ext_bcch := false) |
| 3777 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3778 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3779 | 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] | 3780 | } |
| 3781 | } |
| 3782 | |
| 3783 | /* 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] | 3784 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 3785 | RrMessageType key) |
| 3786 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3787 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3788 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3789 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3790 | return true; |
| 3791 | } |
| 3792 | } |
| 3793 | return false; |
| 3794 | } |
| 3795 | |
| 3796 | /* 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] | 3797 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 3798 | RrMessageType key, |
| 3799 | boolean bcch_ext := false, |
| 3800 | integer n := 1, integer m := 4) |
| 3801 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3802 | var integer count := 0; |
| 3803 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 3804 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 3805 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3806 | } |
| 3807 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3808 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3809 | if (not bcch_ext and fn_mod51 == 2 or |
| 3810 | bcch_ext and fn_mod51 == 6) { |
| 3811 | if (arr[i].si.header.message_type == key) { |
| 3812 | count := count + 1; |
| 3813 | } |
| 3814 | } |
| 3815 | } |
| 3816 | if (count >= n) { |
| 3817 | return true; |
| 3818 | } else { |
| 3819 | return false; |
| 3820 | } |
| 3821 | } |
| 3822 | |
| 3823 | /* 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] | 3824 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 3825 | integer tc, RrMessageType key, |
| 3826 | boolean ext_bcch := false, |
| 3827 | integer n, integer m) |
| 3828 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3829 | 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] | 3830 | 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] | 3831 | } |
| 3832 | } |
| 3833 | |
| 3834 | /* 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] | 3835 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 3836 | RrMessageType key, |
| 3837 | boolean bcch_ext := false) |
| 3838 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3839 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3840 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3841 | if (not bcch_ext and fn_mod51 == 2 or |
| 3842 | bcch_ext and fn_mod51 == 6) { |
| 3843 | if (arr[i].si.header.message_type != key) { |
| 3844 | return false; |
| 3845 | } |
| 3846 | } |
| 3847 | } |
| 3848 | return true; |
| 3849 | } |
| 3850 | |
| 3851 | /* 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] | 3852 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 3853 | integer tc, RrMessageType key, |
| 3854 | boolean ext_bcch := false) |
| 3855 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3856 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3857 | 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] | 3858 | } |
| 3859 | } |
| 3860 | |
| 3861 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3862 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3863 | boolean bcch_extended, |
| 3864 | boolean si1_present, |
| 3865 | boolean si2bis_present, |
| 3866 | boolean si2ter_present, |
| 3867 | boolean si2quater_present, |
| 3868 | boolean si7_present, |
| 3869 | boolean si8_present, |
| 3870 | boolean si9_present, |
| 3871 | boolean si13_present, |
| 3872 | boolean si13alt_present, |
| 3873 | boolean si15_present, |
| 3874 | boolean si16_present, |
| 3875 | boolean si17_present, |
| 3876 | boolean si2n_present, |
| 3877 | boolean si21_present, |
| 3878 | boolean si22_present |
| 3879 | } |
| 3880 | |
| 3881 | /* 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] | 3882 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 3883 | SystemInformationVectorPerTc si_per_tc) |
| 3884 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3885 | var integer i; |
| 3886 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3887 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3888 | 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] | 3889 | } |
| 3890 | } |
| 3891 | if (cfg.si1_present) { |
| 3892 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3893 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3894 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3895 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3896 | /* make sure *ALL* contain SI1 */ |
| 3897 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3898 | } |
| 3899 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3900 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3901 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3902 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3903 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3904 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3905 | |
| 3906 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3907 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3908 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3909 | * consecutive occurrences of TC = 4. */ |
| 3910 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3911 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3912 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3913 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3914 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3915 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3916 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3917 | } |
| 3918 | |
| 3919 | if (cfg.si7_present or cfg.si8_present) { |
| 3920 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3921 | * if System Information type 4 does not contain all information needed for cell |
| 3922 | * selection and reselection. */ |
| 3923 | if (not cfg.bcch_extended) { |
| 3924 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3925 | } |
| 3926 | if (cfg.si7_present) { |
| 3927 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3928 | } |
| 3929 | if (cfg.si8_present) { |
| 3930 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3931 | } |
| 3932 | } |
| 3933 | |
| 3934 | if (cfg.si2quater_present) { |
| 3935 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3936 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3937 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3938 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3939 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3940 | if (not (cfg.bcch_extended)) { |
| 3941 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3942 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3943 | } else { |
| 3944 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3945 | } |
| 3946 | } else { |
| 3947 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3948 | } |
| 3949 | } |
| 3950 | if (cfg.si9_present) { |
| 3951 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3952 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3953 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3954 | } |
| 3955 | if (cfg.si13_present) { |
| 3956 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3957 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3958 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3959 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3960 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3961 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3962 | if (not cfg.bcch_extended) { |
| 3963 | log("not-bccch-extended"); |
| 3964 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3965 | } else { |
| 3966 | log("bccch-extended"); |
| 3967 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3968 | } |
| 3969 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3970 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3971 | } |
| 3972 | } |
| 3973 | if (cfg.si16_present or cfg.si17_present) { |
| 3974 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3975 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3976 | if (cfg.si22_present) { |
| 3977 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3978 | } |
| 3979 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3980 | 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] | 3981 | } |
| 3982 | if (not cfg.bcch_extended) { |
| 3983 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3984 | } |
| 3985 | if (cfg.si16_present) { |
| 3986 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3987 | } |
| 3988 | if (cfg.si17_present) { |
| 3989 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3990 | } |
| 3991 | } |
| 3992 | |
| 3993 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3994 | * broadcast information. The frequency with which they are sent is determined by the |
| 3995 | * system operator. System Information type 9 identifies the scheduling of System |
| 3996 | * Information type 18 and 20 messages. */ |
| 3997 | |
| 3998 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3999 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4000 | * Information Type 9. */ |
| 4001 | |
| 4002 | if (cfg.si15_present) { |
| 4003 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4004 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4005 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4006 | * 4 consecutive occurrences of TC = 1. */ |
| 4007 | if (not cfg.bcch_extended) { |
| 4008 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4009 | } else { |
| 4010 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4011 | } |
| 4012 | } |
| 4013 | if (cfg.si13alt_present) { |
| 4014 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4015 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4016 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4017 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4018 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4019 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4020 | * of TC = 4. */ |
| 4021 | if (cfg.si13_present) { |
| 4022 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4023 | } |
| 4024 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4025 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4026 | } |
| 4027 | if (not cfg.bcch_extended) { |
| 4028 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4029 | } else { |
| 4030 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4031 | } |
| 4032 | } |
| 4033 | if (cfg.si2n_present) { |
| 4034 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4035 | * as determined by the system operator. In the case that the message is sent on the |
| 4036 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4037 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4038 | * consecutive occurrences of TC = 4. */ |
| 4039 | if (not cfg.bcch_extended) { |
| 4040 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4041 | } else { |
| 4042 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4043 | } |
| 4044 | } |
| 4045 | if (cfg.si21_present) { |
| 4046 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4047 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4048 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4049 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4050 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4051 | if (not cfg.bcch_extended) { |
| 4052 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4053 | } else { |
| 4054 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4055 | 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] | 4056 | 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] | 4057 | } |
| 4058 | } |
| 4059 | } |
| 4060 | if (cfg.si22_present) { |
| 4061 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4062 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4063 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4064 | * =2 and TC=6. */ |
| 4065 | if (cfg.si16_present or cfg.si17_present) { |
| 4066 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4067 | } |
| 4068 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4069 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4070 | 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] | 4071 | } |
| 4072 | if (not cfg.bcch_extended) { |
| 4073 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4074 | } else { |
| 4075 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4076 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4077 | } |
| 4078 | } |
| 4079 | } |
| 4080 | |
| 4081 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4082 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4083 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4084 | timer T := duration; |
| 4085 | var SystemInformationVectorPerTc si_per_tc; |
| 4086 | var L1ctlDlMessage l1_dl; |
| 4087 | |
| 4088 | /* initialize all per-TC vectors empty */ |
| 4089 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4090 | si_per_tc[i] := {}; |
| 4091 | } |
| 4092 | |
| 4093 | /* flush all previous L1 queued msgs */ |
| 4094 | pt.clear; |
| 4095 | |
| 4096 | T.start; |
| 4097 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4098 | [] 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] | 4099 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4100 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4101 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4102 | repeat; |
| 4103 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4104 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4105 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4106 | log("SI received at TC=", tc, ": ", sig.si); |
| 4107 | /* append to the per-TC bucket */ |
| 4108 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4109 | repeat; |
| 4110 | } |
| 4111 | [] pt.receive { repeat; } |
| 4112 | [] T.timeout { } |
| 4113 | } |
| 4114 | |
| 4115 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4116 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4117 | } |
| 4118 | log("si_per_tc=", si_per_tc); |
| 4119 | return si_per_tc; |
| 4120 | } |
| 4121 | |
| 4122 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4123 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4124 | 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] | 4125 | var SystemInformationVectorPerTc si_per_tc; |
| 4126 | f_init_l1ctl(); |
| 4127 | f_l1_tune(L1CTL); |
| 4128 | |
| 4129 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4130 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4131 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4132 | |
| 4133 | setverdict(pass); |
| 4134 | } |
| 4135 | |
| 4136 | testcase TC_si_sched_default() runs on test_CT { |
| 4137 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4138 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4139 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4140 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4141 | } |
| 4142 | |
| 4143 | testcase TC_si_sched_1() runs on test_CT { |
| 4144 | f_init(); |
| 4145 | si_cfg.si1_present := true; |
| 4146 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4147 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4148 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4149 | } |
| 4150 | |
| 4151 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4152 | f_init(); |
| 4153 | si_cfg.si2bis_present := true; |
| 4154 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4155 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4156 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4157 | } |
| 4158 | |
| 4159 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4160 | f_init(); |
| 4161 | si_cfg.si2ter_present := true; |
| 4162 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4163 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4164 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4165 | } |
| 4166 | |
| 4167 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4168 | f_init(); |
| 4169 | si_cfg.si2bis_present := true; |
| 4170 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4171 | si_cfg.si2ter_present := true; |
| 4172 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4173 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4174 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4175 | } |
| 4176 | |
| 4177 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4178 | f_init(); |
| 4179 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4180 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4181 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4182 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4183 | } |
| 4184 | |
| 4185 | testcase TC_si_sched_13() runs on test_CT { |
| 4186 | f_init(); |
| 4187 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4188 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4189 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4190 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4191 | } |
| 4192 | |
| 4193 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 4194 | f_init(); |
| 4195 | si_cfg.si2bis_present := true; |
| 4196 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4197 | si_cfg.si2ter_present := true; |
| 4198 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4199 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4200 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4201 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4202 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4203 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4204 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4205 | } |
| 4206 | |
| 4207 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4208 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4209 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4210 | /* FIXME: enable / disable individual BCCH info */ |
| 4211 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4212 | /* expect no ERROR REPORT after either of them * |
| 4213 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4214 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4215 | } |
| 4216 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4217 | /*********************************************************************** |
| 4218 | * Low-Level Protocol Errors / ERROR REPORT |
| 4219 | ***********************************************************************/ |
| 4220 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4221 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4222 | timer T := 5.0; |
| 4223 | T.start; |
| 4224 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4225 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4226 | setverdict(pass); |
| 4227 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4228 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4229 | 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] | 4230 | } |
| 4231 | [] RSL_CCHAN.receive { |
| 4232 | repeat; |
| 4233 | } |
| 4234 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4235 | 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] | 4236 | } |
| 4237 | } |
| 4238 | } |
| 4239 | |
| 4240 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4241 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4242 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4243 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4244 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4245 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4246 | |
| 4247 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4248 | } |
| 4249 | |
| 4250 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4251 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4252 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4253 | |
| 4254 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4255 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4256 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4257 | |
| 4258 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4259 | } |
| 4260 | |
| 4261 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4262 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4263 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4264 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4265 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4266 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4267 | |
| 4268 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4269 | } |
| 4270 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4271 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4272 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4273 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4274 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4275 | RSL.send(rsl); |
| 4276 | f_rslem_unregister(0, g_chan_nr); |
| 4277 | } |
| 4278 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4279 | var ConnHdlr vc_conn; |
| 4280 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4281 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4282 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4283 | |
| 4284 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4285 | vc_conn.done; |
| 4286 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4287 | |
| 4288 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4289 | } |
| 4290 | |
| 4291 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4292 | 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] | 4293 | var template (value) RSL_Message rsl_tx; |
| 4294 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4295 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4296 | RSL.send(rsl_tx); |
| 4297 | f_rslem_unregister(0, g_chan_nr); |
| 4298 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4299 | 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] | 4300 | var template (value) RSL_Message rsl_tx; |
| 4301 | /* we first have to activate the dedicated channel */ |
| 4302 | f_rsl_chan_act(g_pars.chan_mode); |
| 4303 | /* ... to then send an invalid RLL message */ |
| 4304 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4305 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4306 | RSL.send(rsl_tx); |
| 4307 | f_rslem_unregister(0, g_chan_nr); |
| 4308 | } |
| 4309 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4310 | var ConnHdlr vc_conn; |
| 4311 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4312 | var template (value) RSL_Message rsl_tx; |
| 4313 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4314 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4315 | |
| 4316 | /* Common Channel with wrong message type */ |
| 4317 | RSL_CCHAN.clear; |
| 4318 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4319 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4320 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4321 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4322 | |
| 4323 | /* TRX Management */ |
| 4324 | RSL_CCHAN.clear; |
| 4325 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4326 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4327 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4328 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4329 | |
| 4330 | /* Dedicated Channel */ |
| 4331 | RSL_CCHAN.clear; |
| 4332 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4333 | vc_conn.done; |
| 4334 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4335 | |
| 4336 | /* RLL */ |
| 4337 | RSL_CCHAN.clear; |
| 4338 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4339 | vc_conn.done; |
| 4340 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4341 | } |
| 4342 | |
| 4343 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4344 | 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] | 4345 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4346 | f_rslem_unregister(0, g_chan_nr); |
| 4347 | } |
| 4348 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4349 | var ConnHdlr vc_conn; |
| 4350 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4351 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4352 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4353 | |
| 4354 | RSL_CCHAN.clear; |
| 4355 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4356 | vc_conn.done; |
| 4357 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4358 | } |
| 4359 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4360 | /*********************************************************************** |
| 4361 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4362 | ***********************************************************************/ |
| 4363 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4364 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4365 | 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] | 4366 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4367 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4368 | } |
| 4369 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4370 | 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] | 4371 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4372 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 4373 | vc_conn.done; |
| 4374 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4375 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4376 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4377 | 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] | 4378 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4379 | "IPA CRCX ACK"); |
| 4380 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 4381 | "IPA CRCX NACK"); |
| 4382 | } |
| 4383 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 4384 | 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] | 4385 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4386 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 4387 | vc_conn.done; |
| 4388 | } |
| 4389 | |
| 4390 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4391 | 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] | 4392 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4393 | "IPA CRCX ACK"); |
| 4394 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4395 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4396 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4397 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4398 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4399 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4400 | "IPA MDCX ACK"); |
| 4401 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4402 | "IPA DLCX ACK"); |
| 4403 | } |
| 4404 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4405 | 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] | 4406 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4407 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 4408 | vc_conn.done; |
| 4409 | } |
| 4410 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4411 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4412 | 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] | 4413 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 4414 | "IPA CRCX ACK"); |
| 4415 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4416 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 4417 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 4418 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 4419 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4420 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4421 | "IPA MDCX ACK"); |
| 4422 | /* Second MDCX */ |
| 4423 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 4424 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 4425 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 4426 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 4427 | "IPA MDCX ACK"); |
| 4428 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4429 | "IPA DLCX ACK"); |
| 4430 | } |
| 4431 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 4432 | 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] | 4433 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 4434 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 4435 | vc_conn.done; |
| 4436 | } |
| 4437 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4438 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4439 | 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] | 4440 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 4441 | "IPA CRCX NACK"); |
| 4442 | } |
| 4443 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 4444 | var ConnHdlrPars pars; |
| 4445 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4446 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 4447 | |
| 4448 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 4449 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4450 | vc_conn.done; |
| 4451 | |
| 4452 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 4453 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 4454 | vc_conn.done; |
| 4455 | } |
| 4456 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 4457 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4458 | /*********************************************************************** |
| 4459 | * PCU Socket related tests |
| 4460 | ***********************************************************************/ |
| 4461 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4462 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4463 | 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] | 4464 | runs on test_CT { |
| 4465 | timer T := 3.0; |
| 4466 | |
| 4467 | /* we don't expect any RTS.req before PDCH are active */ |
| 4468 | T.start; |
| 4469 | alt { |
| 4470 | [] 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] | 4471 | 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] | 4472 | } |
| 4473 | [] PCU.receive { repeat; } |
| 4474 | [] T.timeout { } |
| 4475 | } |
| 4476 | |
| 4477 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4478 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4479 | |
| 4480 | /* we now expect RTS.req for this timeslot (only) */ |
| 4481 | T.start; |
| 4482 | alt { |
| 4483 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 4484 | setverdict(pass); |
| 4485 | } |
| 4486 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4487 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4488 | 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] | 4489 | } |
| 4490 | [] 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] | 4491 | 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] | 4492 | } |
| 4493 | [] PCU.receive { repeat; } |
| 4494 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4495 | 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] | 4496 | } |
| 4497 | [not exp_success] T.timeout { |
| 4498 | setverdict(pass); |
| 4499 | } |
| 4500 | } |
| 4501 | } |
| 4502 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4503 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4504 | 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] | 4505 | runs on test_CT { |
| 4506 | timer T := 3.0; |
| 4507 | |
| 4508 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4509 | 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] | 4510 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 4511 | * when it will actually have been executed in the BTS */ |
| 4512 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4513 | PCU.clear; |
| 4514 | /* we now expect no RTS.req for this timeslot */ |
| 4515 | T.start; |
| 4516 | alt { |
| 4517 | [] 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] | 4518 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4519 | } |
| 4520 | [] PCU.receive { repeat; } |
| 4521 | [] T.timeout { |
| 4522 | setverdict(pass); |
| 4523 | } |
| 4524 | } |
| 4525 | } |
| 4526 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4527 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4528 | f_init(); |
| 4529 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4530 | } |
| 4531 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4532 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4533 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4534 | f_init_pcu_test(); |
| 4535 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4536 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4537 | } |
| 4538 | |
| 4539 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4540 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4541 | f_init_pcu_test(); |
| 4542 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4543 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4544 | } |
| 4545 | |
| 4546 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4547 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4548 | f_init_pcu_test(); |
| 4549 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4550 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4551 | } |
| 4552 | |
| 4553 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4554 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4555 | f_init_pcu_test(); |
| 4556 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4557 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4558 | } |
| 4559 | |
| 4560 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4561 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4562 | f_init_pcu_test(); |
| 4563 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4564 | /* Activate PDCH */ |
| 4565 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4566 | f_sleep(1.0); |
| 4567 | /* and De-Activate again */ |
| 4568 | f_TC_pcu_deact_req(0, 0, 7); |
| 4569 | } |
| 4570 | |
| 4571 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4572 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4573 | f_init_pcu_test(); |
| 4574 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4575 | f_TC_pcu_deact_req(0, 0, 1); |
| 4576 | } |
| 4577 | |
| 4578 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4579 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4580 | const octetstring si13 := '00010203040506070909'O; |
| 4581 | var PCUIF_send_data sd; |
| 4582 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4583 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4584 | |
| 4585 | /* Set SI13 via RSL */ |
| 4586 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4587 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4588 | T.start; |
| 4589 | alt { |
| 4590 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4591 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4592 | setverdict(pass); |
| 4593 | } else { |
| 4594 | repeat; |
| 4595 | } |
| 4596 | } |
| 4597 | [] PCU.receive { repeat; } |
| 4598 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4599 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4600 | } |
| 4601 | } |
| 4602 | } |
| 4603 | |
| 4604 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4605 | |
| 4606 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4607 | 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] | 4608 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4609 | runs on test_CT |
| 4610 | { |
| 4611 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4612 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4613 | } |
| 4614 | |
| 4615 | /* 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] | 4616 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4617 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4618 | runs on test_CT |
| 4619 | { |
| 4620 | var PCUIF_send_data sd; |
| 4621 | |
| 4622 | timer T := 3.0; |
| 4623 | T.start; |
| 4624 | alt { |
| 4625 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4626 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4627 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4628 | sd.data.u.rts_req.fn, sapi, data); |
| 4629 | } |
| 4630 | [] PCU.receive { repeat; } |
| 4631 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4632 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4633 | } |
| 4634 | } |
| 4635 | } |
| 4636 | |
| 4637 | /* Send DATA.req on invalid BTS */ |
| 4638 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4639 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4640 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4641 | |
| 4642 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4643 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4644 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4645 | f_TfiUsfArrSet(tua, 7, 0); |
| 4646 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4647 | f_sleep(1.0); |
| 4648 | |
| 4649 | 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] | 4650 | } |
| 4651 | |
| 4652 | /* Send DATA.req on invalid TRX */ |
| 4653 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4654 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4655 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4656 | |
| 4657 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4658 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4659 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4660 | f_TfiUsfArrSet(tua, 7, 0); |
| 4661 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4662 | f_sleep(1.0); |
| 4663 | |
| 4664 | 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] | 4665 | } |
| 4666 | |
| 4667 | /* Send DATA.req on invalid timeslot */ |
| 4668 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4669 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4670 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4671 | |
| 4672 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4673 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4674 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4675 | f_TfiUsfArrSet(tua, 7, 0); |
| 4676 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4677 | f_sleep(1.0); |
| 4678 | |
| 4679 | 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] | 4680 | } |
| 4681 | |
| 4682 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4683 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4684 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4685 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4686 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4687 | f_virtphy_common(); |
| 4688 | |
| 4689 | f_TfiUsfArrSet(tua, 7, 0); |
| 4690 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4691 | f_sleep(1.0); |
| 4692 | |
| 4693 | 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] | 4694 | } |
| 4695 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4696 | 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] | 4697 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4698 | boolean wait_rts := true) |
| 4699 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4700 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4701 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4702 | |
| 4703 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4704 | if (wait_rts) { |
| 4705 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4706 | } else { |
| 4707 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4708 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4709 | |
| 4710 | T.start; |
| 4711 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4712 | [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] | 4713 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4714 | setverdict(pass); |
| 4715 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4716 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4717 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4718 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4719 | [] L1CTL.receive { |
| 4720 | repeat; |
| 4721 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4722 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4723 | setverdict(fail, "Timeout waiting for ", data); |
| 4724 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4725 | [not expect_data] T.timeout { |
| 4726 | setverdict(pass); |
| 4727 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4728 | } |
| 4729 | } |
| 4730 | |
| 4731 | private function f_disable_dynamic_ts() runs on test_CT |
| 4732 | { |
| 4733 | f_init_vty_bsc(); |
| 4734 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4735 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4736 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4737 | 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] | 4738 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4739 | } |
| 4740 | |
| 4741 | private function f_virtphy_common() runs on test_CT { |
| 4742 | f_disable_dynamic_ts(); |
| 4743 | f_init_l1ctl(); |
| 4744 | f_l1_tune(L1CTL); |
| 4745 | } |
| 4746 | |
| 4747 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4748 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4749 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4750 | |
| 4751 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4752 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4753 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4754 | f_TfiUsfArrSet(tua, 7, 0); |
| 4755 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4756 | f_sleep(1.0); |
| 4757 | |
| 4758 | 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] | 4759 | } |
| 4760 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4761 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4762 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4763 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4764 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4765 | |
| 4766 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4767 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4768 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4769 | f_TfiUsfArrSet(tua, 7, 0); |
| 4770 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4771 | f_sleep(1.0); |
| 4772 | |
| 4773 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4774 | } |
| 4775 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4776 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4777 | runs on test_CT { |
| 4778 | var template PCUIF_Message pcu_rach_ind; |
| 4779 | var PCUIF_send_data sd; |
| 4780 | var GsmFrameNumber fn; |
| 4781 | timer T; |
| 4782 | |
| 4783 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4784 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4785 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4786 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4787 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4788 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4789 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4790 | |
| 4791 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4792 | T.start(52.0 * 4.615 / 1000.0); |
| 4793 | alt { |
| 4794 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4795 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4796 | setverdict(pass); |
| 4797 | T.stop; |
| 4798 | } |
| 4799 | [] PCU.receive { repeat; } |
| 4800 | [] T.timeout { |
| 4801 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4802 | /* Keep going, that's not the end of the world */ |
| 4803 | } |
| 4804 | } |
| 4805 | } |
| 4806 | |
| 4807 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4808 | var L1ctlDlMessage dl; |
| 4809 | var octetstring data; |
| 4810 | timer T; |
| 4811 | |
| 4812 | f_init_pcu_test(); |
| 4813 | f_init_l1ctl(); |
| 4814 | f_l1_tune(L1CTL); |
| 4815 | |
| 4816 | /* Activate PDCH channel on TS7 */ |
| 4817 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4818 | |
| 4819 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4820 | 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] | 4821 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 4822 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 4823 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4824 | |
| 4825 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4826 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4827 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4828 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4829 | } |
| 4830 | |
| 4831 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4832 | data := f_rnd_octstring(23); |
| 4833 | |
| 4834 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4835 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4836 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4837 | |
| 4838 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4839 | * let's give it more time in case if we miss the beginning. */ |
| 4840 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4841 | alt { |
| 4842 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4843 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4844 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4845 | frame := data)) -> value dl { |
| 4846 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4847 | setverdict(pass); |
| 4848 | T.stop; |
| 4849 | } |
| 4850 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4851 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4852 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4853 | l2_data := data)) -> value dl { |
| 4854 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4855 | setverdict(pass); |
| 4856 | T.stop; |
| 4857 | } |
| 4858 | [] L1CTL.receive { repeat; } |
| 4859 | [] T.timeout { |
| 4860 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4861 | } |
| 4862 | } |
| 4863 | } |
| 4864 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4865 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4866 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4867 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4868 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4869 | f_init_l1ctl(); |
| 4870 | f_l1_tune(L1CTL); |
| 4871 | |
| 4872 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4873 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4874 | |
| 4875 | T.start; |
| 4876 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4877 | [] 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] | 4878 | setverdict(pass); |
| 4879 | } |
| 4880 | [] L1CTL.receive { repeat; } |
| 4881 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4882 | 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] | 4883 | } |
| 4884 | } |
| 4885 | } |
| 4886 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4887 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4888 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4889 | timer T := 3.0; |
| 4890 | f_init_pcu_test(); |
| 4891 | f_init_l1ctl(); |
| 4892 | f_l1_tune(L1CTL); |
| 4893 | |
| 4894 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4895 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4896 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4897 | |
| 4898 | T.start; |
| 4899 | alt { |
| 4900 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4901 | setverdict(pass); |
| 4902 | } |
| 4903 | [] L1CTL.receive { repeat; } |
| 4904 | [] T.timeout { |
| 4905 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4906 | } |
| 4907 | } |
| 4908 | } |
| 4909 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4910 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4911 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4912 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4913 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4914 | f_init_l1ctl(); |
| 4915 | f_l1_tune(L1CTL); |
| 4916 | |
| 4917 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4918 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4919 | |
| 4920 | timer T := 0.5; |
| 4921 | T.start; |
| 4922 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4923 | [] 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] | 4924 | /* TODO: verify paging group */ |
| 4925 | setverdict(pass); |
| 4926 | } |
| 4927 | [] L1CTL.receive { repeat; } |
| 4928 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4929 | 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] | 4930 | } |
| 4931 | } |
| 4932 | } |
| 4933 | |
| 4934 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4935 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4936 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4937 | f_init_l1ctl(); |
| 4938 | f_l1_tune(L1CTL); |
| 4939 | |
| 4940 | var GsmFrameNumber fn_last := 0; |
| 4941 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4942 | var OCT1 ra := f_rnd_ra_ps(); |
| 4943 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4944 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4945 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4946 | } |
| 4947 | fn_last := fn; |
| 4948 | |
| 4949 | timer T := 2.0; |
| 4950 | T.start; |
| 4951 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4952 | [] 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] | 4953 | T.stop; |
| 4954 | } |
| 4955 | [] 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] | 4956 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4957 | } |
| 4958 | [] PCU.receive { repeat; } |
| 4959 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4960 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4961 | } |
| 4962 | } |
| 4963 | } |
| 4964 | setverdict(pass); |
| 4965 | } |
| 4966 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4967 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4968 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4969 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4970 | var template PCUIF_Message pcu_rach_ind; |
| 4971 | var GsmFrameNumber fn_last := 0; |
| 4972 | var L1ctlRachSynchSeq synch_seq; |
| 4973 | var PCUIF_BurstType pcu_bt; |
| 4974 | var GsmFrameNumber fn; |
| 4975 | var BIT11 ra11; |
| 4976 | |
| 4977 | f_init_pcu_test(); |
| 4978 | f_init_l1ctl(); |
| 4979 | f_l1_tune(L1CTL); |
| 4980 | |
| 4981 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4982 | /* We need to test both TS1 & TS2 */ |
| 4983 | if (i rem 2 == 0) { |
| 4984 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4985 | pcu_bt := BURST_TYPE_1; |
| 4986 | } else { |
| 4987 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4988 | pcu_bt := BURST_TYPE_2; |
| 4989 | } |
| 4990 | |
| 4991 | ra11 := f_rnd_ra11_ps(); |
| 4992 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4993 | if (fn == fn_last) { |
| 4994 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4995 | "Two RACH in same FN?!?"); |
| 4996 | } |
| 4997 | fn_last := fn; |
| 4998 | |
| 4999 | /* Compose the expected message */ |
| 5000 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5001 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5002 | ra := bit2int(ra11), |
| 5003 | is_11bit := 1, |
| 5004 | burst_type := pcu_bt, |
| 5005 | fn := fn); |
| 5006 | |
| 5007 | timer T := 2.0; |
| 5008 | T.start; |
| 5009 | alt { |
| 5010 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5011 | T.stop; |
| 5012 | } |
| 5013 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5014 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5015 | } |
| 5016 | [] PCU.receive { repeat; } |
| 5017 | [] T.timeout { |
| 5018 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5019 | } |
| 5020 | } |
| 5021 | } |
| 5022 | setverdict(pass); |
| 5023 | } |
| 5024 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5025 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5026 | runs on test_CT { |
| 5027 | var template PCUIF_send_data sdt; |
| 5028 | var PCUIF_send_data sd; |
| 5029 | var int16_t lqual_cb; |
| 5030 | timer T := 1.0; |
| 5031 | |
| 5032 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5033 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5034 | |
| 5035 | /* Send a random PDTCH frame over Um */ |
| 5036 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5037 | '0000'O & f_rnd_octstring(21))); |
| 5038 | |
| 5039 | T.start; |
| 5040 | alt { |
| 5041 | /* If expected link quality is above the threshold */ |
| 5042 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5043 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5044 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5045 | |
| 5046 | /* Make sure the actual link quality matches the expected value */ |
| 5047 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5048 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5049 | "expected value ", lqual_cb_exp)); |
| 5050 | } else { |
| 5051 | setverdict(pass); |
| 5052 | } |
| 5053 | } |
| 5054 | /* If expected link quality is below the threshold */ |
| 5055 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5056 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5057 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5058 | } |
| 5059 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5060 | [] PCU.receive { repeat; } |
| 5061 | [lqual_cb_exp < thresh] T.timeout { |
| 5062 | log("Rx nothing, as expected"); |
| 5063 | setverdict(pass); |
| 5064 | } |
| 5065 | [lqual_cb_exp >= thresh] T.timeout { |
| 5066 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5067 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5068 | } |
| 5069 | } |
| 5070 | } |
| 5071 | |
| 5072 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5073 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 5074 | f_init_pcu_test(); |
| 5075 | PCU.clear; |
| 5076 | |
| 5077 | f_init_l1ctl(); |
| 5078 | f_l1_tune(L1CTL); |
| 5079 | |
| 5080 | /* Activate a PDCH channel on TS7 */ |
| 5081 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5082 | |
| 5083 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5084 | 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] | 5085 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5086 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5087 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5088 | |
| 5089 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5090 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5091 | var TrxcMessage ret; |
| 5092 | |
| 5093 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 5094 | valueof(ts_TRXC_FAKE_CI(i))); |
| 5095 | |
| 5096 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5097 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5098 | } |
| 5099 | } |
| 5100 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5101 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5102 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5103 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5104 | |
| 5105 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5106 | var MobileIdentityLV mi_lv; |
| 5107 | var octetstring mi_lv_enc; |
| 5108 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5109 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5110 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5111 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5112 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5113 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5114 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5115 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5116 | |
| 5117 | /* Fancy encoding for PCUIF */ |
| 5118 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5119 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5120 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5121 | |
| 5122 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5123 | 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] | 5124 | T.start; |
| 5125 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5126 | [] 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] | 5127 | } |
| 5128 | [] 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] | 5129 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5130 | } |
| 5131 | [] PCU.receive { repeat; } |
| 5132 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5134 | } |
| 5135 | } |
| 5136 | } |
| 5137 | setverdict(pass); |
| 5138 | } |
| 5139 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5140 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5141 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5142 | var PCUIF_send_data pcu_sd; |
| 5143 | var integer num_time_ind := 0; |
| 5144 | var integer first_fn, last_fn; |
| 5145 | var float test_duration := 5.0; |
| 5146 | timer T; |
| 5147 | |
| 5148 | f_init_pcu_test(); |
| 5149 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5150 | |
| 5151 | PCU.clear; |
| 5152 | T.start(test_duration); |
| 5153 | alt { |
| 5154 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5155 | num_time_ind := num_time_ind + 1; |
| 5156 | if (not isbound(first_fn)) { |
| 5157 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5158 | } |
| 5159 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5160 | repeat; |
| 5161 | } |
| 5162 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5163 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5164 | repeat; |
| 5165 | } |
| 5166 | [] PCU.receive { |
| 5167 | repeat; |
| 5168 | } |
| 5169 | [] T.timeout {} |
| 5170 | } |
| 5171 | var integer fn_expired := last_fn - first_fn; |
| 5172 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5173 | |
| 5174 | /* verify the number of frames expired matches our expectation */ |
| 5175 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5176 | 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] | 5177 | 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] | 5178 | if (not match(fn_expired, t_fn_expected)) { |
| 5179 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5180 | } |
| 5181 | |
| 5182 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5183 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5184 | /* Add some tolerance */ |
| 5185 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5186 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5187 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5188 | } |
| 5189 | |
| 5190 | setverdict(pass); |
| 5191 | } |
| 5192 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5193 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5194 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5195 | var PCUIF_send_data pcu_sd; |
| 5196 | var integer first_fn, last_fn; |
| 5197 | var integer num_rts_pdtch := 0; |
| 5198 | var integer num_rts_ptcch := 0; |
| 5199 | var float test_duration := 5.0; |
| 5200 | timer T; |
| 5201 | |
| 5202 | f_init_pcu_test(); |
| 5203 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5204 | |
| 5205 | PCU.clear; |
| 5206 | T.start(test_duration); |
| 5207 | alt { |
| 5208 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5209 | -> value pcu_sd { |
| 5210 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5211 | if (not isbound(first_fn)) { |
| 5212 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5213 | } |
| 5214 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5215 | repeat; |
| 5216 | } |
| 5217 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5218 | -> value pcu_sd { |
| 5219 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5220 | if (not isbound(first_fn)) { |
| 5221 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5222 | } |
| 5223 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5224 | repeat; |
| 5225 | } |
| 5226 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5227 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5228 | repeat; |
| 5229 | } |
| 5230 | [] PCU.receive { |
| 5231 | repeat; |
| 5232 | } |
| 5233 | [] T.timeout {} |
| 5234 | } |
| 5235 | var integer fn_expired := last_fn - first_fn; |
| 5236 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5237 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5238 | |
| 5239 | /* verify the number of frames expired matches our expectation */ |
| 5240 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5241 | 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] | 5242 | 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] | 5243 | if (not match(fn_expired, t_fn_expected)) { |
| 5244 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5245 | } |
| 5246 | |
| 5247 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5248 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5249 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5250 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5251 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5252 | t_ptcch_exp); |
| 5253 | } |
| 5254 | |
| 5255 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5256 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5257 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5258 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5259 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5260 | t_pdtch_exp); |
| 5261 | } |
| 5262 | |
| 5263 | setverdict(pass); |
| 5264 | } |
| 5265 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5266 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5267 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5268 | var PCUIF_send_data pcu_sd; |
| 5269 | var integer num_time_ind := 0; |
| 5270 | var integer first_fn, last_fn; |
| 5271 | var float test_duration := 5.0; |
| 5272 | timer T; |
| 5273 | |
| 5274 | f_init_pcu_test(); |
| 5275 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5276 | |
| 5277 | /* re-connect CTRL port from BTS to BSC */ |
| 5278 | f_ipa_ctrl_stop(); |
| 5279 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 5280 | |
| 5281 | /* Send that OML Alert */ |
| 5282 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5283 | |
| 5284 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5285 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5286 | setverdict(pass); |
| 5287 | } |
| 5288 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5289 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5290 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5291 | var PCUIF_Message first_info; |
| 5292 | var integer pcu_conn_id := -1; |
| 5293 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5294 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5295 | var OCT4 tlli := '01020304'O; |
| 5296 | var OCT1 cause := '23'O; |
| 5297 | timer T := 5.0; |
| 5298 | |
| 5299 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5300 | |
| 5301 | f_l1_tune(L1CTL); |
| 5302 | RSL.clear; |
| 5303 | |
| 5304 | f_est_dchan(); |
| 5305 | L1CTL.clear; |
| 5306 | |
| 5307 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5308 | |
| 5309 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5310 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5311 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5312 | |
| 5313 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5314 | T.start; |
| 5315 | alt { |
| 5316 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5317 | setverdict(pass); |
| 5318 | } |
| 5319 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5320 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 5321 | } |
| 5322 | [] PCU.receive { |
| 5323 | repeat; |
| 5324 | } |
| 5325 | [] T.timeout { |
| 5326 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 5327 | } |
| 5328 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 5329 | |
| 5330 | /* release the channel */ |
| 5331 | f_rsl_chan_deact(); |
| 5332 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5333 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5334 | } |
| 5335 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 5336 | var ConnHdlrPars pars; |
| 5337 | var ConnHdlr vc_conn; |
| 5338 | |
| 5339 | f_init(); |
| 5340 | |
| 5341 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 5342 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 5343 | vc_conn.done; |
| 5344 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5345 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 5346 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 5347 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 5348 | timer T := 5.0; |
| 5349 | |
| 5350 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5351 | f_init(); |
| 5352 | |
| 5353 | /* try to establish a second connection, expect it to fail */ |
| 5354 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 5355 | T.start; |
| 5356 | alt { |
| 5357 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 5358 | setverdict(pass); |
| 5359 | } |
| 5360 | [] PCU.receive(UD_connect_result:?) { |
| 5361 | setverdict(fail, "Unexpected unix domain connect result"); |
| 5362 | } |
| 5363 | [] T.timeout { |
| 5364 | setverdict(pass); |
| 5365 | } |
| 5366 | } |
| 5367 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5368 | } |
| 5369 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 5370 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 5371 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 5372 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5373 | f_init(); |
| 5374 | |
| 5375 | f_sleep(1.0); |
| 5376 | |
| 5377 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5378 | g_pcu_conn_id := -1; |
| 5379 | |
| 5380 | f_sleep(1.0); |
| 5381 | |
| 5382 | /* re-connect */ |
| 5383 | PCU.clear; |
| 5384 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5385 | setverdict(pass); |
| 5386 | |
| 5387 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5388 | } |
| 5389 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5390 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5391 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 5392 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5393 | var L1ctlDlMessage l1_dl; |
| 5394 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 5395 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5396 | timer T := 5.0; |
| 5397 | T.start; |
| 5398 | alt { |
| 5399 | [] 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] | 5400 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 5401 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5402 | repeat; |
| 5403 | } |
| 5404 | } |
| 5405 | [] pt.receive { |
| 5406 | repeat; |
| 5407 | } |
| 5408 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5409 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5410 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5411 | } |
| 5412 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 5413 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5414 | } |
| 5415 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5416 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 5417 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 5418 | runs on test_CT return boolean { |
| 5419 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 5420 | |
| 5421 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5422 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5423 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 5424 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5425 | } |
| 5426 | |
| 5427 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 5428 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5429 | } |
| 5430 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5431 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 5432 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 5433 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5434 | /* don't call f_init() as this would connect PCU socket */ |
| 5435 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5436 | |
| 5437 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5438 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5439 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5440 | |
| 5441 | f_init_l1ctl(); |
| 5442 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5443 | f_sleep(2.0); |
| 5444 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5445 | |
| 5446 | if (f_si_has_gprs_indicator(si_type)) { |
| 5447 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5448 | } else { |
| 5449 | setverdict(pass); |
| 5450 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5451 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5452 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5453 | } |
| 5454 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5455 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 5456 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5457 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5458 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5459 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 5460 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5461 | } |
| 5462 | |
| 5463 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 5464 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 5465 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5466 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5467 | f_init(); |
| 5468 | f_init_l1ctl(); |
| 5469 | f_l1_tune(L1CTL); |
| 5470 | |
| 5471 | f_sleep(2.0); |
| 5472 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5473 | |
| 5474 | if (not f_si_has_gprs_indicator(si_type)) { |
| 5475 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5476 | } else { |
| 5477 | setverdict(pass); |
| 5478 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5479 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5480 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5481 | } |
| 5482 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5483 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5484 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5485 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5486 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5487 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5488 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5489 | } |
| 5490 | |
| 5491 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5492 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5493 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5494 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5495 | f_init(); |
| 5496 | f_init_l1ctl(); |
| 5497 | f_l1_tune(L1CTL); |
| 5498 | |
| 5499 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5500 | g_pcu_conn_id := -1; |
| 5501 | |
| 5502 | f_sleep(1.0); |
| 5503 | |
| 5504 | /* re-connect */ |
| 5505 | PCU.clear; |
| 5506 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5507 | |
| 5508 | f_sleep(2.0); |
| 5509 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5510 | |
| 5511 | if (f_si_has_gprs_indicator(si_type)) { |
| 5512 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5513 | } else { |
| 5514 | setverdict(pass); |
| 5515 | } |
| 5516 | |
| 5517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5518 | } |
| 5519 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5520 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5521 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5522 | } |
| 5523 | |
| 5524 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5525 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5526 | } |
| 5527 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5528 | /* 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) */ |
| 5529 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5530 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5531 | |
| 5532 | f_init(); |
| 5533 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 5534 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 5535 | * information */ |
| 5536 | timer T := 2.0; |
| 5537 | T.start; |
| 5538 | alt { |
| 5539 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 5540 | [] T.timeout {} |
| 5541 | } |
| 5542 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5543 | /* Verify cell_id */ |
| 5544 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5545 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5546 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5547 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5548 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5549 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5550 | } |
| 5551 | |
| 5552 | /* Verify LAC */ |
| 5553 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5554 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5555 | if (lac_si3 != lac_pcu) { |
| 5556 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5557 | } |
| 5558 | |
| 5559 | setverdict(pass); |
| 5560 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5561 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5562 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 5563 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 5564 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5565 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5566 | |
| 5567 | f_init(); |
| 5568 | |
| 5569 | info_ind := g_pcu_last_info.u.info_ind; |
| 5570 | |
| 5571 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 5572 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
| 5573 | if (info_ind.trx.v10[i].pdch_mask[tn] != '1'B) { |
| 5574 | /* Skip inactive timeslots */ |
| 5575 | continue; |
| 5576 | } |
| 5577 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5578 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 5579 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5580 | else |
| 5581 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5582 | |
| 5583 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5584 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5585 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5586 | hsn := fhp.maio_hsn.hsn, |
| 5587 | maio := fhp.maio_hsn.maio, |
| 5588 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 5589 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 5590 | } else { |
| 5591 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 5592 | } |
| 5593 | |
| 5594 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[i].ts[tn]; |
| 5595 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 5596 | if (not match(ts, tr_ts)) { |
| 5597 | setverdict(fail, "Hopping parameters do not match: ", |
| 5598 | "received ", ts, " vs expected ", tr_ts); |
| 5599 | } else { |
| 5600 | setverdict(pass); |
| 5601 | } |
| 5602 | } |
| 5603 | } |
| 5604 | } |
| 5605 | |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 5606 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5607 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 5608 | f_init_vty_bsc(); |
| 5609 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 5610 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 5611 | |
| 5612 | f_init(); |
| 5613 | |
| 5614 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5615 | if (not ischosen(remote_addr.v10)) { |
| 5616 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5617 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5618 | } |
| 5619 | |
| 5620 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV4) { |
| 5621 | setverdict(fail, "Received address family is not IPv4"); |
| 5622 | } |
| 5623 | |
| 5624 | if (substr(remote_addr.v10.addr[0], 0, 4) != f_inet_addr("127.127.127.127")) { |
| 5625 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5626 | } |
| 5627 | |
| 5628 | setverdict(pass); |
| 5629 | } |
| 5630 | |
| 5631 | /* Verify IPv4 NSVC address in the INFO.ind message (version >= 10) */ |
| 5632 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 5633 | f_init_vty_bsc(); |
| 5634 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 5635 | |
| 5636 | f_init(); |
| 5637 | |
| 5638 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
| 5639 | if (not ischosen(remote_addr.v10)) { |
| 5640 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5641 | log2str("Unexpected remote_addr: ", remote_addr)); |
| 5642 | } |
| 5643 | |
| 5644 | if (remote_addr.v10.addr_type[0] != PCUIF_ADDR_TYPE_IPV6) { |
| 5645 | setverdict(fail, "Received address family is not IPv6"); |
| 5646 | } |
| 5647 | |
| 5648 | if (remote_addr.v10.addr[0] != f_inet6_addr("fd00::ca:ff:ee")) { |
| 5649 | setverdict(fail, "Unexpected address: ", remote_addr.v10.addr[0]); |
| 5650 | } |
| 5651 | |
| 5652 | setverdict(pass); |
| 5653 | } |
| 5654 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5655 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5656 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5657 | ***********************************************************************/ |
| 5658 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5659 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 5660 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5661 | runs on ConnHdlr { |
| 5662 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5663 | |
| 5664 | [] 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] | 5665 | 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] | 5666 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 5667 | repeat; |
| 5668 | } |
| 5669 | } |
| 5670 | } |
| 5671 | |
| 5672 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5673 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5674 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5675 | PCU.clear; |
| 5676 | f_rsl_chan_act(g_pars.chan_mode); |
| 5677 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5678 | timer T_wait := 2.0; |
| 5679 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5680 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5681 | [] 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] | 5682 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5683 | [] T_wait.timeout { |
| 5684 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5685 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5686 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5687 | } |
| 5688 | /* try to activate this PDCH from the PCU point of view */ |
| 5689 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5690 | /* FIXME: is there a response? */ |
| 5691 | } |
| 5692 | |
| 5693 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5694 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5695 | /* Send RSL CHAN REL (deactivate) */ |
| 5696 | PCU.clear; |
| 5697 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5698 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5699 | timer T_wait := 2.0; |
| 5700 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5701 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5702 | [] 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] | 5703 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5704 | [] T_wait.timeout { |
| 5705 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5706 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5707 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5708 | } |
| 5709 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5710 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5711 | alt { |
| 5712 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5713 | setverdict(pass); |
| 5714 | } |
| 5715 | [] RSL.receive { repeat; } |
| 5716 | } |
| 5717 | } |
| 5718 | |
| 5719 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5720 | 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] | 5721 | var PCUIF_Message first_info; |
| 5722 | var integer ts_nr := g_chan_nr.tn; |
| 5723 | var integer trx_nr := 0; |
| 5724 | var integer bts_nr := 0; |
| 5725 | var integer pcu_conn_id := -1; |
| 5726 | |
| 5727 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5728 | |
| 5729 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5730 | f_sleep(3.0); |
| 5731 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5732 | setverdict(pass); |
| 5733 | } |
| 5734 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5735 | var ConnHdlrPars pars; |
| 5736 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5737 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5738 | |
| 5739 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5740 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5741 | vc_conn.done; |
| 5742 | } |
| 5743 | |
| 5744 | /* 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] | 5745 | 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] | 5746 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5747 | var integer pcu_conn_id := -1; |
| 5748 | |
| 5749 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5750 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5751 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5752 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5753 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5754 | setverdict(pass); |
| 5755 | } |
| 5756 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5757 | var ConnHdlrPars pars; |
| 5758 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5759 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5760 | |
| 5761 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5762 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5763 | vc_conn.done; |
| 5764 | } |
| 5765 | |
| 5766 | /* 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] | 5767 | 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] | 5768 | var PCUIF_Message first_info; |
| 5769 | var integer ts_nr := g_chan_nr.tn; |
| 5770 | var integer trx_nr := 0; |
| 5771 | var integer bts_nr := 0; |
| 5772 | var integer pcu_conn_id := -1; |
| 5773 | |
| 5774 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5775 | |
| 5776 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5777 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5778 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5779 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5780 | setverdict(pass); |
| 5781 | } |
| 5782 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5783 | var ConnHdlrPars pars; |
| 5784 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5785 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5786 | |
| 5787 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5788 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5789 | vc_conn.done; |
| 5790 | } |
| 5791 | |
| 5792 | /* 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] | 5793 | 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] | 5794 | var PCUIF_Message first_info; |
| 5795 | var integer ts_nr := g_chan_nr.tn; |
| 5796 | var integer trx_nr := 0; |
| 5797 | var integer bts_nr := 0; |
| 5798 | var integer pcu_conn_id := -1; |
| 5799 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5800 | |
| 5801 | /* register for the TCH/F channel number */ |
| 5802 | f_rslem_register(0, chan_nr); |
| 5803 | |
| 5804 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5805 | |
| 5806 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5807 | "RSL CHAN ACT"); |
| 5808 | setverdict(pass); |
| 5809 | } |
| 5810 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5811 | var ConnHdlrPars pars; |
| 5812 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5813 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5814 | |
| 5815 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5816 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5817 | vc_conn.done; |
| 5818 | } |
| 5819 | |
| 5820 | /* 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] | 5821 | 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] | 5822 | var PCUIF_Message first_info; |
| 5823 | var integer ts_nr := g_chan_nr.tn; |
| 5824 | var integer trx_nr := 0; |
| 5825 | var integer bts_nr := 0; |
| 5826 | var integer pcu_conn_id := -1; |
| 5827 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5828 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5829 | |
| 5830 | /* register for the TCH/H channel numbers */ |
| 5831 | f_rslem_register(0, chan_nr[0]); |
| 5832 | f_rslem_register(0, chan_nr[1]); |
| 5833 | |
| 5834 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5835 | |
| 5836 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5837 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5838 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5839 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5840 | setverdict(pass); |
| 5841 | } |
| 5842 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5843 | var ConnHdlrPars pars; |
| 5844 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5845 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5846 | |
| 5847 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5848 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5849 | vc_conn.done; |
| 5850 | } |
| 5851 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5852 | /*********************************************************************** |
| 5853 | * IPA Style Dynamic Timeslot Support |
| 5854 | ***********************************************************************/ |
| 5855 | |
| 5856 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5857 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5858 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5859 | PCU.clear; |
| 5860 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5861 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5862 | timer T_wait := 2.0; |
| 5863 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5864 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5865 | [] 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] | 5866 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5867 | [] T_wait.timeout { |
| 5868 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5869 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5870 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5871 | } |
| 5872 | /* try to activate this PDCH from the PCU point of view */ |
| 5873 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5874 | /* FIXME: is there a response? */ |
| 5875 | |
| 5876 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5877 | } |
| 5878 | |
| 5879 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5880 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5881 | /* Send RSL CHAN REL (deactivate) */ |
| 5882 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5883 | PCU.clear; |
| 5884 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5885 | timer T_wait := 2.0; |
| 5886 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5887 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 5888 | [] 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] | 5889 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5890 | [] T_wait.timeout { |
| 5891 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5892 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5893 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5894 | } |
| 5895 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5896 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5897 | alt { |
| 5898 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5899 | setverdict(pass); |
| 5900 | } |
| 5901 | [] RSL.receive { repeat; } |
| 5902 | } |
| 5903 | } |
| 5904 | |
| 5905 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5906 | 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] | 5907 | var PCUIF_Message first_info; |
| 5908 | var integer ts_nr := g_chan_nr.tn; |
| 5909 | var integer trx_nr := 0; |
| 5910 | var integer bts_nr := 0; |
| 5911 | var integer pcu_conn_id := -1; |
| 5912 | |
| 5913 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5914 | |
| 5915 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5916 | f_sleep(3.0); |
| 5917 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5918 | |
| 5919 | setverdict(pass); |
| 5920 | |
| 5921 | } |
| 5922 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5923 | var ConnHdlrPars pars; |
| 5924 | var ConnHdlr vc_conn; |
| 5925 | f_init(); |
| 5926 | |
| 5927 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5928 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5929 | vc_conn.done; |
| 5930 | } |
| 5931 | |
| 5932 | /* 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] | 5933 | 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] | 5934 | var PCUIF_Message first_info; |
| 5935 | var integer ts_nr := g_chan_nr.tn; |
| 5936 | var integer trx_nr := 0; |
| 5937 | var integer bts_nr := 0; |
| 5938 | var integer pcu_conn_id := -1; |
| 5939 | |
| 5940 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5941 | |
| 5942 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5943 | "RSL CHAN ACT"); |
| 5944 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5945 | "RF CHAN REL", true); |
| 5946 | setverdict(pass); |
| 5947 | } |
| 5948 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5949 | var ConnHdlrPars pars; |
| 5950 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5951 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5952 | |
| 5953 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5954 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5955 | vc_conn.done; |
| 5956 | } |
| 5957 | |
| 5958 | /* 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] | 5959 | 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] | 5960 | var PCUIF_Message first_info; |
| 5961 | var integer ts_nr := g_chan_nr.tn; |
| 5962 | var integer trx_nr := 0; |
| 5963 | var integer bts_nr := 0; |
| 5964 | var integer pcu_conn_id := -1; |
| 5965 | |
| 5966 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5967 | |
| 5968 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5969 | "RSL CHAN ACT"); |
| 5970 | |
| 5971 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5972 | alt { |
| 5973 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5974 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5976 | } |
| 5977 | [] RSL.receive { repeat; } |
| 5978 | } |
| 5979 | |
| 5980 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5981 | "RF CHAN REL", true); |
| 5982 | setverdict(pass); |
| 5983 | } |
| 5984 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5985 | var ConnHdlrPars pars; |
| 5986 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5987 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5988 | |
| 5989 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5990 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5991 | vc_conn.done; |
| 5992 | } |
| 5993 | |
| 5994 | /* 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] | 5995 | 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] | 5996 | var PCUIF_Message first_info; |
| 5997 | var integer ts_nr := g_chan_nr.tn; |
| 5998 | var integer trx_nr := 0; |
| 5999 | var integer bts_nr := 0; |
| 6000 | var integer pcu_conn_id := -1; |
| 6001 | |
| 6002 | /* register for the TCH/F channel number */ |
| 6003 | f_rslem_register(0, g_chan_nr); |
| 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 | |
| 6009 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6010 | "RSL CHAN ACT"); |
| 6011 | |
| 6012 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6013 | |
| 6014 | setverdict(pass); |
| 6015 | } |
| 6016 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6017 | var ConnHdlrPars pars; |
| 6018 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6019 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6020 | |
| 6021 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6022 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6023 | vc_conn.done; |
| 6024 | } |
| 6025 | |
| 6026 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6027 | /*********************************************************************** |
| 6028 | * LAPDm / RLL related |
| 6029 | ***********************************************************************/ |
| 6030 | |
| 6031 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6032 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6033 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6034 | var template (value) SacchL1Header l1h; |
| 6035 | |
| 6036 | /* 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] | 6037 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6038 | /* Compose dummy L1 header */ |
| 6039 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 6040 | 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] | 6041 | } else { |
| 6042 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6043 | 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] | 6044 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6045 | } |
| 6046 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6047 | private type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6048 | uint3_t sapi, |
| 6049 | RslLinkId link_id, |
| 6050 | octetstring l3, |
| 6051 | boolean exp |
| 6052 | } |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6053 | private type record of RllTestCase RllTestCases; |
| 6054 | private template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, |
| 6055 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6056 | sapi := sapi, |
| 6057 | link_id := id, |
| 6058 | l3 := l3, |
| 6059 | exp := exp |
| 6060 | } |
| 6061 | |
| 6062 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6063 | * variety of logical channels */ |
| 6064 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6065 | var ConnHdlrPars pars; |
| 6066 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6067 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6068 | |
| 6069 | /* test on each of the channels we have */ |
| 6070 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6071 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6072 | |
| 6073 | /* test each of the test cases on the current channel */ |
| 6074 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6075 | pars.spec.rll := tcs[j]; |
| 6076 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6077 | vc_conn := f_start_handler(fn, pars); |
| 6078 | vc_conn.done; |
| 6079 | } |
| 6080 | } |
| 6081 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6083 | } |
| 6084 | |
| 6085 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6086 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6087 | var RllTestCase tc := g_pars.spec.rll; |
| 6088 | timer T := 3.0; |
| 6089 | |
| 6090 | f_l1_tune(L1CTL); |
| 6091 | RSL.clear; |
| 6092 | |
| 6093 | /* activate the logical channel */ |
| 6094 | f_est_dchan(); |
| 6095 | L1CTL.clear; |
| 6096 | |
| 6097 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6098 | T.start; |
| 6099 | alt { |
| 6100 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6101 | if (tc.exp) { |
| 6102 | setverdict(pass); |
| 6103 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6104 | 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] | 6105 | } |
| 6106 | } |
| 6107 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6108 | if (tc.exp) { |
| 6109 | setverdict(pass); |
| 6110 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6111 | 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] | 6112 | } |
| 6113 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6114 | /* We also expect to receive the measurements */ |
| 6115 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6116 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6117 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6118 | } |
| 6119 | [not tc.exp] T.timeout { |
| 6120 | setverdict(pass); |
| 6121 | } |
| 6122 | } |
| 6123 | |
| 6124 | f_rsl_chan_deact(); |
| 6125 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6126 | f_rslem_unregister(0, g_chan_nr); |
| 6127 | } |
| 6128 | testcase TC_rll_est_ind() runs on test_CT { |
| 6129 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6130 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6131 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 6132 | /* normal SAPI0 establishment */ |
| 6133 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6134 | /* SAPI 3 doesn't support contention resolution */ |
| 6135 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 6136 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 6137 | /* normal SAPI3 establishment on main DCCH */ |
| 6138 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6139 | /* normal SAPI3 establishment on SACCH */ |
| 6140 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6141 | }; |
| 6142 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 6143 | } |
| 6144 | |
| 6145 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 6146 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 6147 | var RllTestCase tc := g_pars.spec.rll; |
| 6148 | var L1ctlDlMessage dl; |
| 6149 | timer T := 3.0; |
| 6150 | |
| 6151 | f_l1_tune(L1CTL); |
| 6152 | RSL.clear; |
| 6153 | |
| 6154 | /* activate the logical channel */ |
| 6155 | f_est_dchan(); |
| 6156 | L1CTL.clear; |
| 6157 | |
| 6158 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 6159 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 6160 | T.start; |
| 6161 | alt { |
| 6162 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6163 | var LapdmFrame lapdm; |
| 6164 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6165 | if (dl.dl_info.link_id.c == SACCH) { |
| 6166 | /* remove L1 header */ |
| 6167 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6168 | } |
| 6169 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6170 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 6171 | setverdict(pass); |
| 6172 | } else { |
| 6173 | repeat; |
| 6174 | } |
| 6175 | } |
| 6176 | [] L1CTL.receive { repeat; } |
| 6177 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6178 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6179 | } |
| 6180 | } |
| 6181 | |
| 6182 | f_rsl_chan_deact(); |
| 6183 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6184 | f_rslem_unregister(0, g_chan_nr); |
| 6185 | } |
| 6186 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 6187 | var RllTestCases tcs := { |
| 6188 | /* normal SAPI3 establishment on main DCCH */ |
| 6189 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 6190 | }; |
| 6191 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6192 | } |
| 6193 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 6194 | var RllTestCases tcs := { |
| 6195 | /* normal SAPI3 establishment on SACCH */ |
| 6196 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6197 | } |
| 6198 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 6199 | } |
| 6200 | |
| 6201 | /* altstep to receive a LAPDm frame matching the given template */ |
| 6202 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 6203 | var L1ctlDlMessage dl; |
| 6204 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6205 | var LapdmFrame lapdm; |
| 6206 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6207 | if (dl.dl_info.link_id.c == SACCH) { |
| 6208 | /* remove L1 header */ |
| 6209 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 6210 | } |
| 6211 | if (ischosen(exp.ab)) { |
| 6212 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 6213 | } else if (ischosen(exp.b4)) { |
| 6214 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 6215 | } else if (ischosen(exp.bbis)) { |
| 6216 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 6217 | } |
| 6218 | log("Rx LAPDm ", lapdm); |
| 6219 | if (match(lapdm, exp)) { |
| 6220 | setverdict(pass); |
| 6221 | } else { |
| 6222 | repeat; |
| 6223 | } |
| 6224 | } |
| 6225 | [] L1CTL.receive { repeat; } |
| 6226 | } |
| 6227 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 6228 | timer T := t; |
| 6229 | T.start; |
| 6230 | alt { |
| 6231 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6232 | 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] | 6233 | } |
| 6234 | [] as_l1_exp_lapdm(exp); |
| 6235 | } |
| 6236 | } |
| 6237 | |
| 6238 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 6239 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 6240 | /* send SABM from MS -> BTS */ |
| 6241 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 6242 | /* expect RLL EST IND on Abis */ |
| 6243 | alt { |
| 6244 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 6245 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 6246 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6247 | 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] | 6248 | } |
| 6249 | [] RSL.receive { repeat; } |
| 6250 | } |
| 6251 | /* expect UA from BTS -> MS */ |
| 6252 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 6253 | } |
| 6254 | |
| 6255 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 6256 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 6257 | var RllTestCase tc := g_pars.spec.rll; |
| 6258 | |
| 6259 | f_l1_tune(L1CTL); |
| 6260 | RSL.clear; |
| 6261 | |
| 6262 | /* activate the logical channel */ |
| 6263 | f_est_dchan(); |
| 6264 | L1CTL.clear; |
| 6265 | |
| 6266 | /* first establish the link-layer */ |
| 6267 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6268 | |
| 6269 | /* then send the DISC */ |
| 6270 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 6271 | /* ... and expect the REL IND on the RSL side */ |
| 6272 | alt { |
| 6273 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 6274 | setverdict(pass); |
| 6275 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 6276 | /* We also expect to receive the measurements */ |
| 6277 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6278 | } |
| 6279 | |
| 6280 | /* release the channel */ |
| 6281 | f_rsl_chan_deact(); |
| 6282 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6283 | f_rslem_unregister(0, g_chan_nr); |
| 6284 | } |
| 6285 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 6286 | var RllTestCases tcs := { |
| 6287 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 6288 | }; |
| 6289 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6290 | } |
| 6291 | |
| 6292 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 6293 | var RllTestCases tcs := { |
| 6294 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 6295 | }; |
| 6296 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6297 | } |
| 6298 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 6299 | var RllTestCases tcs := { |
| 6300 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 6301 | }; |
| 6302 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6303 | } |
| 6304 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 6305 | var RllTestCases tcs := { |
| 6306 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6307 | }; |
| 6308 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 6309 | } |
| 6310 | |
| 6311 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 6312 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 6313 | var RllTestCase tc := g_pars.spec.rll; |
| 6314 | f_l1_tune(L1CTL); |
| 6315 | RSL.clear; |
| 6316 | |
| 6317 | /* activate the logical channel */ |
| 6318 | f_est_dchan(); |
| 6319 | L1CTL.clear; |
| 6320 | |
| 6321 | /* first establish the link-layer */ |
| 6322 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 6323 | |
| 6324 | /* then send the REL REQ via RSL */ |
| 6325 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 6326 | /* ... and expect the DISC on the Um side */ |
| 6327 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 6328 | [] 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] | 6329 | /* FIXME: send a UA in resposne to the DISC */ |
| 6330 | } |
| 6331 | } |
| 6332 | |
| 6333 | /* release the channel */ |
| 6334 | f_rsl_chan_deact(); |
| 6335 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6336 | f_rslem_unregister(0, g_chan_nr); |
| 6337 | } |
| 6338 | testcase TC_rll_rel_req() runs on test_CT { |
| 6339 | var RllTestCases tcs := { |
| 6340 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 6341 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 6342 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 6343 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 6344 | }; |
| 6345 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 6346 | } |
| 6347 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6348 | /* 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] | 6349 | testcase TC_rll_data_req() runs on test_CT { |
| 6350 | } |
| 6351 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 6352 | /* 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] | 6353 | testcase TC_rll_data_ind() runs on test_CT { |
| 6354 | } |
| 6355 | |
| 6356 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 6357 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 6358 | var RllTestCase tc := g_pars.spec.rll; |
| 6359 | |
| 6360 | f_l1_tune(L1CTL); |
| 6361 | RSL.clear; |
| 6362 | |
| 6363 | f_est_dchan(); |
| 6364 | L1CTL.clear; |
| 6365 | |
| 6366 | /* Send UNITDATA REQ on RSL side */ |
| 6367 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 6368 | /* Expect it to arrive on the other side */ |
| 6369 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6370 | 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] | 6371 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6372 | 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] | 6373 | } |
| 6374 | |
| 6375 | /* release the channel */ |
| 6376 | f_rsl_chan_deact(); |
| 6377 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6378 | f_rslem_unregister(0, g_chan_nr); |
| 6379 | } |
| 6380 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 6381 | var octetstring l3 := f_rnd_octstring(15); |
| 6382 | var RllTestCases tcs := { |
| 6383 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6384 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6385 | }; |
| 6386 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6387 | } |
| 6388 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 6389 | var octetstring l3 := f_rnd_octstring(19); |
| 6390 | var RllTestCases tcs := { |
| 6391 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6392 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6393 | }; |
| 6394 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 6395 | } |
| 6396 | |
| 6397 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 6398 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 6399 | var RllTestCase tc := g_pars.spec.rll; |
| 6400 | |
| 6401 | f_l1_tune(L1CTL); |
| 6402 | RSL.clear; |
| 6403 | |
| 6404 | f_est_dchan(); |
| 6405 | L1CTL.clear; |
| 6406 | |
| 6407 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6408 | 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] | 6409 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 6410 | alt { |
| 6411 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6412 | setverdict(pass); |
| 6413 | } |
| 6414 | [] RSL.receive { repeat; } |
| 6415 | } |
| 6416 | |
| 6417 | /* release the channel */ |
| 6418 | f_rsl_chan_deact(); |
| 6419 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6420 | f_rslem_unregister(0, g_chan_nr); |
| 6421 | } |
| 6422 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 6423 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6424 | var RllTestCases tcs := { |
| 6425 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 6426 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 6427 | }; |
| 6428 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6429 | } |
| 6430 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 6431 | var octetstring l3 := f_rnd_octstring(18); |
| 6432 | var RllTestCases tcs := { |
| 6433 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 6434 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 6435 | }; |
| 6436 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 6437 | } |
| 6438 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6439 | /*********************************************************************** |
| 6440 | * Encryption Related |
| 6441 | ***********************************************************************/ |
| 6442 | |
| 6443 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 6444 | 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] | 6445 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 6446 | if (link_id.c == SACCH) { |
| 6447 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6448 | } else { |
| 6449 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 6450 | } |
| 6451 | } |
| 6452 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6453 | /* Expect (or not expect) other kinds of messages */ |
| 6454 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 6455 | [exp_any] RSL.receive { repeat; } |
| 6456 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6457 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6458 | } |
| 6459 | } |
| 6460 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6461 | /* 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] | 6462 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6463 | RslLinkId link_id, |
| 6464 | octetstring l3, |
| 6465 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6466 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 6467 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6468 | timer T := 3.0; |
| 6469 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 6470 | T.start; |
| 6471 | /* Expect RLL UNITDATA IND on RSL side */ |
| 6472 | alt { |
| 6473 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 6474 | setverdict(pass); |
| 6475 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6476 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 6477 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6478 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6479 | 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] | 6480 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6481 | } |
| 6482 | } |
| 6483 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6484 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 6485 | private function f_data_mo( |
| 6486 | RslLinkId link_id, |
| 6487 | boolean p, uint3_t nr, uint3_t ns, |
| 6488 | octetstring l3, |
| 6489 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 6490 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6491 | ) runs on ConnHdlr { |
| 6492 | timer T := 3.0; |
| 6493 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 6494 | T.start; |
| 6495 | /* Expect RLL DATA IND on RSL side */ |
| 6496 | alt { |
| 6497 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 6498 | setverdict(pass); |
| 6499 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 6500 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6501 | [] as_rsl_any_ind(exp_any); |
| 6502 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6503 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6504 | } |
| 6505 | } |
| 6506 | } |
| 6507 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6508 | /* 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] | 6509 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6510 | f_l1_tune(L1CTL); |
| 6511 | f_est_dchan(true); |
| 6512 | |
| 6513 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6514 | var L1ctlDlMessage dl; |
| 6515 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 6516 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6517 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6518 | |
| 6519 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6520 | f_unitdata_mt(link_id, l3); |
| 6521 | |
| 6522 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6523 | f_unitdata_mo(link_id, l3); |
| 6524 | |
| 6525 | /* release the channel */ |
| 6526 | f_rsl_chan_deact(); |
| 6527 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6528 | f_rslem_unregister(0, g_chan_nr); |
| 6529 | } |
| 6530 | testcase TC_chan_act_a51() runs on test_CT { |
| 6531 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6532 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6533 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6534 | } |
| 6535 | testcase TC_chan_act_a52() runs on test_CT { |
| 6536 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6537 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6538 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6539 | } |
| 6540 | testcase TC_chan_act_a53() runs on test_CT { |
| 6541 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6542 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6543 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 6544 | } |
| 6545 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6546 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 6547 | 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] | 6548 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6549 | f_l1_tune(L1CTL); |
| 6550 | f_est_dchan(true); |
| 6551 | |
| 6552 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 6553 | var L1ctlDlMessage dl; |
| 6554 | |
| 6555 | var octetstring l3 := f_rnd_octstring(20); |
| 6556 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6557 | |
| 6558 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 6559 | f_unitdata_mt(link_id, l3); |
| 6560 | |
| 6561 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 6562 | f_unitdata_mo(link_id, l3); |
| 6563 | |
| 6564 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6565 | 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] | 6566 | |
| 6567 | /* modify key to break proper encryption */ |
| 6568 | g_pars.encr.key := f_rnd_octstring(8); |
| 6569 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6570 | rsl.ies := rsl.ies & { ei }; |
| 6571 | RSL.send(rsl); |
| 6572 | |
| 6573 | timer T0 := 1.0; |
| 6574 | T0.start; |
| 6575 | /* Expect RSL MODIFY ACK */ |
| 6576 | alt { |
| 6577 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6578 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6579 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6580 | } |
| 6581 | [] T0.timeout { |
| 6582 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6583 | } |
| 6584 | } |
| 6585 | |
| 6586 | var octetstring l3msg := f_rnd_octstring(15); |
| 6587 | timer T1 := 3.0; |
| 6588 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6589 | due to broken encryption */ |
| 6590 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6591 | T1.start; |
| 6592 | alt { |
| 6593 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6594 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6595 | } |
| 6596 | [] T1.timeout { |
| 6597 | setverdict(pass); |
| 6598 | } |
| 6599 | } |
| 6600 | |
| 6601 | /* release the channel */ |
| 6602 | f_rsl_chan_deact(); |
| 6603 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6604 | f_rslem_unregister(0, g_chan_nr); |
| 6605 | } |
| 6606 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6607 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6608 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6609 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6610 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6611 | |
| 6612 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6613 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6614 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6615 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6616 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6617 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6618 | |
| 6619 | f_l1_tune(L1CTL); |
| 6620 | |
| 6621 | /* first establish a dedicated channel in the clear */ |
| 6622 | f_est_dchan(false); |
| 6623 | |
| 6624 | /* Establish ABM */ |
| 6625 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6626 | |
| 6627 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6628 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6629 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6630 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6631 | |
| 6632 | /* configure L1 to apply ciphering */ |
| 6633 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6634 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6635 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6636 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6637 | 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] | 6638 | |
| 6639 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6640 | * and hence enable encryption also on the downlink */ |
| 6641 | |
| 6642 | /* expect bi-directional communication work in encrypted mode */ |
| 6643 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6644 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6645 | |
| 6646 | /* release the channel */ |
| 6647 | f_rsl_chan_deact(); |
| 6648 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6649 | f_rslem_unregister(0, g_chan_nr); |
| 6650 | } |
| 6651 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6652 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6653 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6654 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6655 | } |
| 6656 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6657 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6658 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6659 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6660 | } |
| 6661 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6662 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6663 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6664 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6665 | } |
| 6666 | |
| 6667 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6668 | var LapdmFrame lf; |
| 6669 | var octetstring reenc; |
| 6670 | |
| 6671 | /* decode the LAPDm frame */ |
| 6672 | if (ischosen(exp_match.ab)) { |
| 6673 | lf.ab := dec_LapdmFrameAB(enc); |
| 6674 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6675 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6676 | } |
| 6677 | |
| 6678 | /* check if decoder result matches expectation */ |
| 6679 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6680 | 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] | 6681 | } else { |
| 6682 | log(name, ": matched"); |
| 6683 | setverdict(pass); |
| 6684 | } |
| 6685 | |
| 6686 | /* test if re-encoded frame equals original input */ |
| 6687 | reenc := enc_LapdmFrame(lf); |
| 6688 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6689 | 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] | 6690 | } else { |
| 6691 | setverdict(pass); |
| 6692 | } |
| 6693 | } |
| 6694 | |
| 6695 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6696 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6697 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6698 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6699 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6700 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6701 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6702 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6703 | } |
| 6704 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6705 | /*********************************************************************** |
| 6706 | * DTX Related (see GSM 05.08, section 8.3) |
| 6707 | ***********************************************************************/ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6708 | private function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6709 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6710 | var GsmFrameNumber first_fn; |
| 6711 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6712 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6713 | 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] | 6714 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6715 | 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] | 6716 | const integer frame_dtx_tchf_mod := 104; |
| 6717 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6718 | * which operates in terms of blocks rather than frames. */ |
| 6719 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6720 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6721 | timer T := 5.0; |
| 6722 | |
| 6723 | f_l1_tune(L1CTL); |
| 6724 | RSL.clear; |
| 6725 | L1CTL.clear; |
| 6726 | |
| 6727 | /* activate TCHF signalling channel */ |
| 6728 | f_est_dchan(false); |
| 6729 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6730 | /* A template for matching dummy LAPDm func=UA frames */ |
| 6731 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 6732 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 6733 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 6734 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6735 | T.start; |
| 6736 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6737 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6738 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6739 | |
| 6740 | if (is_first_frame) { |
| 6741 | is_first_frame := false; |
| 6742 | first_fn := dl.dl_info.frame_nr; |
| 6743 | } |
| 6744 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6745 | if (dtxd) { |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6746 | if (not match(g_chan_nr, t_RslChanNr_Bm(?))) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6747 | T.stop; |
| 6748 | f_rsl_chan_deact(); |
| 6749 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6750 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6751 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6752 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6753 | T.stop; |
| 6754 | f_rsl_chan_deact(); |
| 6755 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6756 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6757 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 6758 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6759 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6760 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame^] | 6761 | setverdict(fail, "Not enough fill frames received: ", |
| 6762 | nfill_frames, " out of ", expected_fill_frames); |
| 6763 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6764 | } else { |
| 6765 | setverdict(pass); |
| 6766 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6767 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6768 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6769 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6770 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6771 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6772 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6773 | 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] | 6774 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6775 | repeat; |
| 6776 | } |
| 6777 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame^] | 6778 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 6779 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6780 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6781 | f_rsl_chan_deact(); |
| 6782 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6783 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6784 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6785 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6786 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6787 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6788 | |
| 6789 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6790 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 6791 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6792 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 6793 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 6794 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6795 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 6796 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 6797 | case else { |
| 6798 | /* This shall not happen, just to be sure */ |
| 6799 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6800 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6801 | } |
| 6802 | |
| 6803 | f_rsl_chan_deact(); |
| 6804 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6805 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 6806 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6807 | setverdict(pass); |
| 6808 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame^] | 6809 | setverdict(fail, "Not enough fill frames received: ", |
| 6810 | nfill_frames, " out of ", expected_fill_frames); |
| 6811 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6812 | } |
| 6813 | } else { |
| 6814 | repeat; |
| 6815 | } |
| 6816 | } |
| 6817 | } |
| 6818 | [] L1CTL.receive { repeat; } |
| 6819 | [] T.timeout { |
| 6820 | f_rsl_chan_deact(); |
| 6821 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6822 | 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] | 6823 | } |
| 6824 | } |
| 6825 | } |
| 6826 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6827 | 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] | 6828 | f_test_l2_fill_frames(false); |
| 6829 | } |
| 6830 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6831 | private function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6832 | f_test_l2_fill_frames(true); |
| 6833 | } |
| 6834 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6835 | 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] | 6836 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6837 | var ConnHdlr vc_conn; |
| 6838 | var ConnHdlrPars pars; |
| 6839 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6840 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6841 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6842 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 6843 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6844 | if (dtxd) { |
| 6845 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6846 | break; |
| 6847 | } |
| 6848 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6849 | } else { |
| 6850 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6851 | } |
| 6852 | vc_conn.done; |
| 6853 | } |
| 6854 | } |
| 6855 | |
| 6856 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6857 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6858 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6859 | f_tch_sign_l2_fill_frame(false); |
| 6860 | } |
| 6861 | |
| 6862 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6863 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6864 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6865 | f_tch_sign_l2_fill_frame(true); |
| 6866 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6867 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6868 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6869 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6870 | } |
| 6871 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6872 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6873 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6874 | } |
| 6875 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 6876 | |
| 6877 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 6878 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 6879 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 6880 | runs on ConnHdlr return octetstring; |
| 6881 | |
| 6882 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 6883 | runs on ConnHdlr { |
| 6884 | var L1ctlDlMessage l1_dl; |
| 6885 | var SacchL1Header l1h; |
| 6886 | var octetstring l2; |
| 6887 | |
| 6888 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 6889 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 6890 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 6891 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 6892 | |
| 6893 | /* Pass it to the user specified call-back function */ |
| 6894 | l2 := cb.apply(l1h, num_blocks); |
| 6895 | /* Send a Measurement Report generated by the call-back */ |
| 6896 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 6897 | l1_dl.dl_info.link_id, |
| 6898 | l1h, l2)); |
| 6899 | |
| 6900 | /* Shall we keep going? */ |
| 6901 | num_blocks := num_blocks - 1; |
| 6902 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 6903 | if (num_blocks > 0) { repeat; } |
| 6904 | } |
| 6905 | [] L1CTL.receive { repeat; } |
| 6906 | } |
| 6907 | |
| 6908 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 6909 | runs on ConnHdlr return octetstring { |
| 6910 | /* Command the L1 to apply received parameters */ |
| 6911 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 6912 | |
| 6913 | /* Dummy measurement report (the results are invalid) */ |
| 6914 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 6915 | } |
| 6916 | |
| 6917 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 6918 | runs on ConnHdlr return octetstring { |
| 6919 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 6920 | setverdict(fail, "Unexpected MS Power level change: ", |
| 6921 | g_pars.l1_pars.ms_power_level, " -> ", |
| 6922 | l1h.ms_power_lvl); |
| 6923 | } |
| 6924 | |
| 6925 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 6926 | } |
| 6927 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 6928 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 6929 | runs on ConnHdlr return octetstring { |
| 6930 | /* UL RSSI oscillation driven by SACCH block number */ |
| 6931 | if (num_blocks rem 2 == 0) { |
| 6932 | f_trxc_fake_rssi(-100); |
| 6933 | } else { |
| 6934 | f_trxc_fake_rssi(-50); |
| 6935 | } |
| 6936 | |
| 6937 | /* Make sure that MS power level remains constant */ |
| 6938 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 6939 | } |
| 6940 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 6941 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 6942 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 6943 | runs on ConnHdlr { |
| 6944 | var integer num_blocks := 8; |
| 6945 | timer T := int2float(num_blocks); |
| 6946 | |
| 6947 | f_l1_tune(L1CTL); |
| 6948 | RSL.clear; |
| 6949 | |
| 6950 | /* These IEs are needed for autonomous MS power control */ |
| 6951 | var template (value) RSL_IE_List ies := { |
| 6952 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 6953 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 6954 | }), |
| 6955 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 6956 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 6957 | }) |
| 6958 | }; |
| 6959 | |
| 6960 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 6961 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 6962 | |
| 6963 | /* Establish a dedicated channel */ |
| 6964 | f_est_dchan(more_ies := valueof(ies)); |
| 6965 | |
| 6966 | L1CTL.clear; |
| 6967 | T.start; |
| 6968 | alt { |
| 6969 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 6970 | [] T.timeout { |
| 6971 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 6972 | num_blocks, " were not handled"); |
| 6973 | } |
| 6974 | } |
| 6975 | } |
| 6976 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 6977 | var ConnHdlr vc_conn; |
| 6978 | var ConnHdlrPars pars; |
| 6979 | |
| 6980 | f_init(); |
| 6981 | |
| 6982 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 6983 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 6984 | |
| 6985 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 6986 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6987 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 6988 | |
| 6989 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 6990 | pars, trxc_comp := true); |
| 6991 | vc_conn.done; |
| 6992 | } |
| 6993 | |
| 6994 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 6995 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6996 | } |
| 6997 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 6998 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 6999 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7000 | runs on ConnHdlr { |
| 7001 | var integer num_blocks := 16; |
| 7002 | timer T := int2float(num_blocks); |
| 7003 | |
| 7004 | f_l1_tune(L1CTL); |
| 7005 | RSL.clear; |
| 7006 | |
| 7007 | /* These IEs are needed for autonomous MS power control */ |
| 7008 | var template (value) RSL_IE_List ies := { |
| 7009 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7010 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7011 | }), |
| 7012 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7013 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7014 | }) |
| 7015 | }; |
| 7016 | |
| 7017 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7018 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7019 | |
| 7020 | /* Establish a dedicated channel */ |
| 7021 | f_est_dchan(more_ies := valueof(ies)); |
| 7022 | |
| 7023 | L1CTL.clear; |
| 7024 | T.start; |
| 7025 | alt { |
| 7026 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7027 | [] T.timeout { |
| 7028 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7029 | num_blocks, " were not handled"); |
| 7030 | } |
| 7031 | } |
| 7032 | } |
| 7033 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7034 | var ConnHdlr vc_conn; |
| 7035 | var ConnHdlrPars pars; |
| 7036 | |
| 7037 | f_init(); |
| 7038 | |
| 7039 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7040 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7041 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7042 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7043 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7044 | |
| 7045 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7046 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7047 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7048 | |
| 7049 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7050 | pars, trxc_comp := true); |
| 7051 | vc_conn.done; |
| 7052 | } |
| 7053 | |
| 7054 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7055 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7056 | } |
| 7057 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7058 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7059 | var template L1ctlDlMessage tr_bad_frame; |
| 7060 | var L1ctlDlMessage l1_dl; |
| 7061 | timer T := 8.0; |
| 7062 | |
| 7063 | f_l1_tune(L1CTL); |
| 7064 | RSL.clear; |
| 7065 | |
| 7066 | f_est_dchan(); |
| 7067 | |
| 7068 | /* There may be a few errors right after the channel activation */ |
| 7069 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 7070 | L1CTL.clear; |
| 7071 | |
| 7072 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 7073 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 7074 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 7075 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 7076 | tr_bad_frame.payload := ?; |
| 7077 | |
| 7078 | T.start; |
| 7079 | alt { |
| 7080 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 7081 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 7082 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 7083 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 7084 | } |
| 7085 | [] as_l1_sacch(); |
| 7086 | [] L1CTL.receive { repeat; } |
| 7087 | [] T.timeout { |
| 7088 | /* We're done, break the loop */ |
| 7089 | setverdict(pass); |
| 7090 | } |
| 7091 | } |
| 7092 | |
| 7093 | f_rsl_chan_deact(); |
| 7094 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7095 | } |
| 7096 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 7097 | var ConnHdlr vc_conn; |
| 7098 | var ConnHdlrPars pars; |
| 7099 | |
| 7100 | f_init(); |
| 7101 | |
| 7102 | /* TS1, TCH/F, V1 (FR codec) */ |
| 7103 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 7104 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7105 | vc_conn.done; |
| 7106 | } |
| 7107 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 7108 | var ConnHdlr vc_conn; |
| 7109 | var ConnHdlrPars pars; |
| 7110 | |
| 7111 | f_init(); |
| 7112 | |
| 7113 | /* TS5, TCH/H, V1 (HR codec) */ |
| 7114 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 7115 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 7116 | vc_conn.done; |
| 7117 | } |
| 7118 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7119 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 7120 | /* protocol error as per 44.006 */ |
| 7121 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 7122 | /* repetition of SABM or DISC N200 times without ACK */ |
| 7123 | /* receptiom of SABM in multi-frame established state */ |
| 7124 | |
| 7125 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7126 | /* TODO Areas: |
| 7127 | |
| 7128 | * channel activation |
| 7129 | ** with BS_Power / MS_Power, bypassing power control loop |
| 7130 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7131 | ** with timing advance from initial activation on |
| 7132 | * mode modify |
| 7133 | ** encryption |
| 7134 | ** multirate |
| 7135 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7136 | ** unsupported algorithm |
| 7137 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7138 | * BS Power Control |
| 7139 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7140 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7141 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7142 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7143 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7144 | ** DATA_IND from BTS->PCU |
| 7145 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7146 | |
| 7147 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7148 | |
| 7149 | control { |
| 7150 | execute( TC_chan_act_stress() ); |
| 7151 | execute( TC_chan_act_react() ); |
| 7152 | execute( TC_chan_deact_not_active() ); |
| 7153 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 7154 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 7155 | execute( TC_sacch_filling() ); |
| 7156 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 7157 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 7158 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 7159 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 7160 | execute( TC_sacch_chan_act_ho_async() ); |
| 7161 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7162 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 7163 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 7164 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 7165 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 7166 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 7167 | execute( TC_rach_load_idle_thresh0() ); |
| 7168 | execute( TC_rach_load_idle_below_thresh() ); |
| 7169 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7170 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7171 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 7172 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 7173 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 7174 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7175 | execute( TC_meas_res_sign_tchf() ); |
| 7176 | execute( TC_meas_res_sign_tchh() ); |
| 7177 | execute( TC_meas_res_sign_sdcch4() ); |
| 7178 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 7179 | execute( TC_meas_res_sign_tchh_toa256() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 7180 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 7181 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 7182 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 7183 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 7184 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 7185 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 7186 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 7187 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 7188 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 7189 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 7190 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 7191 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 7192 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 7193 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7194 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7195 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 7196 | execute( TC_paging_imsi_80percent() ); |
| 7197 | execute( TC_paging_tmsi_80percent() ); |
| 7198 | execute( TC_paging_imsi_200percent() ); |
| 7199 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 7200 | execute( TC_rsl_protocol_error() ); |
| 7201 | execute( TC_rsl_mand_ie_error() ); |
| 7202 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7203 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 7204 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 7205 | execute( TC_si_sched_2bis() ); |
| 7206 | execute( TC_si_sched_2ter() ); |
| 7207 | execute( TC_si_sched_2ter_2bis() ); |
| 7208 | execute( TC_si_sched_2quater() ); |
| 7209 | execute( TC_si_sched_13() ); |
| 7210 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 7211 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 7212 | execute( TC_ipa_crcx_twice_not_active() ); |
| 7213 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 7214 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 7215 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 7216 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7217 | if (mp_pcu_socket != "") { |
| 7218 | execute( TC_pcu_act_req() ); |
| 7219 | execute( TC_pcu_act_req_wrong_ts() ); |
| 7220 | execute( TC_pcu_act_req_wrong_bts() ); |
| 7221 | execute( TC_pcu_act_req_wrong_trx() ); |
| 7222 | execute( TC_pcu_deact_req() ); |
| 7223 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 7224 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7225 | if (mp_l1_supports_gprs) { |
| 7226 | execute( TC_pcu_data_req_pdtch() ); |
| 7227 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 7228 | execute( TC_pcu_data_req_wrong_bts() ); |
| 7229 | execute( TC_pcu_data_req_wrong_trx() ); |
| 7230 | execute( TC_pcu_data_req_wrong_ts() ); |
| 7231 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 7232 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 7233 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7234 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 7235 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7236 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 7237 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 7238 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 7239 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7240 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 7241 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 7242 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 7243 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 7244 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 7245 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 7246 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7247 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7248 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7249 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7250 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 7251 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 7252 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 7253 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 7254 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 7255 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 7256 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 7257 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 7258 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 7259 | if (PCUIF_Types.mp_pcuif_version >= 10) { |
| 7260 | execute( TC_pcu_info_ind_fh_params() ); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 7261 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 7262 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 7263 | } |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 7264 | } else { |
| 7265 | log("PCU socket path not available, skipping PCU tests"); |
| 7266 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7267 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7268 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 7269 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 7270 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7271 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 7272 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7273 | |
| 7274 | execute( TC_rll_est_ind() ); |
| 7275 | execute( TC_rll_est_req_DCCH_3() ); |
| 7276 | execute( TC_rll_est_req_ACCH_3() ); |
| 7277 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 7278 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 7279 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 7280 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 7281 | execute( TC_rll_rel_req() ); |
| 7282 | execute( TC_rll_unit_data_req_DCCH() ); |
| 7283 | execute( TC_rll_unit_data_req_ACCH() ); |
| 7284 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 7285 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7286 | |
| 7287 | execute( TC_chan_act_a51() ); |
| 7288 | execute( TC_chan_act_a52() ); |
| 7289 | execute( TC_chan_act_a53() ); |
| 7290 | execute( TC_encr_cmd_a51() ); |
| 7291 | execute( TC_encr_cmd_a52() ); |
| 7292 | execute( TC_encr_cmd_a53() ); |
| 7293 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 7294 | execute( TC_err_rep_wrong_mdisc() ); |
| 7295 | execute( TC_err_rep_wrong_msg_type() ); |
| 7296 | execute( TC_err_rep_wrong_sequence() ); |
| 7297 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7298 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7299 | |
| 7300 | execute( TC_tch_sign_l2_fill_frame() ); |
| 7301 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7302 | |
| 7303 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7304 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7305 | |
| 7306 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7307 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7308 | |
| 7309 | execute( TC_speech_no_rtp_tchf() ); |
| 7310 | execute( TC_speech_no_rtp_tchh() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 7311 | } |
| 7312 | |
| 7313 | |
| 7314 | } |