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; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 43 | import from RTP_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 44 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 45 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 46 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 47 | import from RSL_Emulation all; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 48 | import from RTP_Emulation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 49 | |
| 50 | import from IPL4asp_Types all; |
| 51 | import from TRXC_Types all; |
| 52 | import from TRXC_CodecPort all; |
| 53 | import from TRXC_CodecPort_CtrlFunct all; |
| 54 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 55 | import from PCUIF_Types all; |
| 56 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 57 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 58 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 59 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 60 | import from MobileL3_RRM_Types all; |
| 61 | import from MobileL3_Types all; |
| 62 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 63 | import from L3_Common all; |
| 64 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 65 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 66 | import from Osmocom_VTY_Functions all; |
| 67 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 68 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 69 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 70 | friend module BTS_Tests_SMSCB; |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 71 | friend module BTS_Tests_VAMOS; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 72 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 73 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 74 | friend module BTS_Tests_perf; |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 75 | friend module BTS_Tests_OML; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 76 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 77 | /* The tests assume a BTS with the following timeslot configuration: |
| 78 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 79 | * TS1 : TCH/F |
| 80 | * TS2 : TCH/F |
| 81 | * TS3 : TCH/F_PDCH (IPA Style) |
| 82 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 83 | * TS5 : TCH/H |
| 84 | * TS6 : SDCCH/8 |
| 85 | * TS7 : PDCH |
| 86 | */ |
| 87 | |
| 88 | modulepar { |
| 89 | charstring mp_rsl_ip := "127.0.0.2"; |
| 90 | integer mp_rsl_port := 3003; |
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; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 98 | charstring mp_rtpem_bind_ip := "127.0.0.1"; |
| 99 | integer mp_rtpem_bind_port := 6766; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 100 | integer mp_tolerance_rxqual := 1; |
| 101 | integer mp_tolerance_rxlev := 3; |
| 102 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 103 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 104 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 105 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 106 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 107 | 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] | 108 | integer mp_ms_actual_ta_exp := 0; |
| 109 | integer mp_timing_offset_256syms_exp := 512; |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 110 | integer mp_uplink_power_target := -75; |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 111 | integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */ |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 112 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 113 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 114 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 115 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 116 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 117 | /* how many transceivers do we expect to connect */ |
| 118 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 119 | /* frequency hopping status */ |
| 120 | boolean mp_freq_hop_enabled := false; |
| 121 | /* frequency hopping parameters */ |
| 122 | FreqHopConfig mp_fh_config; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 123 | /* configuration for each individual transceiver */ |
| 124 | TrxPars mp_trx_pars; /* see BTS_Tests.default */ |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 125 | /* default Training Sequence Code */ |
| 126 | GsmTsc mp_tsc_def := 7; |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 127 | /* Default interference boundaries in osmo-bsc (in dBm): |
| 128 | * 0(-85) X1(-91) X2(-97) X3(-103) X4(-109) X5(-115) |
| 129 | * Default interference level reported by fake_trx.py: |
| 130 | * 0: -109 >= -85 dBm (no) |
| 131 | * X1: -109 >= -91 dBm (no) |
| 132 | * X2: -109 >= -97 dBm (no) |
| 133 | * X3: -109 >= -103 dBm (no) |
| 134 | * X4: -109 >= -109 dBm (yes) |
| 135 | * X5: -109 >= -115 dBm (no) |
| 136 | * So all channels should be in band 4. */ |
| 137 | uint3_t mp_interf_band := 4; |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 138 | /* T3105 timer (see 3GPP TS 44.018, section 11.1.2) */ |
| 139 | integer mp_ho_t3105_ms := 100; |
| 140 | /* Ny1 counter (see 3GPP TS 44.018, section 11.1.3) */ |
| 141 | integer mp_ho_ny1 := 10; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 144 | type record of RslChannelNr ChannelNrs; |
| 145 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 146 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 147 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 148 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 149 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 150 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 151 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 152 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 153 | |
| 154 | /* L1CTL port (for classic tests) */ |
| 155 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 156 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 157 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 158 | port TRXC_CODEC_PT BTS_TRXC; |
| 159 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 160 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 161 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 162 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 163 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 164 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 165 | /* PCU Interface of BTS */ |
| 166 | port PCUIF_CODEC_PT PCU; |
| 167 | var integer g_pcu_conn_id; |
| 168 | /* Last PCU INFO IND we received */ |
| 169 | var PCUIF_Message g_pcu_last_info; |
| 170 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 171 | /* SI configuration */ |
| 172 | var SystemInformationConfig si_cfg := { |
| 173 | bcch_extended := false, |
| 174 | si1_present := false, |
| 175 | si2bis_present := false, |
| 176 | si2ter_present := false, |
| 177 | si2quater_present := false, |
| 178 | si7_present := false, |
| 179 | si8_present := false, |
| 180 | si9_present := false, |
| 181 | si13_present := false, |
| 182 | si13alt_present := false, |
| 183 | si15_present := false, |
| 184 | si16_present := false, |
| 185 | si17_present := false, |
| 186 | si2n_present := false, |
| 187 | si21_present := false, |
| 188 | si22_present := false |
| 189 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 190 | |
| 191 | /* all logical channels available on the BTS */ |
| 192 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 193 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 197 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 198 | port L1CTL_PT L1CTL; |
| 199 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 200 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 201 | port TRXC_CODEC_PT BTS_TRXC; |
| 202 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 203 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 204 | /* port to be initialized optionally to access BSC VTY */ |
| 205 | port TELNETasp_PT BSCVTY; |
| 206 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 207 | timer g_Tguard; |
| 208 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 209 | |
| 210 | var ConnHdlrPars g_pars; |
| 211 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 212 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 213 | |
| 214 | /* PCU Interface of BTS */ |
| 215 | port PCUIF_CODEC_PT PCU; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 216 | |
| 217 | var RTP_Emulation_CT vc_RTPEM; |
| 218 | port RTPEM_CTRL_PT RTPEM_CTRL; |
| 219 | port RTPEM_DATA_PT RTPEM_DATA; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 222 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 223 | var bitstring trx_mask := '00000000'B; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 224 | var bitstring rfind_mask := '00000000'B; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 225 | var integer trx_count := 0; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 226 | var integer rfind_count := 0; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 227 | var RSLEm_Event ev; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 228 | var ASP_RSL_Unitdata rx_ud; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 229 | timer T; |
| 230 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 231 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 232 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 233 | |
| 234 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 235 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 236 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 237 | |
| 238 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 239 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 240 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 241 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 242 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 243 | T.start(mp_ipa_up_timeout); |
| 244 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 245 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 246 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 247 | /* Make sure that all transceivers use unique stream ID */ |
| 248 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 249 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 250 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 251 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 252 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 253 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 254 | trx_count := trx_count + 1; |
| 255 | |
| 256 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 257 | repeat; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 258 | } |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 259 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 260 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud { |
| 261 | if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) { |
| 262 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 263 | log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")")); |
| 264 | } |
| 265 | if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) { |
| 266 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 267 | log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")")); |
| 268 | } |
| 269 | |
| 270 | rfind_mask[enum2int(rx_ud.streamId)] := '1'B; |
| 271 | rfind_count := rfind_count + 1; |
| 272 | log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received"); |
| 273 | if (rfind_count < mp_transceiver_num) { repeat; } |
| 274 | } |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 275 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 276 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 277 | [] T.timeout { |
| 278 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 279 | "Timeout waiting for RSL bring up"); |
| 280 | } |
| 281 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 282 | } |
| 283 | |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 284 | friend type record length(1 .. 256) of TrxParsItem TrxPars; |
| 285 | friend type record TrxParsItem { |
| 286 | GsmArfcn arfcn, |
| 287 | TrxTsPars ts |
| 288 | }; |
| 289 | |
| 290 | friend type record length(8) of TrxTsParsItem TrxTsPars; |
| 291 | friend type record TrxTsParsItem { |
| 292 | PchanConfig config |
| 293 | }; |
| 294 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 295 | friend type record FreqHopPars { |
| 296 | /* Whether frequency hopping is in use */ |
| 297 | boolean enabled, |
| 298 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 299 | MaioHsn maio_hsn, |
| 300 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 301 | MobileAllocationLV ma_map, |
| 302 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 303 | L1ctlMA ma |
| 304 | }; |
| 305 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 306 | type record ConnHdlrPars { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 307 | uint8_t trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 308 | RslChannelNr chan_nr, |
| 309 | RSL_IE_ChannelMode chan_mode, |
| 310 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 311 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 312 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 313 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 314 | BtsBand bts0_band optional, |
| 315 | |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 316 | /* Training Sequence Code */ |
| 317 | GsmTsc tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 318 | /* Frequency hopping parameters */ |
| 319 | FreqHopPars fhp |
| 320 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 321 | |
| 322 | /* Test-specific parameters */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 323 | friend type union TestSpecUnion { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 324 | RllTestCase rll, |
| 325 | TopTestCase top |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 328 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 329 | max_retrans := RACH_MAX_RETRANS_7, |
| 330 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 331 | cell_barr_access := false, |
| 332 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 333 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 334 | }; |
| 335 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 336 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 337 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 338 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 339 | acs := '0'B, |
| 340 | neci := true, |
| 341 | rxlev_access_min := 0 |
| 342 | } |
| 343 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 344 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 345 | mcc_mnc := '262F42'H, |
| 346 | lac := 42 |
| 347 | } |
| 348 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 349 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 350 | ra_colour := 0, |
| 351 | si13_pos := '0'B |
| 352 | } |
| 353 | |
| 354 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 355 | modifies ts_SI3RestOctets := { |
| 356 | gprs_ind := { |
| 357 | presence := CSN1_H, |
| 358 | ind := ts_GPRSIndicator_def |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 363 | modifies ts_SI4RestOctets := { |
| 364 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 365 | presence := CSN1_H, |
| 366 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 370 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 371 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 372 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 373 | payload := { |
| 374 | si3 := { |
| 375 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 376 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 377 | ctrl_chan_desc := { |
| 378 | msc_r99 := true, |
| 379 | att := true, |
| 380 | bs_ag_blks_res := 1, |
| 381 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 382 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 383 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 384 | spare := '00'B, |
| 385 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 386 | t3212 := 1 /* 6 minutes */ |
| 387 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 388 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 389 | dn_ind := false, |
| 390 | pwrc := false, |
| 391 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 392 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 393 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 394 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 395 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 396 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 400 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 401 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 402 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 403 | payload := { |
| 404 | si2 := { |
| 405 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 406 | ncc_permitted := '11111111'B, |
| 407 | rach_control := ts_RachCtrl_default |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 412 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 413 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 414 | payload := { |
| 415 | si4 := { |
| 416 | lai := ts_LAI_default, |
| 417 | cell_sel_par := ts_CellSelPar_default, |
| 418 | rach_control := ts_RachCtrl_default, |
| 419 | cbch_chan_desc := omit, |
| 420 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 421 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 426 | 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] | 427 | runs on test_CT { |
| 428 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 429 | 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] | 430 | } |
| 431 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 432 | 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] | 433 | runs on test_CT { |
| 434 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 435 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 436 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 437 | } |
| 438 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 439 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 440 | map(self:BTSVTY, system:BTSVTY); |
| 441 | f_vty_set_prompts(BTSVTY); |
| 442 | f_vty_transceive(BTSVTY, "enable"); |
| 443 | } |
| 444 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 445 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 446 | map(self:BSCVTY, system:BSCVTY); |
| 447 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 448 | f_vty_transceive(BSCVTY, "enable"); |
| 449 | } |
| 450 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 451 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 452 | map(self:BSCVTY, system:BSCVTY); |
| 453 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 454 | f_vty_transceive(BSCVTY, "enable"); |
| 455 | } |
| 456 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 457 | /* PCU socket may at any time receive a new INFO.ind */ |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 458 | friend altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 459 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 460 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 461 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 462 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 463 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 464 | [] 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] | 465 | 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] | 466 | } |
| 467 | } |
| 468 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 469 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 470 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 471 | timer T := 2.0; |
| 472 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 473 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 474 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 475 | return; |
| 476 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 477 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 478 | |
| 479 | T.start; |
| 480 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 481 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 482 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 483 | 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] | 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 488 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 489 | out integer trxc_conn_id) { |
| 490 | var Result res; |
| 491 | |
| 492 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 493 | "", -1, -1, { udp := {} }, {}); |
| 494 | if (not ispresent(res.connId)) { |
| 495 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 496 | "Could not connect to the control (TRXC) interface " & |
| 497 | "of FakeTRX, check your configuration"); |
| 498 | } |
| 499 | trxc_conn_id := res.connId; |
| 500 | } |
| 501 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 502 | /* global init function (without PCUIF connection) */ |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 503 | friend function f_init(uint8_t trx_nr := 0) |
| 504 | runs on test_CT |
| 505 | { |
| 506 | var TrxParsItem trx_pars := mp_trx_pars[trx_nr]; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 507 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 508 | |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 509 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653. |
| 510 | * TODO: also generate this list dynamically from module parameters. */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 511 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 512 | g_AllChanTypes := { |
| 513 | /* TS 1..4: TCH/F */ |
| 514 | valueof(ts_RslChanNr_Bm(1)), |
| 515 | /* TS 5: TCH/H */ |
| 516 | valueof(ts_RslChanNr_Lm(5,1)), |
| 517 | /* TS 0: SDCCH/4 */ |
| 518 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 519 | /* TS 6: SDCCH/8 */ |
| 520 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 521 | }; |
| 522 | } else { |
| 523 | g_AllChanTypes := { |
| 524 | /* TS 1..4: TCH/F */ |
| 525 | valueof(ts_RslChanNr_Bm(1)), |
| 526 | /* TS 0: SDCCH/4 */ |
| 527 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 528 | /* TS 6: SDCCH/8 */ |
| 529 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 530 | }; |
| 531 | } |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 532 | |
| 533 | g_AllChannels := { }; |
| 534 | |
| 535 | /* Generate list of all logical channels from module parameters */ |
| 536 | for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) { |
| 537 | select (trx_pars.ts[tn].config) { |
| 538 | case (GSM_PCHAN_CCCH_SDCCH4) { |
| 539 | g_AllChannels := g_AllChannels & |
| 540 | { valueof(ts_RslChanNr_SDCCH4(tn, 0)), |
| 541 | valueof(ts_RslChanNr_SDCCH4(tn, 1)), |
| 542 | valueof(ts_RslChanNr_SDCCH4(tn, 2)), |
| 543 | valueof(ts_RslChanNr_SDCCH4(tn, 3)) }; |
| 544 | } |
| 545 | case (GSM_PCHAN_SDCCH8) { |
| 546 | g_AllChannels := g_AllChannels & |
| 547 | { valueof(ts_RslChanNr_SDCCH8(tn, 0)), |
| 548 | valueof(ts_RslChanNr_SDCCH8(tn, 1)), |
| 549 | valueof(ts_RslChanNr_SDCCH8(tn, 2)), |
| 550 | valueof(ts_RslChanNr_SDCCH8(tn, 3)), |
| 551 | valueof(ts_RslChanNr_SDCCH8(tn, 4)), |
| 552 | valueof(ts_RslChanNr_SDCCH8(tn, 5)), |
| 553 | valueof(ts_RslChanNr_SDCCH8(tn, 6)), |
| 554 | valueof(ts_RslChanNr_SDCCH8(tn, 7)) }; |
| 555 | } |
| 556 | case (GSM_PCHAN_TCHH_TCHF_PDCH) { |
| 557 | g_AllChannels := g_AllChannels & |
| 558 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 559 | valueof(ts_RslChanNr_Lm(tn, 1)), |
| 560 | valueof(ts_RslChanNr_Bm(tn)) }; |
| 561 | } |
| 562 | case (GSM_PCHAN_TCHH) { |
| 563 | g_AllChannels := g_AllChannels & |
| 564 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 565 | valueof(ts_RslChanNr_Lm(tn, 1)) }; |
| 566 | } |
| 567 | case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) { |
| 568 | g_AllChannels := g_AllChannels & |
| 569 | { valueof(ts_RslChanNr_Bm(tn)) }; |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 574 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 575 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 576 | f_init_vty(id); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 577 | f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 578 | |
| 579 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 580 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 581 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 582 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 583 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 584 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 585 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 586 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 587 | |
| 588 | /* Init TRXC interface to FakeTRX */ |
| 589 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 590 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 591 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 592 | /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 593 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256)); |
| 594 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(-60)); |
Vadim Yanitskiy | de535e0 | 2019-07-26 16:29:27 +0700 | [diff] [blame] | 595 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 596 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(60)); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 597 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 598 | |
| 599 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 600 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 601 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 604 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 605 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 606 | map(self:L1CTL, system:L1CTL); |
| 607 | f_connect_reset(L1CTL); |
| 608 | } |
| 609 | |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 610 | friend type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 611 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 612 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 613 | |
| 614 | private type record of FreqHopGroup FreqHopGroups; |
| 615 | private type record FreqHopGroup { |
| 616 | uint6_t hsn, |
| 617 | FreqHopGroupItems trx_maio |
| 618 | }; |
| 619 | |
| 620 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 621 | private type record FreqHopGroupItem { |
| 622 | uint8_t trx_nr, |
| 623 | uint6_t maio |
| 624 | }; |
| 625 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 626 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 627 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 628 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 629 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 630 | var integer i, j; |
| 631 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 632 | fhp.enabled := false; |
| 633 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 634 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 635 | var FreqHopGroup g := groups[i]; |
| 636 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 637 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 638 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 639 | fhp.maio_hsn.maio := gi.maio; |
| 640 | fhp.maio_hsn.hsn := g.hsn; |
| 641 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 642 | break; |
| 643 | } |
| 644 | } |
| 645 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 646 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 647 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 648 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 649 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 650 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 651 | |
| 652 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 653 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 654 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 655 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 656 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 657 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 658 | } |
| 659 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 660 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 661 | break; /* We're done */ |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 666 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 667 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 668 | boolean pcu_comp := false, |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 669 | boolean trxc_comp := false, |
| 670 | boolean l1ctl := true) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 671 | runs on test_CT return ConnHdlr { |
| 672 | var charstring id := testcasename(); |
| 673 | var ConnHdlr vc_conn; |
| 674 | |
| 675 | vc_conn := ConnHdlr.create(id); |
| 676 | /* connect to RSL Emulation main component */ |
| 677 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 678 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 679 | |
| 680 | /* The ConnHdlr component may want to talk to some ports directly, |
| 681 | * so we disconnect it from the test_CT and connect it to the component. |
| 682 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 683 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 684 | unmap(self:PCU, system:PCU); |
| 685 | map(vc_conn:PCU, system:PCU); |
| 686 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 687 | if (trxc_comp) { |
| 688 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 689 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 690 | } |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 691 | if (l1ctl) { |
| 692 | map(vc_conn:L1CTL, system:L1CTL); |
| 693 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 694 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 695 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 696 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 697 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 698 | } |
| 699 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 700 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 701 | return vc_conn; |
| 702 | } |
| 703 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 704 | private altstep as_Tguard() runs on ConnHdlr { |
| 705 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 706 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 710 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 711 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 712 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 713 | } |
| 714 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 715 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 716 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 717 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 718 | } |
| 719 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 720 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 721 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 722 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /* first function started in ConnHdlr component */ |
| 726 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 727 | runs on ConnHdlr { |
| 728 | g_pars := pars; |
| 729 | g_chan_nr := pars.chan_nr; |
| 730 | |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 731 | if (L1CTL.checkstate("Mapped")) { |
| 732 | f_connect_reset(L1CTL); |
| 733 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 734 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 735 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 736 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 737 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 738 | |
| 739 | g_Tguard.start(pars.t_guard); |
| 740 | activate(as_Tguard()); |
| 741 | |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 742 | f_rslem_register(pars.trx_nr, pars.chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 743 | |
| 744 | /* call the user-supplied test case function */ |
| 745 | fn.apply(id); |
| 746 | } |
| 747 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 748 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 749 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 750 | runs on ConnHdlr return RSL_Message { |
| 751 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 752 | timer T := 3.0; |
| 753 | RSL.send(tx); |
| 754 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 755 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 756 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 757 | T.stop; |
| 758 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 759 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 760 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 761 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 762 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 763 | [not ignore_other] as_l1_sacch(); |
| 764 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 765 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 766 | [not ignore_other] as_l1_tch_loop(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 767 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 768 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 769 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 770 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 771 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 772 | return rx; |
| 773 | } |
| 774 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 775 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 776 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 777 | runs on ConnHdlr { |
| 778 | 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] | 779 | } |
| 780 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 781 | /* Send the given measurement results to the IUT over the Um interface */ |
| 782 | friend function f_send_meas_rep(template (value) MeasurementResults meas_res) |
| 783 | runs on ConnHdlr { |
| 784 | var template (value) SacchL1Header l1h; |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 785 | |
| 786 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta); |
| 787 | f_send_meas_rep_l1h(meas_res, l1h); |
| 788 | } |
| 789 | |
| 790 | /* Send the given measurement results and L1H to the IUT over the Um interface */ |
| 791 | friend function f_send_meas_rep_l1h(template (value) MeasurementResults meas_res, |
| 792 | template (value) SacchL1Header l1h) |
| 793 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 794 | var octetstring l2; |
| 795 | |
| 796 | /* RR Measurement Report to be sent */ |
| 797 | var GsmRrL3Message meas_rep := { |
| 798 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 799 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 800 | }; |
| 801 | |
| 802 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 803 | l2 := f_pad_oct(enc_LapdmFrameAB(valueof(ts_LAPDm_AB(0, meas_rep))), 21, '00'O); |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 804 | |
| 805 | log(%definitionId, "(): Tx SACCH L1 header: ", l1h); |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 806 | |
| 807 | /* Send RR Measurement Report over the Um interface */ |
| 808 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
| 809 | } |
| 810 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 811 | /* Send the given measurement results to the IUT over the Um interface, |
| 812 | * wait for the IUT to receive then and forward over the A-bis/RSL interface. */ |
| 813 | friend function f_transceive_meas_rep(template (value) MeasurementResults meas_res) |
| 814 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 815 | var octetstring l3; |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 816 | timer T; |
| 817 | |
| 818 | /* RR Measurement Report to be sent */ |
| 819 | var GsmRrL3Message meas_rep := { |
| 820 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 821 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 822 | }; |
| 823 | |
| 824 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 825 | l3 := f_pad_oct(enc_GsmRrL3Message(meas_rep), 18, '00'O); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 826 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 827 | f_send_meas_rep(meas_res); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 828 | |
| 829 | /* Expect MEASurement RESult on the A-bis/RSL interface */ |
| 830 | T.start(2.0); |
| 831 | alt { |
| 832 | [] RSL.receive(tr_RSL_MEAS_RES_OSMO(g_chan_nr, l3_info := l3)) { |
| 833 | setverdict(pass); |
| 834 | } |
| 835 | [] RSL.receive { repeat; } |
| 836 | [] T.timeout { |
| 837 | setverdict(fail, "Timeout waiting for RSL MEASurement RESult"); |
| 838 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 839 | } |
| 840 | } |
| 841 | } |
| 842 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 843 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 844 | boolean encr_enable := false, |
| 845 | RSL_IE_List more_ies := {}, |
| 846 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 847 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 848 | 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] | 849 | if (encr_enable) { |
| 850 | /* append encryption related IEs, if requested */ |
| 851 | var RSL_IE_EncryptionInfo encr_info; |
| 852 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 853 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 854 | encr_info})) }; |
| 855 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 856 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 857 | 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] | 858 | } |
| 859 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 860 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 861 | 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] | 862 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 863 | } |
| 864 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 865 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 866 | template RSL_IE_ChannelMode chan_mode, |
| 867 | template (omit) TestSpecUnion spec := omit, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 868 | uint8_t trx_nr := 0, float t_guard := 20.0) := { |
| 869 | trx_nr := trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 870 | chan_nr := valueof(chan_nr), |
| 871 | chan_mode := valueof(chan_mode), |
| 872 | t_guard := t_guard, |
| 873 | l1_pars := { |
| 874 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 875 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 876 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 877 | meas_ul := { |
| 878 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 879 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 880 | rxqual := 0 |
| 881 | }, |
| 882 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 883 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 884 | rxqual := 0 |
| 885 | } |
| 886 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 887 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 888 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 889 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 890 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 891 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 892 | }, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 893 | spec := spec, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 894 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 895 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 896 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 897 | fhp := { |
| 898 | enabled := false, |
| 899 | maio_hsn := ts_HsnMaio(0, 0), |
| 900 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 901 | ma := { } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 902 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 903 | } |
| 904 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 905 | /* This altstep triggers on receipt of a L1CTL DATA.ind matching the given |
| 906 | * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */ |
| 907 | private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg, |
| 908 | template (present) octetstring tr_data := ?, |
| 909 | template (present) RslChannelNr chan_nr := ?, |
| 910 | template (present) RslLinkId link_id := ?) |
| 911 | runs on ConnHdlr { |
| 912 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg; |
| 913 | } |
| 914 | |
| 915 | /* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt |
| 916 | * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */ |
| 917 | private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?, |
| 918 | template (present) RslLinkId link_id := ?, |
| 919 | template (present) LapdmSapi sapi := ?, |
| 920 | boolean do_repeat := true) |
| 921 | runs on ConnHdlr { |
| 922 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O); |
| 923 | var L1ctlDlMessage dl_msg; |
| 924 | |
| 925 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) { |
| 926 | if (do_repeat) { |
| 927 | repeat; |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload |
| 933 | * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */ |
| 934 | private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame, |
| 935 | template (present) LapdmFrameAB tr_frame := ?, |
| 936 | template (present) RslLinkId link_id := ?) |
| 937 | runs on ConnHdlr { |
| 938 | var L1ctlDlMessage dl_msg; |
| 939 | |
| 940 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) { |
| 941 | frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload); |
| 942 | } |
| 943 | } |
| 944 | |
Vadim Yanitskiy | a144e3c | 2022-03-14 23:56:40 +0300 | [diff] [blame] | 945 | /* This altstep triggers on receipt of a Downlink SACCH containing a L2 payload |
| 946 | * that matches the given LAPDm frame, as well as the given SACCH L1 header. */ |
| 947 | private altstep as_dl_sacch_lapdm_ab(out SacchL1Header l1h, out LapdmFrameAB frame, |
| 948 | template (present) LapdmFrameAB tr_frame := ?, |
| 949 | template (present) SacchL1Header tr_l1h := ?, |
| 950 | template (present) GsmSapi sapi := ?) |
| 951 | runs on ConnHdlr { |
| 952 | var L1ctlDlMessage dl_msg; |
| 953 | template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi); |
| 954 | template (present) L1ctlDataReq tr_data := { |
| 955 | l1header := tr_l1h, |
| 956 | l2_payload := decmatch tr_frame |
| 957 | }; |
| 958 | |
| 959 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_data, g_chan_nr, link_id) { |
| 960 | var octetstring data := dl_msg.payload.data_ind.payload; |
| 961 | l1h := dec_SacchL1Header(substr(data, 0, 2)); |
| 962 | frame := dec_LapdmFrameAB(substr(data, 2, lengthof(data) - 2)); |
| 963 | } |
| 964 | } |
| 965 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 966 | /* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt |
| 967 | * of a LAPDm AB frame with a L3 payload matching the given template. The L3 |
| 968 | * payload is treated as PDU_ML3_NW_MS. */ |
| 969 | private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu, |
| 970 | template (present) PDU_ML3_NW_MS tr_pdu := ?, |
| 971 | template (present) GsmSapi sapi := 0) |
| 972 | runs on ConnHdlr { |
| 973 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu); |
| 974 | template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi); |
| 975 | var LapdmFrameAB lapdm_frame; |
| 976 | |
| 977 | [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) { |
| 978 | pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload); |
| 979 | } |
| 980 | } |
| 981 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 982 | /*********************************************************************** |
| 983 | * Channel Activation / Deactivation |
| 984 | ***********************************************************************/ |
| 985 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 986 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 987 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 988 | for (var integer i := 0; i < 500; i := i+1) { |
| 989 | f_rsl_chan_act(g_pars.chan_mode); |
| 990 | f_rsl_chan_deact(); |
| 991 | } |
| 992 | setverdict(pass); |
| 993 | } |
| 994 | testcase TC_chan_act_stress() runs on test_CT { |
| 995 | var ConnHdlr vc_conn; |
| 996 | 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] | 997 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 998 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 999 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1000 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1004 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1005 | f_rsl_chan_act(g_pars.chan_mode); |
| 1006 | /* attempt to activate the same lchan again -> expect reject */ |
| 1007 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1008 | alt { |
| 1009 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1010 | 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] | 1011 | } |
| 1012 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1013 | setverdict(pass); |
| 1014 | } |
| 1015 | } |
| 1016 | f_rsl_chan_deact(); |
| 1017 | } |
| 1018 | testcase TC_chan_act_react() runs on test_CT { |
| 1019 | var ConnHdlr vc_conn; |
| 1020 | 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] | 1021 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1022 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 1023 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1024 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1028 | 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] | 1029 | timer T := 3.0; |
| 1030 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 1031 | T.start; |
| 1032 | alt { |
| 1033 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 1034 | setverdict(pass); |
| 1035 | } |
| 1036 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1037 | 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] | 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 1042 | 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] | 1043 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1044 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 1045 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1046 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1050 | 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] | 1051 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1052 | alt { |
| 1053 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1054 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1055 | } |
| 1056 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1057 | setverdict(pass); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | private type record WrongChanNrCase { |
| 1062 | RslChannelNr chan_nr, |
| 1063 | charstring description |
| 1064 | } |
| 1065 | private type record of WrongChanNrCase WrongChanNrCases; |
| 1066 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 1067 | chan_nr := chan_nr, |
| 1068 | description := desc |
| 1069 | } |
| 1070 | |
| 1071 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 1072 | var ConnHdlr vc_conn; |
| 1073 | var ConnHdlrPars pars; |
| 1074 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1075 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1076 | |
| 1077 | var WrongChanNrCases wrong := { |
| 1078 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 1079 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 1080 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 1081 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 1082 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 1083 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 1084 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 1085 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 1086 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 1087 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 1088 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 1089 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 1090 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 1091 | }; |
| 1092 | |
| 1093 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 1094 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 1095 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 1096 | vc_conn.done; |
| 1097 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1098 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1099 | } |
| 1100 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1101 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1102 | 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] | 1103 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1104 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1105 | |
| 1106 | /* test on each of the channels we have */ |
| 1107 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1108 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 1109 | |
| 1110 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 1111 | vc_conn := f_start_handler(fn, pars); |
| 1112 | vc_conn.done; |
| 1113 | } |
| 1114 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1115 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1116 | } |
| 1117 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1118 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1119 | * SACCH handling |
| 1120 | ***********************************************************************/ |
| 1121 | |
| 1122 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 1123 | timer T_sacch := 3.0; |
| 1124 | T_sacch.start; |
| 1125 | alt { |
| 1126 | [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] | 1127 | 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] | 1128 | } |
| 1129 | [not exp] T_sacch.timeout { |
| 1130 | setverdict(pass); |
| 1131 | } |
| 1132 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 1133 | setverdict(pass); |
| 1134 | } |
| 1135 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1136 | 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] | 1137 | } |
| 1138 | [] L1CTL.receive { repeat; } |
| 1139 | [] RSL.receive { repeat; } |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 1144 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 1145 | f_l1_tune(L1CTL); |
| 1146 | RSL.clear; |
| 1147 | |
| 1148 | /* activate the logical channel */ |
| 1149 | f_est_dchan(); |
| 1150 | L1CTL.clear; |
| 1151 | |
| 1152 | /* check that SACCH actually are received as expected */ |
| 1153 | f_exp_sacch(true); |
| 1154 | |
| 1155 | /* deactivate SACCH on the logical channel */ |
| 1156 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 1157 | f_sleep(1.0); |
| 1158 | L1CTL.clear; |
| 1159 | |
| 1160 | /* check that no SACCH are received anymore */ |
| 1161 | f_exp_sacch(false); |
| 1162 | |
| 1163 | /* release the channel */ |
| 1164 | f_rsl_chan_deact(); |
| 1165 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1166 | } |
| 1167 | testcase TC_deact_sacch() runs on test_CT { |
| 1168 | var ConnHdlr vc_conn; |
| 1169 | var ConnHdlrPars pars; |
| 1170 | f_init(); |
| 1171 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1172 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1173 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1174 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1175 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1176 | vc_conn.done; |
| 1177 | } |
| 1178 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1180 | } |
| 1181 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1182 | /* verify that given SACCH payload is present */ |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1183 | private function f_sacch_present(template octetstring l3_exp, |
| 1184 | boolean do_fail := true) |
| 1185 | runs on ConnHdlr { |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1186 | var L1ctlDlMessage dl; |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1187 | timer T_sacch := 3.0; |
| 1188 | L1CTL.clear; |
| 1189 | T_sacch.start; |
| 1190 | alt { |
| 1191 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1192 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1193 | if (match(l3, l3_exp)) { |
| 1194 | setverdict(pass); |
| 1195 | } else { |
| 1196 | repeat; |
| 1197 | } |
| 1198 | } |
| 1199 | [] L1CTL.receive { repeat; } |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1200 | [not do_fail] T_sacch.timeout { |
| 1201 | log("Timeout waiting for SACCH ", l3_exp); |
| 1202 | } |
| 1203 | [do_fail] T_sacch.timeout { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1204 | setverdict(fail, "Timeout waiting for SACCH ", l3_exp); |
| 1205 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1206 | } |
| 1207 | } |
| 1208 | } |
| 1209 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1210 | /* verify that given SACCH payload is not present */ |
| 1211 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1212 | var L1ctlDlMessage dl; |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1213 | timer T_sacch := 3.0; |
| 1214 | L1CTL.clear; |
| 1215 | T_sacch.start; |
| 1216 | alt { |
| 1217 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1218 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1219 | if (match(l3, l3_exp)) { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1220 | setverdict(fail, "Received unexpected SACCH ", dl); |
| 1221 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1222 | } else { |
| 1223 | repeat; |
| 1224 | } |
| 1225 | } |
| 1226 | [] L1CTL.receive { repeat; } |
| 1227 | [] T_sacch.timeout { |
| 1228 | setverdict(pass); |
| 1229 | } |
| 1230 | } |
| 1231 | } |
| 1232 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1233 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1234 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1235 | /* Set a known default SACCH filling for SI5 */ |
| 1236 | var octetstring si5 := f_rnd_octstring(19); |
| 1237 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1238 | |
| 1239 | f_l1_tune(L1CTL); |
| 1240 | RSL.clear; |
| 1241 | |
| 1242 | /* activate the logical channel */ |
| 1243 | f_est_dchan(); |
| 1244 | |
| 1245 | /* check that the specified SI5 value is actually sent */ |
| 1246 | f_sacch_present(si5); |
| 1247 | |
| 1248 | /* release the channel */ |
| 1249 | RSL.clear; |
| 1250 | f_rsl_chan_deact(); |
| 1251 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1252 | } |
| 1253 | testcase TC_sacch_filling() runs on test_CT { |
| 1254 | var ConnHdlr vc_conn; |
| 1255 | var ConnHdlrPars pars; |
| 1256 | f_init(); |
| 1257 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1258 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1259 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1260 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1261 | vc_conn.done; |
| 1262 | } |
| 1263 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1264 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1265 | } |
| 1266 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1267 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1268 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1269 | /* Set a known default SACCH filling for SI5 */ |
| 1270 | var octetstring si5 := f_rnd_octstring(19); |
| 1271 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1272 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1273 | |
| 1274 | f_l1_tune(L1CTL); |
| 1275 | RSL.clear; |
| 1276 | |
| 1277 | log("Activating channel, expecting standard SI5"); |
| 1278 | /* activate the logical channel */ |
| 1279 | f_est_dchan(); |
| 1280 | /* check that the specified SI5 value is actually sent */ |
| 1281 | f_sacch_present(si5); |
| 1282 | |
| 1283 | /* set channel-specific different SI5 */ |
| 1284 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1285 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1286 | /* check that the specified lchan-specific value is now used */ |
| 1287 | f_sacch_present(si5_diff); |
| 1288 | |
| 1289 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1290 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1291 | f_rsl_chan_deact(); |
| 1292 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1293 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1294 | f_sacch_present(si5); |
| 1295 | |
| 1296 | /* release the channel */ |
| 1297 | RSL.clear; |
| 1298 | f_rsl_chan_deact(); |
| 1299 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1300 | } |
| 1301 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1302 | var ConnHdlr vc_conn; |
| 1303 | var ConnHdlrPars pars; |
| 1304 | f_init(); |
| 1305 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1306 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1307 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1308 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1309 | vc_conn.done; |
| 1310 | } |
| 1311 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1312 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1313 | } |
| 1314 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1315 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1316 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1317 | var octetstring si5 := f_rnd_octstring(19); |
| 1318 | var octetstring si5bis := f_rnd_octstring(19); |
| 1319 | var octetstring si5ter := f_rnd_octstring(19); |
| 1320 | var octetstring si6 := f_rnd_octstring(19); |
| 1321 | |
| 1322 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1323 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1324 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1325 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1326 | |
| 1327 | f_l1_tune(L1CTL); |
| 1328 | RSL.clear; |
| 1329 | |
| 1330 | /* activate the logical channel */ |
| 1331 | f_est_dchan(); |
| 1332 | L1CTL.clear; |
| 1333 | |
| 1334 | /* check that SACCH actually are received as expected */ |
| 1335 | f_sacch_present(si5); |
| 1336 | f_sacch_present(si5bis); |
| 1337 | f_sacch_present(si5ter); |
| 1338 | f_sacch_present(si6); |
| 1339 | |
| 1340 | /* release the channel */ |
| 1341 | f_rsl_chan_deact(); |
| 1342 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1343 | } |
| 1344 | testcase TC_sacch_multi() runs on test_CT { |
| 1345 | var ConnHdlr vc_conn; |
| 1346 | var ConnHdlrPars pars; |
| 1347 | f_init(); |
| 1348 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1349 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1350 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1351 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1352 | vc_conn.done; |
| 1353 | } |
| 1354 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1356 | } |
| 1357 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1358 | /* Test if SACH information is modified as expected */ |
| 1359 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1360 | var octetstring si5 := f_rnd_octstring(19); |
| 1361 | var octetstring si6 := f_rnd_octstring(19); |
| 1362 | |
| 1363 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1364 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1365 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1366 | |
| 1367 | f_l1_tune(L1CTL); |
| 1368 | RSL.clear; |
| 1369 | |
| 1370 | /* activate the logical channel */ |
| 1371 | f_est_dchan(); |
| 1372 | L1CTL.clear; |
| 1373 | |
| 1374 | /* check that SACCH actually are received as expected */ |
| 1375 | f_sacch_present(si5); |
| 1376 | f_sacch_present(si6); |
| 1377 | |
| 1378 | /* disable SI6 */ |
| 1379 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1380 | |
| 1381 | /* check that SI5 is still transmitted */ |
| 1382 | f_sacch_present(si5); |
| 1383 | /* check if SI6 is now gone */ |
| 1384 | f_sacch_missing(si6); |
| 1385 | |
| 1386 | /* release the channel */ |
| 1387 | f_rsl_chan_deact(); |
| 1388 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1389 | } |
| 1390 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1391 | var ConnHdlr vc_conn; |
| 1392 | var ConnHdlrPars pars; |
| 1393 | f_init(); |
| 1394 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1395 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1396 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1397 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1398 | vc_conn.done; |
| 1399 | } |
| 1400 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1401 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1402 | } |
| 1403 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1404 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1405 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1406 | var octetstring si5 := f_rnd_octstring(19); |
| 1407 | var octetstring si6 := f_rnd_octstring(19); |
| 1408 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1409 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1410 | |
| 1411 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1412 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1413 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1414 | |
| 1415 | f_l1_tune(L1CTL); |
| 1416 | RSL.clear; |
| 1417 | |
| 1418 | /* activate channel with different SACCH filling */ |
| 1419 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1420 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1421 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1422 | })); |
| 1423 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1424 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1425 | f_est_dchan(more_ies := addl_ies); |
| 1426 | |
| 1427 | /* check that SACCH actually are received as expected */ |
| 1428 | f_sacch_present(si5_specific); |
| 1429 | f_sacch_present(si6_specific); |
| 1430 | |
| 1431 | /* release the channel */ |
| 1432 | f_rsl_chan_deact(); |
| 1433 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1434 | } |
| 1435 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1436 | var ConnHdlr vc_conn; |
| 1437 | var ConnHdlrPars pars; |
| 1438 | f_init(); |
| 1439 | |
| 1440 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1441 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1442 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1443 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1444 | vc_conn.done; |
| 1445 | } |
| 1446 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1447 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1448 | } |
| 1449 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1450 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1451 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1452 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1453 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1454 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1455 | |
| 1456 | f_l1_tune(L1CTL); |
| 1457 | RSL.clear; |
| 1458 | |
| 1459 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1460 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1461 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1462 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1463 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1464 | var RSL_IE_List addl_ies := { |
| 1465 | ho_ref_ie |
| 1466 | }; |
| 1467 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1468 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1469 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1470 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1471 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1472 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1473 | |
| 1474 | /* Verify that no DL SACCH is being received */ |
| 1475 | f_sacch_missing(?); |
| 1476 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1477 | /* Send handover Access Burst and expect SACCH to start */ |
| 1478 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1479 | |
| 1480 | f_sacch_present(si5); |
| 1481 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1482 | f_rsl_chan_deact(); |
| 1483 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1484 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1485 | /* Tune back to CCCH/BCCH */ |
| 1486 | f_l1_tune(L1CTL); |
| 1487 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1488 | |
| 1489 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1490 | |
| 1491 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1492 | addl_ies := { |
| 1493 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1494 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1495 | }; |
| 1496 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1497 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1498 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1499 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1500 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1501 | /* 4.1.3 "If the MS Power IE is present the BTS *may* start transmission |
| 1502 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1503 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1504 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1505 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1506 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1507 | |
| 1508 | f_sacch_present(si5); |
| 1509 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1510 | f_rsl_chan_deact(); |
| 1511 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1512 | } |
| 1513 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1514 | var ConnHdlr vc_conn; |
| 1515 | var ConnHdlrPars pars; |
| 1516 | f_init(); |
| 1517 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1518 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1519 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1520 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1521 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1522 | vc_conn.done; |
| 1523 | } |
| 1524 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1525 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1526 | } |
| 1527 | |
| 1528 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1529 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1530 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1531 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1532 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1533 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1534 | var RSL_IE_List addl_ies; |
| 1535 | |
| 1536 | f_l1_tune(L1CTL); |
| 1537 | RSL.clear; |
| 1538 | |
| 1539 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1540 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1541 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1542 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1543 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1544 | addl_ies := { |
| 1545 | ho_ref_ie |
| 1546 | }; |
| 1547 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1548 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1549 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1550 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1551 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1552 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1553 | |
| 1554 | /* Verify that no DL SACCH is being received */ |
| 1555 | f_sacch_missing(?); |
| 1556 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1557 | /* Send handover Access Burst and expect SACCH to start */ |
| 1558 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1559 | |
| 1560 | f_sacch_present(si5); |
| 1561 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1562 | f_rsl_chan_deact(); |
| 1563 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1564 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1565 | /* Tune back to CCCH/BCCH */ |
| 1566 | f_l1_tune(L1CTL); |
| 1567 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1568 | |
| 1569 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1570 | |
| 1571 | /* Activate channel on BTS side */ |
| 1572 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1573 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1574 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1575 | }; |
| 1576 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1577 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1578 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1579 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1580 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1581 | /* 4.1.4 "If only the MS Power IE is present the BTS *may* start transmission |
| 1582 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1583 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1584 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1585 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1586 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1587 | |
| 1588 | f_sacch_present(si5); |
| 1589 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1590 | f_rsl_chan_deact(); |
| 1591 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1592 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1593 | /* Tune back to CCCH/BCCH */ |
| 1594 | f_l1_tune(L1CTL); |
| 1595 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1596 | |
| 1597 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1598 | |
| 1599 | /* Activate channel on BTS side */ |
| 1600 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1601 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1602 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1603 | }; |
| 1604 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1605 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1606 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1607 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1608 | |
| 1609 | /* Verify that no DL SACCH is being received */ |
| 1610 | f_sacch_missing(?); |
| 1611 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1612 | /* Send handover Access Burst and expect SACCH to start */ |
| 1613 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1614 | |
| 1615 | f_sacch_present(si5); |
| 1616 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1617 | f_rsl_chan_deact(); |
| 1618 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1619 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1620 | /* Tune back to CCCH/BCCH */ |
| 1621 | f_l1_tune(L1CTL); |
| 1622 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1623 | |
| 1624 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1625 | |
| 1626 | /* Activate channel on BTS side */ |
| 1627 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1628 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1629 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1630 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1631 | }; |
| 1632 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1633 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1634 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1635 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1636 | |
| 1637 | /* Verify that DL SACCH is being received */ |
| 1638 | f_sacch_present(si5); |
| 1639 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1640 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1641 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1642 | |
| 1643 | f_sacch_present(si5); |
| 1644 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1645 | f_rsl_chan_deact(); |
| 1646 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1647 | } |
| 1648 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1649 | var ConnHdlr vc_conn; |
| 1650 | var ConnHdlrPars pars; |
| 1651 | f_init(); |
| 1652 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1653 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1654 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1655 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1656 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1657 | vc_conn.done; |
| 1658 | } |
| 1659 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1660 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1661 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1662 | |
| 1663 | |
| 1664 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1665 | * RACH Handling |
| 1666 | ***********************************************************************/ |
| 1667 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1668 | /* 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] | 1669 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1670 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1671 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1672 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1673 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1674 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1675 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1676 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1677 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1678 | if (emerg == true) { |
| 1679 | ra := f_rnd_ra_emerg(); |
| 1680 | } else { |
| 1681 | ra := f_rnd_ra_cs(); |
| 1682 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1683 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1684 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1685 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1686 | } |
| 1687 | fn_last := fn; |
| 1688 | |
| 1689 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1690 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1691 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1692 | [] 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] | 1693 | T.stop; |
| 1694 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1695 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1696 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1697 | } |
| 1698 | [] RSL_CCHAN.receive { repeat; } |
| 1699 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1700 | test_failed := true; |
| 1701 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1702 | } |
| 1703 | } |
| 1704 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1705 | if (test_failed) { |
| 1706 | 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] | 1707 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1708 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1709 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1710 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1711 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1712 | /* Normal variant */ |
| 1713 | testcase TC_rach_content() runs on test_CT { |
| 1714 | f_TC_rach_content(emerg := false); |
| 1715 | } |
| 1716 | |
| 1717 | /* Emergency call variant */ |
| 1718 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1719 | f_TC_rach_content(emerg := true); |
| 1720 | } |
| 1721 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1722 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1723 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1724 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1725 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1726 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1727 | f_l1_tune(L1CTL); |
| 1728 | |
| 1729 | var GsmFrameNumber fn_last := 0; |
| 1730 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1731 | var OCT1 ra := f_rnd_ra_cs(); |
| 1732 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1733 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1734 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1735 | } |
| 1736 | fn_last := fn; |
| 1737 | } |
| 1738 | var integer rsl_chrqd := 0; |
| 1739 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1740 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1741 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1742 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1743 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1744 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1745 | repeat; |
| 1746 | } |
| 1747 | [] RSL_CCHAN.receive { repeat; } |
| 1748 | [] T.timeout { } |
| 1749 | } |
| 1750 | if (rsl_chrqd == 1000) { |
| 1751 | setverdict(pass); |
| 1752 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1753 | 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] | 1754 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1755 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1756 | } |
| 1757 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1758 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1759 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1760 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1761 | } |
| 1762 | |
| 1763 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1764 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1765 | |
| 1766 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1767 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1768 | var ASP_RSL_Unitdata rx_ud; |
| 1769 | |
| 1770 | f_init_vty_bsc(); |
| 1771 | /* send load indications even at 0% load */ |
| 1772 | f_vty_load_ind_thresh(0); |
| 1773 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1774 | f_sleep(2.0); |
| 1775 | |
| 1776 | f_init(); |
| 1777 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1778 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1779 | alt { |
| 1780 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1781 | [] RSL_CCHAN.receive { repeat } |
| 1782 | } |
| 1783 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1784 | timer T := 5.0; |
| 1785 | T.start; |
| 1786 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1787 | [] 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] | 1788 | setverdict(pass); |
| 1789 | repeat; |
| 1790 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1791 | [] 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] | 1792 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1793 | repeat; |
| 1794 | } |
| 1795 | [] RSL_CCHAN.receive { |
| 1796 | repeat; |
| 1797 | } |
| 1798 | [] T.timeout { } |
| 1799 | } |
| 1800 | |
| 1801 | f_vty_load_ind_thresh(10); |
| 1802 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1803 | } |
| 1804 | |
| 1805 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1806 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1807 | var ASP_RSL_Unitdata rx_ud; |
| 1808 | |
| 1809 | f_init_vty_bsc(); |
| 1810 | f_init(); |
| 1811 | |
| 1812 | timer T := 5.0; |
| 1813 | T.start; |
| 1814 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1815 | [] 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] | 1816 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1817 | repeat; |
| 1818 | } |
| 1819 | [] RSL_CCHAN.receive { |
| 1820 | repeat; |
| 1821 | } |
| 1822 | [] T.timeout { |
| 1823 | setverdict(pass); |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1828 | } |
| 1829 | |
| 1830 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1831 | testcase TC_rach_load_count() runs on test_CT { |
| 1832 | var ASP_RSL_Unitdata rx_ud; |
| 1833 | var integer load_access_count := 0; |
| 1834 | |
| 1835 | f_init_vty_bsc(); |
| 1836 | /* send load indications even at 0% load */ |
| 1837 | f_vty_load_ind_thresh(0); |
| 1838 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1839 | f_sleep(2.0); |
| 1840 | f_init(); |
| 1841 | |
| 1842 | f_init_l1ctl(); |
| 1843 | f_sleep(1.0); |
| 1844 | f_l1_tune(L1CTL); |
| 1845 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1846 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1847 | alt { |
| 1848 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1849 | [] RSL_CCHAN.receive { repeat } |
| 1850 | } |
| 1851 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1852 | var GsmFrameNumber fn_last := 0; |
| 1853 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1854 | var OCT1 ra := f_rnd_ra_cs(); |
| 1855 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1856 | if (fn == fn_last) { |
| 1857 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1858 | } |
| 1859 | fn_last := fn; |
| 1860 | } |
| 1861 | |
| 1862 | timer T := 5.0; |
| 1863 | T.start; |
| 1864 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1865 | [] 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] | 1866 | -> value rx_ud { |
| 1867 | var RSL_IE_Body ie; |
| 1868 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1869 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1870 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1871 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1872 | } |
| 1873 | repeat; |
| 1874 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1875 | [] 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] | 1876 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1877 | repeat; |
| 1878 | } |
| 1879 | [] RSL_CCHAN.receive { |
| 1880 | repeat; |
| 1881 | } |
| 1882 | [] T.timeout { } |
| 1883 | } |
| 1884 | if (load_access_count == 1000) { |
| 1885 | setverdict(pass); |
| 1886 | } else { |
| 1887 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1888 | } |
| 1889 | |
| 1890 | f_vty_load_ind_thresh(10); |
| 1891 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1892 | } |
| 1893 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1894 | 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] | 1895 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1896 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 1897 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256)); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1898 | f_sleep(0.5); |
| 1899 | |
| 1900 | /* Transmit RACH request + wait for confirmation */ |
| 1901 | var OCT1 ra := f_rnd_ra_cs(); |
| 1902 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1903 | |
| 1904 | /* Check for expected result */ |
| 1905 | timer T := 1.5; |
| 1906 | T.start; |
| 1907 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1908 | [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] | 1909 | setverdict(pass); |
| 1910 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1911 | [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] | 1912 | 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] | 1913 | } |
| 1914 | [] RSL_CCHAN.receive { repeat; } |
| 1915 | [not expect_pass] T.timeout { |
| 1916 | setverdict(pass); |
| 1917 | } |
| 1918 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1919 | 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] | 1920 | } |
| 1921 | } |
| 1922 | } |
| 1923 | |
| 1924 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1925 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1926 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1927 | f_init_l1ctl(); |
| 1928 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1929 | f_sleep(1.0); |
| 1930 | |
| 1931 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1932 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1933 | /* We allow early arrival up to 2 symbols */ |
| 1934 | f_rach_toffs(-1*256, true); |
| 1935 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1936 | f_rach_toffs(-10*256, false); |
| 1937 | |
| 1938 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1939 | f_rach_toffs(0, true); |
| 1940 | f_rach_toffs(32*256, true); |
| 1941 | f_rach_toffs(63*256, true); |
| 1942 | |
| 1943 | /* more than 63 bits is not legal / permitted */ |
| 1944 | f_rach_toffs(64*256, false); |
| 1945 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1946 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1947 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1948 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1949 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1950 | var GsmFrameNumber fn; |
| 1951 | var RSL_Message rm; |
| 1952 | |
| 1953 | f_l1_tune(L1CTL); |
| 1954 | RSL.clear; |
| 1955 | |
| 1956 | /* Generate a random Handover Reference */ |
| 1957 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1958 | |
| 1959 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1960 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1961 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1962 | |
| 1963 | /* Activate a channel on the BTS side (no encryption) */ |
| 1964 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1965 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1966 | |
| 1967 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1968 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1969 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1970 | |
| 1971 | /* Send handover Access Burst */ |
| 1972 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1973 | |
| 1974 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1975 | |
| 1976 | /* Wait for handover detection */ |
| 1977 | timer T := 3.0; |
| 1978 | T.start; |
| 1979 | alt { |
| 1980 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1981 | log("Handover RACH has been detected: ", rm); |
| 1982 | setverdict(pass); |
| 1983 | } |
| 1984 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1985 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1986 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1987 | } |
| 1988 | [] RSL.receive { repeat; } |
| 1989 | [] T.timeout { |
| 1990 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1991 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | /* Release the channel */ |
| 1996 | f_rsl_chan_deact(); |
| 1997 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1998 | } |
| 1999 | |
| 2000 | /* Test handover RACH detection */ |
| 2001 | testcase TC_ho_rach() runs on test_CT { |
| 2002 | var ConnHdlrPars pars; |
| 2003 | var ConnHdlr vc_conn; |
| 2004 | |
| 2005 | f_init(); |
| 2006 | |
| 2007 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 2008 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 2009 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 2010 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 2011 | vc_conn.done; |
| 2012 | } |
| 2013 | |
| 2014 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2015 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2016 | } |
| 2017 | |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 2018 | /* Test sending of the RR Physical Information message on DCCH */ |
| 2019 | private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr { |
| 2020 | var PDU_ML3_NW_MS dcch_pdu; |
| 2021 | var integer count := 0; |
| 2022 | var L1ctlDlMessage dl; |
| 2023 | timer T; |
| 2024 | |
| 2025 | f_l1_tune(L1CTL); |
| 2026 | RSL.clear; |
| 2027 | |
| 2028 | /* Generate a random Handover Reference */ |
| 2029 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 2030 | |
| 2031 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 2032 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 2033 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 2034 | |
| 2035 | /* Activate a channel on the BTS side (no encryption) */ |
| 2036 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 2037 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 2038 | |
| 2039 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 2040 | * waiting for Immediate Assignment and sending of an Access Burst. */ |
| 2041 | f_l1ctl_est_dchan(L1CTL, g_pars); /* FIXME: disable Uplink Tx */ |
| 2042 | |
| 2043 | /* Expect nothing to be transmitted on Downlink DCCH. Nothing in this |
| 2044 | * context means any L2 frames, not only the RR Physical Information. */ |
| 2045 | T.start(2.0); |
| 2046 | L1CTL.clear; |
| 2047 | alt { |
| 2048 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value dl { |
| 2049 | setverdict(fail, "Rx unexpected Downlink DCCH (before handover RACH): ", dl); |
| 2050 | T.stop; |
| 2051 | } |
| 2052 | [] L1CTL.receive { repeat; } |
| 2053 | [] T.timeout { setverdict(pass); } |
| 2054 | } |
| 2055 | |
| 2056 | /* Send handover Access Burst */ |
| 2057 | log("Sending handover Access Burst"); |
| 2058 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 2059 | |
| 2060 | /* Expect RR Physical Information being sent on Downlink DCCH Ny1 times */ |
| 2061 | T.start(int2float(mp_ho_t3105_ms * mp_ho_ny1) / 1000.0 + 1.0); |
| 2062 | L1CTL.clear; |
| 2063 | alt { |
| 2064 | [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */ |
| 2065 | [] as_dl_dcch_pdu(dcch_pdu, tr_RRM_PhysicalInfo) { |
| 2066 | log("Rx RR Physical Information: ", dcch_pdu); |
| 2067 | /* Wait until the count reaches Ny1 */ |
| 2068 | count := count + 1; |
| 2069 | if (count < mp_ho_ny1) |
| 2070 | { repeat; } |
| 2071 | setverdict(pass); |
| 2072 | } |
| 2073 | [] as_dl_dcch_pdu(dcch_pdu, ?) { |
| 2074 | setverdict(fail, "Rx unexpected DCCH PDU: ", dcch_pdu); |
| 2075 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2076 | } |
| 2077 | [] L1CTL.receive { repeat; } |
| 2078 | [] T.timeout { |
| 2079 | setverdict(fail, "Timeout waiting for RR Physical Information"); |
| 2080 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | /* Release the channel */ |
| 2085 | f_rsl_chan_deact(); |
| 2086 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2087 | } |
| 2088 | testcase TC_ho_physical_info() runs on test_CT { |
| 2089 | var ConnHdlrPars pars; |
| 2090 | var ConnHdlr vc_conn; |
| 2091 | |
| 2092 | f_init(); |
| 2093 | |
| 2094 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 2095 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 2096 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
| 2097 | vc_conn := f_start_handler(refers(f_TC_ho_physical_info), pars); |
| 2098 | vc_conn.done; |
| 2099 | } |
| 2100 | |
| 2101 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2102 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2103 | } |
| 2104 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2105 | /*********************************************************************** |
| 2106 | * Measurement Processing / Reporting |
| 2107 | ***********************************************************************/ |
| 2108 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2109 | private template (value) LapdmAddressField |
| 2110 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 2111 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2112 | spare := '0'B, |
| 2113 | lpd := 0, |
| 2114 | sapi := sapi, |
| 2115 | c_r := c_r, |
| 2116 | ea := true |
| 2117 | } |
| 2118 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2119 | private template (value) LapdmFrameAB |
| 2120 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 2121 | template (value) GsmRrL3Message l3, |
| 2122 | template (value) boolean c_r := false, |
| 2123 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2124 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2125 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2126 | len := 0, /* overwritten */ |
| 2127 | m := false, |
| 2128 | el := 1, |
Vadim Yanitskiy | 16e2991 | 2022-03-12 13:26:21 +0300 | [diff] [blame] | 2129 | payload := enc_GsmRrL3Message(valueof(l3)), |
| 2130 | padding := ''O |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2131 | } |
| 2132 | |
| 2133 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2134 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2135 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2136 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2137 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2138 | [] 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] | 2139 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2140 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2141 | lb := ts_LAPDm_AB(0, ts_MEAS_REP(g_pars.l1_pars.meas_valid, |
Vadim Yanitskiy | cb57c1b | 2020-11-11 20:57:15 +0700 | [diff] [blame] | 2142 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 2143 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 2144 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 2145 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2146 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 2147 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2148 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 2149 | g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2150 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 2151 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 2152 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '00'O); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2153 | |
| 2154 | log("Sending Measurement Report: ", l1h, l2); |
| 2155 | 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] | 2156 | repeat; |
| 2157 | } |
| 2158 | } |
| 2159 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2160 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 2161 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 2162 | boolean do_apply := true) |
| 2163 | runs on ConnHdlr |
| 2164 | { |
| 2165 | var L1ctlDlMessage l1_dl; |
| 2166 | |
| 2167 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2168 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 2169 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 2170 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 2171 | |
| 2172 | if (do_apply) { |
| 2173 | /* Update TA and MS power to follow what BTS requests */ |
| 2174 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 2175 | } |
| 2176 | } |
| 2177 | } |
| 2178 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2179 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2180 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2181 | [] 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] | 2182 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 2183 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 2184 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2185 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2186 | repeat; |
| 2187 | } |
| 2188 | } |
| 2189 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2190 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 2191 | var L1ctlDlMessage l1_dl; |
| 2192 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 2193 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2194 | |
| 2195 | /* occasionaly inject FACCH frames into the uplink */ |
| 2196 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 2197 | var octetstring pl := '010301'O; |
| 2198 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2199 | f_pad_oct(pl, 23, '2B'O))); |
| 2200 | } else { |
| 2201 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 2202 | l1_dl.payload.traffic_ind.data)); |
| 2203 | } |
| 2204 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2205 | repeat; |
| 2206 | } |
| 2207 | } |
| 2208 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2209 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2210 | uint6_t rxlev, |
| 2211 | uint3_t rxqual |
| 2212 | } |
| 2213 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2214 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2215 | MeasElem full, |
| 2216 | MeasElem sub |
| 2217 | } |
| 2218 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2219 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2220 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2221 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2222 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2223 | MeasElemFS meas_ul, |
| 2224 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2225 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2226 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2227 | uint8_t ms_actual_ta, |
| 2228 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 2232 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 2233 | return 63 + (toffs256s/256); |
| 2234 | } |
| 2235 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2236 | private function f_max(integer a, integer b) return integer { |
| 2237 | if (a > b) { |
| 2238 | return a; |
| 2239 | } else { |
| 2240 | return b; |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | private function f_min(integer a, integer b) return integer { |
| 2245 | if (a < b) { |
| 2246 | return a; |
| 2247 | } else { |
| 2248 | return b; |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 2253 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 2254 | val := val - tolerance; |
| 2255 | return f_max(val, min); |
| 2256 | } |
| 2257 | |
| 2258 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 2259 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 2260 | val := val + tolerance; |
| 2261 | return f_min(val, max); |
| 2262 | } |
| 2263 | |
| 2264 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 2265 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 2266 | return template integer { |
| 2267 | var template integer ret; |
| 2268 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 2269 | return ret; |
| 2270 | } |
| 2271 | |
| 2272 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2273 | /* build a template for matching measurement results against */ |
| 2274 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 2275 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2276 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2277 | len := 3, |
| 2278 | rfu := '0'B, |
| 2279 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2280 | 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] | 2281 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2282 | 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] | 2283 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2284 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2285 | 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] | 2286 | supp_meas_info := omit |
| 2287 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2288 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2289 | ul_meas.len := (3+8); |
| 2290 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2291 | 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] | 2292 | toa256_min := ?, |
| 2293 | toa256_max := ?, |
| 2294 | toa256_std_dev := ? |
| 2295 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2296 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2297 | var template RSL_IE_BS_Power bs_power := { |
| 2298 | reserved := 0, |
| 2299 | epc := false, |
| 2300 | fpc := false, |
| 2301 | power_level := l1p.bs_power_level |
| 2302 | }; |
| 2303 | var template RSL_IE_L1Info l1_info := { |
| 2304 | ms_power_lvl := l1p.ms_power_level, |
| 2305 | fpc := false, |
| 2306 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2307 | 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] | 2308 | }; |
| 2309 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2310 | 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] | 2311 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2312 | ?, t_toffs); |
| 2313 | } |
| 2314 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2315 | /* build a template for matching measurement results that do not contain any |
| 2316 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2317 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2318 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2319 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2320 | len := 3, |
| 2321 | rfu := '0'B, |
| 2322 | dtx_d := l1p.dtx_enabled, |
| 2323 | rxlev_f_u := ?, |
| 2324 | reserved1 := '00'B, |
| 2325 | rxlev_s_u := ?, |
| 2326 | reserved2 := '00'B, |
| 2327 | rxq_f_u := ?, |
| 2328 | rxq_s_u := ?, |
| 2329 | supp_meas_info := omit |
| 2330 | }; |
| 2331 | if (l1p.toa256_enabled) { |
| 2332 | ul_meas.len := (3+8); |
| 2333 | ul_meas.supp_meas_info := { |
| 2334 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2335 | toa256_min := ?, |
| 2336 | toa256_max := ?, |
| 2337 | toa256_std_dev := ? |
| 2338 | } |
| 2339 | } |
| 2340 | var template RSL_IE_BS_Power bs_power := { |
| 2341 | reserved := 0, |
| 2342 | epc := false, |
| 2343 | fpc := false, |
| 2344 | power_level := l1p.bs_power_level |
| 2345 | }; |
| 2346 | |
| 2347 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2348 | } |
| 2349 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2350 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2351 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2352 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2353 | var boolean chan_est := false; |
| 2354 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2355 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2356 | |
| 2357 | /* Receive osmocom specific measurement reports. This is the normal |
| 2358 | * case. Here we verify that the measurement reports we sent are |
| 2359 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2360 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2361 | /* increment counter of next to-be-expected meas rep */ |
| 2362 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2363 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2364 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2365 | |
| 2366 | /* The following two cases may only happen in the beginning |
| 2367 | * of the channel establishment phase. Once we have received |
| 2368 | * the "our" measurement report the first time, the channel |
| 2369 | * is established and empty or hardcoded TRXCON reports must |
| 2370 | * not occur anymore. */ |
| 2371 | chan_est := true; |
| 2372 | |
| 2373 | repeat; |
| 2374 | } |
| 2375 | |
| 2376 | /* When the BTS has established the channel, the MS might need slightly |
| 2377 | * more time to establish the channel and actually start sending. The |
| 2378 | * result is then a measurement report that just lacks the measurement |
| 2379 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2380 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2381 | /* increment counter of next to-be-expected meas rep */ |
| 2382 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2383 | /* Re-start the timer expecting the next MEAS RES */ |
| 2384 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2385 | repeat; |
| 2386 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2387 | |
| 2388 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2389 | * measurements if the TTCN3 side does not supply measurement input in |
| 2390 | * time. In those cases TRXCON will either use a cached measurement |
| 2391 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2392 | * report the templates above will not match. We tolerate this |
| 2393 | * behavior, but only once. */ |
| 2394 | [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] | 2395 | /* increment counter of next to-be-expected meas rep */ |
| 2396 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2397 | if (g_first_meas_res) { |
| 2398 | g_first_meas_res := false; |
| 2399 | repeat; |
| 2400 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2401 | 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] | 2402 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2403 | } |
| 2404 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2405 | 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] | 2406 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2407 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2408 | 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] | 2409 | } |
| 2410 | } |
| 2411 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2412 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2413 | select (rsl_alg_id) { |
| 2414 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2415 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2416 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2417 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2418 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2419 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2420 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2421 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2422 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2423 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2424 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2425 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2426 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2427 | } |
| 2428 | } |
| 2429 | } |
| 2430 | |
| 2431 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2432 | select (rsl_alg_id) { |
| 2433 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2434 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2435 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2436 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2437 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2438 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2439 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2440 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2441 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2442 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2443 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2444 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2445 | } |
| 2446 | } |
| 2447 | } |
| 2448 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2449 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2450 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2451 | var GsmFrameNumber fn; |
| 2452 | timer T := 8.0; |
| 2453 | |
| 2454 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2455 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2456 | |
| 2457 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2458 | /* Send the actual RACH */ |
| 2459 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2460 | |
| 2461 | T.start; |
| 2462 | alt { |
| 2463 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2464 | [] T.timeout { |
| 2465 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2466 | } |
| 2467 | } |
| 2468 | T.stop |
| 2469 | return fn; |
| 2470 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2471 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2472 | /* Tune to a dedicated channel: L1CTL only */ |
| 2473 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2474 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2475 | var TrxParsItem trx_pars := mp_trx_pars[pars.trx_nr]; |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2476 | pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2477 | trx_pars.arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2478 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2479 | pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2480 | pars.fhp.maio_hsn.hsn, |
| 2481 | pars.fhp.maio_hsn.maio, |
| 2482 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2483 | } |
| 2484 | } |
| 2485 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2486 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2487 | private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr { |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2488 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2489 | |
| 2490 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2491 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2492 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2493 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2494 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2495 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2496 | } else { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2497 | var TrxParsItem trx_pars := mp_trx_pars[g_pars.trx_nr]; |
| 2498 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, trx_pars.arfcn, g_pars.tsc)); |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2499 | } |
| 2500 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2501 | /* enable dedicated mode */ |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 2502 | f_l1ctl_est_dchan(L1CTL, g_pars); |
| 2503 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2504 | /* enable encryption, if requested */ |
| 2505 | if (encr_enable) { |
| 2506 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2507 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2508 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2509 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2510 | /* Send TCH Mode Request to the L1 if needed */ |
| 2511 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2512 | var L1ctlTchMode tch_mode; |
| 2513 | |
| 2514 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2515 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2516 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2517 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
| 2518 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; } |
| 2519 | case else { |
| 2520 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2521 | " is not supported by the L1, falling back to signalling"); |
| 2522 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | f_L1CTL_TCH_MODE(L1CTL, tch_mode); |
| 2527 | } |
| 2528 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2529 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2530 | } |
| 2531 | |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2532 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2533 | friend function f_rtpem_activate(inout octetstring payload, |
| 2534 | RtpemConfig cfg := c_RtpemDefaultCfg, |
| 2535 | RtpemMode mode := RTPEM_MODE_BIDIR) |
| 2536 | runs on ConnHdlr { |
| 2537 | /* Step 0: initialize, connect and start the emulation component */ |
| 2538 | vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM"); |
| 2539 | map(vc_RTPEM:RTP, system:RTP); |
| 2540 | map(vc_RTPEM:RTCP, system:RTCP); |
| 2541 | connect(vc_RTPEM:CTRL, self:RTPEM_CTRL); |
| 2542 | connect(vc_RTPEM:DATA, self:RTPEM_DATA); |
| 2543 | vc_RTPEM.start(RTP_Emulation.f_main()); |
| 2544 | |
| 2545 | /* Step 1: configure the RTP parameters */ |
| 2546 | var integer payload_len := 0; |
| 2547 | var octetstring hdr := ''O; |
| 2548 | |
| 2549 | select (g_pars.chan_mode) { |
| 2550 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */ |
| 2551 | { payload_len := 33; hdr := 'D0'O; } |
| 2552 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */ |
| 2553 | { payload_len := 15; hdr := '00'O; } |
| 2554 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */ |
| 2555 | { payload_len := 31; hdr := 'C0'O; } |
| 2556 | case else { /* FIXME: also handle TCH/AFS and TCH/AHS */ |
| 2557 | setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode); |
| 2558 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2559 | } |
| 2560 | } |
| 2561 | |
| 2562 | /* Pad the payload to conform the expected length */ |
| 2563 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2564 | cfg.tx_fixed_payload := payload; |
| 2565 | f_rtpem_configure(RTPEM_CTRL, cfg); |
| 2566 | |
| 2567 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2568 | var PortNumber rtpem_bind_port := mp_rtpem_bind_port; |
| 2569 | f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port); |
| 2570 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2571 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2572 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2573 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2574 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2575 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit), |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2576 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2577 | "IPA CRCX ACK"); |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2578 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2579 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2580 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2581 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2582 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2583 | remote_ip := f_inet_addr(mp_rtpem_bind_ip), |
| 2584 | remote_port := rtpem_bind_port, |
| 2585 | rtp_pt2 := 0), |
| 2586 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?), |
| 2587 | "IPA MDCX ACK"); |
| 2588 | |
| 2589 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2590 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2591 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2592 | f_rtpem_connect(RTPEM_CTRL, bts_bind_ip, bts_bind_port); |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2593 | |
| 2594 | /* Step 5: set the given RTP emulation mode */ |
| 2595 | f_rtpem_mode(RTPEM_CTRL, mode); |
| 2596 | } |
| 2597 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2598 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2599 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2600 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2601 | RSL.clear; |
| 2602 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2603 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2604 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2605 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2606 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2607 | |
| 2608 | f_est_dchan(); |
| 2609 | |
| 2610 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2611 | * RSL measurement reports on Abis side */ |
| 2612 | timer T := 8.0; |
| 2613 | T.start; |
| 2614 | alt { |
| 2615 | [] as_l1_sacch(); |
| 2616 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2617 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2618 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2619 | [] L1CTL.receive { repeat; } |
| 2620 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2621 | /* 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] | 2622 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2623 | setverdict(pass); |
| 2624 | } |
| 2625 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2626 | 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] | 2627 | } |
| 2628 | } |
| 2629 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2630 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2631 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2632 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2633 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2634 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2635 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2636 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2637 | timer Tup := 10.0; |
| 2638 | Tup.start; |
| 2639 | alt { |
| 2640 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2641 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2642 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2643 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2644 | if (rx_lvl != max_rx_lvl) { |
| 2645 | repeat; |
| 2646 | } |
| 2647 | Tup.stop; |
| 2648 | } |
| 2649 | [] L1CTL.receive { repeat; } |
| 2650 | [] Tup.timeout { |
| 2651 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2652 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2653 | } |
| 2654 | } |
| 2655 | return max_rx_lvl; |
| 2656 | } |
| 2657 | |
| 2658 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2659 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2660 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2661 | var integer initial_rx_lvl := -1; |
| 2662 | var integer last_rx_lvl := -1; |
| 2663 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2664 | |
| 2665 | timer T := 2.0; |
| 2666 | alt { |
| 2667 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2668 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2669 | log("Received rx_level=", rx_lvl); |
| 2670 | if (initial_rx_lvl == -1) { |
| 2671 | initial_rx_lvl := rx_lvl; |
| 2672 | last_rx_lvl := rx_lvl; |
| 2673 | |
| 2674 | /* Expect a somehow low value during first received messages */ |
| 2675 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2676 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2677 | log2str("Detected high initial tx power during ramp up: ", |
| 2678 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2679 | } |
| 2680 | } |
| 2681 | |
| 2682 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2683 | if (rx_lvl > max_rx_lvl) { |
| 2684 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2685 | log2str("Detected Tx power higher than full power: ", |
| 2686 | rx_lvl , " > ", max_rx_lvl)); |
| 2687 | } |
| 2688 | |
| 2689 | /* Make sure it never decreases, since we are rumping up */ |
| 2690 | if (last_rx_lvl > rx_lvl) { |
| 2691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2692 | log2str("Detected Tx power decrease during ramp up: ", |
| 2693 | last_rx_lvl , " -> ", rx_lvl)); |
| 2694 | } |
| 2695 | |
| 2696 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2697 | /* We reached the maximum power, start timer and receive |
| 2698 | /* a few more to make sure we don't surpass it */ |
| 2699 | log("Reached full power, wating a bit more until success"); |
| 2700 | T.start; |
| 2701 | } |
| 2702 | |
| 2703 | last_rx_lvl := rx_lvl; |
| 2704 | repeat; |
| 2705 | } |
| 2706 | [] L1CTL.receive { repeat; } |
| 2707 | [] T.timeout { } |
| 2708 | } |
| 2709 | |
| 2710 | /* We didn't increase tx power during ramp up */ |
| 2711 | if (initial_rx_lvl < last_rx_lvl) { |
| 2712 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2713 | } else { |
| 2714 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2715 | log2str("No Tx power increase during whole ramp up: ", |
| 2716 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2717 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2718 | } |
| 2719 | |
| 2720 | /* verify BTS ramps power down to rx_level 0 */ |
| 2721 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2722 | var L1ctlDlMessage l1_dl; |
| 2723 | var integer last_rx_lvl := max_rx_lvl; |
| 2724 | |
| 2725 | timer Tdown := 5.0; |
| 2726 | Tdown.start; |
| 2727 | alt { |
| 2728 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2729 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2730 | log("Received rx_level=", rx_lvl); |
| 2731 | |
| 2732 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2733 | if (rx_lvl > max_rx_lvl) { |
| 2734 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2735 | log2str("Detected Tx power higher than full power: ", |
| 2736 | rx_lvl , " > ", max_rx_lvl)); |
| 2737 | } |
| 2738 | |
| 2739 | /* Make sure it never increases, since we are rumping down */ |
| 2740 | if (last_rx_lvl < rx_lvl) { |
| 2741 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2742 | log2str("Detected Tx power increase during ramp up: ", |
| 2743 | last_rx_lvl , " -> ", rx_lvl)); |
| 2744 | } |
| 2745 | |
| 2746 | last_rx_lvl := rx_lvl; |
| 2747 | if (last_rx_lvl != 0) { |
| 2748 | repeat; |
| 2749 | } |
| 2750 | /* we reached power level 0, we are done */ |
| 2751 | Tdown.stop; |
| 2752 | } |
| 2753 | [] L1CTL.receive { repeat; } |
| 2754 | [] Tdown.timeout { } |
| 2755 | } |
| 2756 | |
| 2757 | /* We didn't increase tx power during ramp down */ |
| 2758 | if (max_rx_lvl > last_rx_lvl) { |
| 2759 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2760 | } else { |
| 2761 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2762 | log2str("No Tx power decrease during whole ramp down: ", |
| 2763 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2764 | } |
| 2765 | } |
| 2766 | |
| 2767 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2768 | 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] | 2769 | f_l1_tune(L1CTL); |
| 2770 | RSL.clear; |
| 2771 | |
| 2772 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2773 | |
| 2774 | setverdict(pass); |
| 2775 | } |
| 2776 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2777 | var ConnHdlr vc_conn; |
| 2778 | var ConnHdlrPars pars; |
| 2779 | f_init(); |
| 2780 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2781 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2782 | pcu_comp := false, trxc_comp := true); |
| 2783 | vc_conn.done; |
| 2784 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2785 | } |
| 2786 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2787 | /* 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] | 2788 | 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] | 2789 | f_connhdlr_init_vty_bsc(); |
| 2790 | |
| 2791 | f_l1_tune(L1CTL); |
| 2792 | RSL.clear; |
| 2793 | |
| 2794 | /* Wait until BTS is started and at full power */ |
| 2795 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2796 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2797 | |
| 2798 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2799 | f_verify_ramp_down(max_rx_lvl); |
| 2800 | |
| 2801 | setverdict(pass); |
| 2802 | } |
| 2803 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2804 | var ConnHdlr vc_conn; |
| 2805 | var ConnHdlrPars pars; |
| 2806 | f_init(); |
| 2807 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2808 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2809 | pcu_comp := false, trxc_comp := true); |
| 2810 | vc_conn.done; |
| 2811 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2812 | } |
| 2813 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2814 | /* Verify Tx power: |
| 2815 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2816 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2817 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2818 | 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] | 2819 | var L1ctlDlMessage l1_dl; |
| 2820 | var integer last_rx_lvl; |
| 2821 | |
| 2822 | f_connhdlr_init_vty_bsc(); |
| 2823 | |
| 2824 | f_l1_tune(L1CTL); |
| 2825 | RSL.clear; |
| 2826 | |
| 2827 | /* Wait until BTS is started and at full power */ |
| 2828 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2829 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2830 | |
| 2831 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2832 | f_vty_enter_cfg_trx(BSCVTY); |
| 2833 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2834 | last_rx_lvl := max_rx_lvl; |
| 2835 | f_verify_ramp_down(max_rx_lvl); |
| 2836 | |
| 2837 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2838 | * anymore because scheduler has stopped after ramping down */ |
| 2839 | f_sleep(2.0); |
| 2840 | L1CTL.clear; |
| 2841 | timer Tlocked := 2.0; |
| 2842 | Tlocked.start; |
| 2843 | alt { |
| 2844 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2845 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2846 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2847 | } |
| 2848 | [] L1CTL.receive { repeat; } |
| 2849 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2850 | } |
| 2851 | |
| 2852 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2853 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2854 | f_verify_ramp_up(); |
| 2855 | setverdict(pass); |
| 2856 | } |
| 2857 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2858 | var ConnHdlr vc_conn; |
| 2859 | var ConnHdlrPars pars; |
| 2860 | f_init(); |
| 2861 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2862 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2863 | pcu_comp := false, trxc_comp := true); |
| 2864 | vc_conn.done; |
| 2865 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2866 | } |
| 2867 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2868 | 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] | 2869 | timer T := 8.0; |
| 2870 | T.start; |
| 2871 | var RSL_Message rsl; |
| 2872 | alt { |
| 2873 | [] as_l1_sacch(); |
| 2874 | [] L1CTL.receive { repeat; } |
| 2875 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 2876 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 2877 | setverdict(pass) |
| 2878 | } else { |
| 2879 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 2880 | } |
| 2881 | } |
| 2882 | [] T.timeout { |
| 2883 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 2884 | } |
| 2885 | } |
| 2886 | } |
| 2887 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2888 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2889 | * set _during_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2890 | 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] | 2891 | f_l1_tune(L1CTL); |
| 2892 | RSL.clear; |
| 2893 | |
| 2894 | if (mp_bts_trxc_port != -1) { |
| 2895 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2896 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2897 | } |
| 2898 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2899 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2900 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2901 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2902 | |
| 2903 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2904 | |
| 2905 | f_check_meas_bs_power_level(pwr_var); |
| 2906 | |
| 2907 | f_rsl_chan_deact(); |
| 2908 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2909 | } |
| 2910 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2911 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 2912 | * set _after_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2913 | 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] | 2914 | f_l1_tune(L1CTL); |
| 2915 | RSL.clear; |
| 2916 | |
| 2917 | if (mp_bts_trxc_port != -1) { |
| 2918 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2919 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2920 | } |
| 2921 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2922 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2923 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2924 | |
| 2925 | f_est_dchan(); |
| 2926 | |
| 2927 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2928 | |
| 2929 | f_check_meas_bs_power_level(pwr_var); |
| 2930 | |
| 2931 | f_rsl_chan_deact(); |
| 2932 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2933 | } |
| 2934 | |
| 2935 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2936 | var ConnHdlr vc_conn; |
| 2937 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2938 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2939 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2940 | |
| 2941 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 2942 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2943 | pcu_comp := false, trxc_comp := true); |
| 2944 | vc_conn.done; |
| 2945 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2946 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2947 | } |
| 2948 | |
| 2949 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2950 | var ConnHdlr vc_conn; |
| 2951 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2952 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2953 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 2954 | |
| 2955 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 2956 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2957 | pcu_comp := false, trxc_comp := true); |
| 2958 | vc_conn.done; |
| 2959 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 2960 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2961 | } |
| 2962 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 2963 | /* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2964 | * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds. |
| 2965 | * 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] | 2966 | 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] | 2967 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2968 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2969 | |
| 2970 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2971 | f_l1_tune(L1CTL); |
| 2972 | RSL.clear; |
| 2973 | |
| 2974 | var RSL_IE_List addl_ies; |
| 2975 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2976 | |
| 2977 | addl_ies := { |
| 2978 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2979 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2980 | }; |
| 2981 | |
| 2982 | /* establish with power parameters */ |
| 2983 | f_est_dchan(more_ies := addl_ies); |
| 2984 | |
| 2985 | /* set a high value to ensure L1 power control level increases */ |
| 2986 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2987 | |
| 2988 | timer T2 := 6.0; |
| 2989 | T2.start; |
| 2990 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2991 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 2992 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 2993 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2994 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2995 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2996 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2997 | T2.stop; |
| 2998 | } |
| 2999 | [] L1CTL.receive { repeat; } |
| 3000 | [] T2.timeout { |
| 3001 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3002 | "Power Level in L1 header has not increased sufficiently"); |
| 3003 | } |
| 3004 | } |
| 3005 | |
| 3006 | /* set a low value to ensure L1 power control level decreases */ |
| 3007 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 3008 | |
| 3009 | timer T4 := 6.0; |
| 3010 | T4.start; |
| 3011 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3012 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3013 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3014 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3015 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3016 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 3017 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3018 | T4.stop; |
| 3019 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 3020 | } |
| 3021 | [] L1CTL.receive { repeat; } |
| 3022 | [] T4.timeout { |
| 3023 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3024 | "Power Level in L1 header has not decreased sufficiently"); |
| 3025 | } |
| 3026 | } |
| 3027 | |
| 3028 | f_rsl_chan_deact(); |
| 3029 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3030 | |
| 3031 | } |
| 3032 | |
| 3033 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3034 | 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] | 3035 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3036 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3037 | |
| 3038 | /* set a low value to ensure power increases */ |
| 3039 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3040 | f_l1_tune(L1CTL); |
| 3041 | RSL.clear; |
| 3042 | |
| 3043 | var RSL_IE_List addl_ies; |
| 3044 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3045 | |
| 3046 | addl_ies := { |
| 3047 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3048 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3049 | }; |
| 3050 | |
| 3051 | /* establish with power parameters */ |
| 3052 | f_est_dchan(more_ies := addl_ies); |
| 3053 | |
| 3054 | timer T1 := 10.0; |
| 3055 | T1.start; |
| 3056 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3057 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3058 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3059 | repeat; |
| 3060 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3061 | [] L1CTL.receive { repeat; } |
| 3062 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3063 | if (not isbound(l1h)) { |
| 3064 | setverdict(fail, "No SACCH blocks were received"); |
| 3065 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3066 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 3067 | } |
| 3068 | } |
| 3069 | } |
| 3070 | |
| 3071 | f_rsl_chan_deact(); |
| 3072 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3073 | |
| 3074 | } |
| 3075 | |
| 3076 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3077 | private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3078 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3079 | var uint5_t pwr_var := 15; |
| 3080 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 3081 | |
| 3082 | /* set a low value to ensure power increases */ |
| 3083 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3084 | f_l1_tune(L1CTL); |
| 3085 | RSL.clear; |
| 3086 | |
| 3087 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3088 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3089 | |
| 3090 | /* establish with fixed power level */ |
| 3091 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3092 | |
| 3093 | /* check our initial power level */ |
| 3094 | f_wait_for_l1_power_level(pwr_var); |
| 3095 | |
| 3096 | /* update power param to enable power loop |
| 3097 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 3098 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 3099 | |
Vadim Yanitskiy | 93ad814 | 2022-04-08 01:52:13 +0300 | [diff] [blame] | 3100 | /* By default, the MS power loop gets triggered every 4th SACCH block (1.92s). |
| 3101 | * We need 9 * 4 dB steps to get from 0 dBm to 33 dBm, so 9 * 1.92s total. |
| 3102 | * Add an extra offset to avoid race conditions: +1.92s. */ |
| 3103 | timer T1 := 9.0 * 1.92 + 1.92; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3104 | T1.start; |
| 3105 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3106 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3107 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3108 | repeat; |
| 3109 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3110 | [] L1CTL.receive { repeat; } |
| 3111 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3112 | if (not isbound(l1h)) { |
| 3113 | setverdict(fail, "No SACCH blocks were received"); |
| 3114 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3115 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 3116 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3117 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 3118 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3119 | } |
| 3120 | } |
| 3121 | } |
| 3122 | |
| 3123 | f_rsl_chan_deact(); |
| 3124 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3125 | |
| 3126 | } |
| 3127 | |
| 3128 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3129 | private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3130 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3131 | |
| 3132 | /* set a high value to ensure power decreases */ |
| 3133 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3134 | f_l1_tune(L1CTL); |
| 3135 | RSL.clear; |
| 3136 | |
| 3137 | var uint5_t pwr_var := 5; |
| 3138 | var uint5_t pwr_target_val := 15; |
| 3139 | |
| 3140 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3141 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3142 | |
| 3143 | /* establish with fixed power level */ |
| 3144 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3145 | |
| 3146 | /* check our initial power level */ |
| 3147 | f_wait_for_l1_power_level(pwr_var); |
| 3148 | |
| 3149 | /* update power param to enable power loop |
| 3150 | 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] | 3151 | 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] | 3152 | |
| 3153 | /* wait, then check that our power level was increased */ |
| 3154 | timer T1 := 10.0; |
| 3155 | T1.start; |
| 3156 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3157 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3158 | [] L1CTL.receive { repeat; } |
| 3159 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3160 | if (not isbound(l1h)) { |
| 3161 | setverdict(fail, "No SACCH blocks were received"); |
| 3162 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 3163 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3164 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3165 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3166 | } |
| 3167 | } |
| 3168 | } |
| 3169 | |
| 3170 | f_rsl_chan_deact(); |
| 3171 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3172 | |
| 3173 | } |
| 3174 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3175 | /* See if the power level remains constant when MS Power Parameters IE |
| 3176 | * is _absent_ in the CHANnel ACTIVation message. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3177 | private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3178 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3179 | |
| 3180 | /* set a high value to ensure power decreases */ |
| 3181 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3182 | f_l1_tune(L1CTL); |
| 3183 | RSL.clear; |
| 3184 | |
| 3185 | var uint5_t pwr_var := 5; |
| 3186 | |
| 3187 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3188 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3189 | |
| 3190 | /* establish with fixed power level */ |
| 3191 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3192 | |
| 3193 | /* check our initial power level */ |
| 3194 | f_wait_for_l1_power_level(pwr_var); |
| 3195 | |
| 3196 | /* wait, then check that our power level did not change */ |
| 3197 | timer T1 := 10.0; |
| 3198 | T1.start; |
| 3199 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3200 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3201 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3202 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3203 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3204 | } |
| 3205 | repeat; |
| 3206 | } |
| 3207 | [] L1CTL.receive { repeat; } |
| 3208 | [] T1.timeout { setverdict(pass); } |
| 3209 | } |
| 3210 | |
| 3211 | f_rsl_chan_deact(); |
| 3212 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3213 | |
| 3214 | } |
| 3215 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3216 | /* See if the power level remains constant when MS Power Parameters IE |
| 3217 | * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3218 | private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3219 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3220 | |
| 3221 | /* set a high value to ensure power decreases */ |
| 3222 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3223 | f_l1_tune(L1CTL); |
| 3224 | RSL.clear; |
| 3225 | |
| 3226 | var uint5_t pwr_var := 5; |
| 3227 | |
| 3228 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3229 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3230 | |
| 3231 | /* establish with fixed power level */ |
| 3232 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3233 | |
| 3234 | /* check our initial power level */ |
| 3235 | f_wait_for_l1_power_level(pwr_var); |
| 3236 | |
| 3237 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 3238 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3239 | |
| 3240 | /* wait, then check that our power level did not change */ |
| 3241 | timer T1 := 10.0; |
| 3242 | T1.start; |
| 3243 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3244 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3245 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3247 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3248 | } |
| 3249 | repeat; |
| 3250 | } |
| 3251 | [] L1CTL.receive { repeat; } |
| 3252 | [] T1.timeout { setverdict(pass); } |
| 3253 | } |
| 3254 | |
| 3255 | f_rsl_chan_deact(); |
| 3256 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3257 | |
| 3258 | } |
| 3259 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3260 | private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3261 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3262 | timer T0 := 10.0; |
| 3263 | T0.start; |
| 3264 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3265 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3266 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3267 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3268 | "Power level in L1 header != signaled (RSL) power level."); |
| 3269 | } |
| 3270 | } |
| 3271 | [] L1CTL.receive { repeat; } |
| 3272 | [] T0.timeout { |
| 3273 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3274 | "Timeout waiting for initial power level"); |
| 3275 | } |
| 3276 | } |
| 3277 | T0.stop; |
| 3278 | } |
| 3279 | |
| 3280 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3281 | var IntegerRecord min_dbm_level; |
| 3282 | var IntegerRecord max_dbm_level; |
| 3283 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3284 | |
| 3285 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 3286 | if (min_dbm_level[i] == level) { |
| 3287 | return true; |
| 3288 | } |
| 3289 | } |
| 3290 | return false; |
| 3291 | } |
| 3292 | |
| 3293 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3294 | var IntegerRecord min_dbm_level; |
| 3295 | var IntegerRecord max_dbm_level; |
| 3296 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3297 | |
| 3298 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 3299 | if (max_dbm_level[i] == level) { |
| 3300 | return true; |
| 3301 | } |
| 3302 | } |
| 3303 | return false; |
| 3304 | } |
| 3305 | |
| 3306 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 3307 | var IntegerRecord min_dbm_level; |
| 3308 | var IntegerRecord max_dbm_level; |
| 3309 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3310 | return max_dbm_level[0]; |
| 3311 | } |
| 3312 | |
| 3313 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3314 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3315 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 3316 | // 45.005 4.1.1 |
| 3317 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 3318 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 3319 | 2, 1, 0}; |
| 3320 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 3321 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 3322 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 3323 | var IntegerRecord rv; |
| 3324 | |
| 3325 | select(band){ |
| 3326 | case (BtsBand_allGSM){ |
| 3327 | rv := gsm_power; |
| 3328 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 3329 | max_dbm_level := {2, 1, 0}; |
| 3330 | } |
| 3331 | case("DCS1800"){ |
| 3332 | rv := dcs_power; |
| 3333 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 3334 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 3335 | } |
| 3336 | case("PCS1900"){ |
| 3337 | rv := pcs_power; |
| 3338 | min_dbm_level := {15}; |
| 3339 | max_dbm_level := {30}; |
| 3340 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 3341 | case else { |
| 3342 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3343 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3344 | } |
| 3345 | |
| 3346 | return rv; |
| 3347 | } |
| 3348 | |
| 3349 | 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] | 3350 | 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] | 3351 | } |
| 3352 | |
| 3353 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3354 | var ConnHdlr vc_conn; |
| 3355 | var ConnHdlrPars pars; |
| 3356 | f_init(); |
| 3357 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3358 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3359 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3360 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3361 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3362 | vc_conn.done; |
| 3363 | } |
| 3364 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3365 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3366 | } |
| 3367 | |
| 3368 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3369 | var ConnHdlr vc_conn; |
| 3370 | var ConnHdlrPars pars; |
| 3371 | f_init(); |
| 3372 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3373 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
Vadim Yanitskiy | c78aeb7 | 2022-07-30 17:56:39 +0700 | [diff] [blame] | 3374 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN, t_guard := 30.0)); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3375 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3376 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3377 | vc_conn.done; |
| 3378 | } |
| 3379 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3381 | } |
| 3382 | |
| 3383 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3384 | var ConnHdlr vc_conn; |
| 3385 | var ConnHdlrPars pars; |
| 3386 | f_init(); |
| 3387 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3388 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3389 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3390 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3391 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3392 | vc_conn.done; |
| 3393 | } |
| 3394 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3396 | } |
| 3397 | |
| 3398 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3399 | var ConnHdlr vc_conn; |
| 3400 | var ConnHdlrPars pars; |
| 3401 | f_init(); |
| 3402 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3403 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3404 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3405 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3406 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3407 | vc_conn.done; |
| 3408 | } |
| 3409 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3410 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3411 | } |
| 3412 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3413 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3414 | var ConnHdlr vc_conn; |
| 3415 | var ConnHdlrPars pars; |
| 3416 | f_init(); |
| 3417 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3418 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3419 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3420 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3421 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3422 | vc_conn.done; |
| 3423 | } |
| 3424 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3425 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3426 | } |
| 3427 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3428 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3429 | var ConnHdlr vc_conn; |
| 3430 | var ConnHdlrPars pars; |
| 3431 | f_init(); |
| 3432 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3433 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3434 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3435 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3436 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3437 | vc_conn.done; |
| 3438 | } |
| 3439 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3440 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3441 | } |
| 3442 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3443 | 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] | 3444 | var template RSL_IE_ChannelMode ch_mode; |
| 3445 | var ConnHdlr vc_conn; |
| 3446 | var ConnHdlrPars pars; |
| 3447 | f_init(); |
| 3448 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3449 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3450 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3451 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3452 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3453 | pcu_comp := false, trxc_comp := true); |
| 3454 | vc_conn.done; |
| 3455 | } |
| 3456 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3457 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3458 | |
| 3459 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3460 | f_TC_meas_res_speech_tchf(false); |
| 3461 | } |
| 3462 | |
| 3463 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3464 | f_TC_meas_res_speech_tchf(true); |
| 3465 | } |
| 3466 | |
| 3467 | 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] | 3468 | var template RSL_IE_ChannelMode ch_mode; |
| 3469 | var ConnHdlr vc_conn; |
| 3470 | var ConnHdlrPars pars; |
| 3471 | f_init(); |
| 3472 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3473 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3474 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3475 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3476 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3477 | pcu_comp := false, trxc_comp := true); |
| 3478 | vc_conn.done; |
| 3479 | } |
| 3480 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3481 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3482 | |
| 3483 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3484 | f_TC_meas_res_speech_tchh(false) |
| 3485 | } |
| 3486 | |
| 3487 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3488 | f_TC_meas_res_speech_tchh(true) |
| 3489 | } |
| 3490 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3491 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3492 | var template RSL_IE_ChannelMode ch_mode; |
| 3493 | var ConnHdlr vc_conn; |
| 3494 | var ConnHdlrPars pars; |
| 3495 | f_init(); |
| 3496 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3497 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3498 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3499 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3500 | pars.l1_pars.toa256_enabled := true; |
| 3501 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3502 | pcu_comp := false, trxc_comp := true); |
| 3503 | vc_conn.done; |
| 3504 | } |
| 3505 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3506 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3507 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3508 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3509 | var ConnHdlr vc_conn; |
| 3510 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3511 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3512 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3513 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3514 | 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] | 3515 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3516 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3517 | vc_conn.done; |
| 3518 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3519 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3520 | } |
| 3521 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3522 | var ConnHdlr vc_conn; |
| 3523 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3524 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3525 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3526 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3527 | 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] | 3528 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3529 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3530 | vc_conn.done; |
| 3531 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3532 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3533 | } |
| 3534 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3535 | var ConnHdlr vc_conn; |
| 3536 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3537 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3538 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3539 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3540 | 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] | 3541 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3542 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3543 | vc_conn.done; |
| 3544 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3545 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3546 | } |
| 3547 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3548 | var ConnHdlr vc_conn; |
| 3549 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3550 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3551 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3552 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3553 | 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] | 3554 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3555 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3556 | vc_conn.done; |
| 3557 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3558 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3559 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3560 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3561 | var ConnHdlr vc_conn; |
| 3562 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3563 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3564 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3565 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3566 | 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] | 3567 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3568 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3569 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3570 | vc_conn.done; |
| 3571 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3572 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3573 | } |
| 3574 | |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 3575 | /* Make sure that we always get RSL MEASurement RESult messages regardless |
| 3576 | * of what is sent on SACCH: (RR) Measurement Report or SAPI=3 data (SMS). */ |
| 3577 | private function f_TC_meas_res_sapi3(charstring id) runs on ConnHdlr { |
| 3578 | timer Texec := 8.0; |
| 3579 | timer Timpf := 2.0; |
| 3580 | timer Tmr; |
| 3581 | |
| 3582 | f_l1_tune(L1CTL); |
| 3583 | RSL.clear; |
| 3584 | |
| 3585 | f_est_dchan(); |
| 3586 | L1CTL.clear; |
| 3587 | |
| 3588 | /* Establish the main SAPI=0 link on DCCH first */ |
| 3589 | f_tx_lapdm(ts_LAPDm_SABM(0, cr_MO_CMD, true, ''O), ts_RslLinkID_DCCH(0)); |
| 3590 | |
| 3591 | /* Give more time for the first RSL MEASurement RESult */ |
| 3592 | Tmr.start(0.480 * 2.0); |
| 3593 | Texec.start; /* EXECution timer */ |
| 3594 | Timpf.start; /* IMPFung timer */ |
| 3595 | |
| 3596 | alt { |
| 3597 | /* We expect RSL MEASurement RESult messages every ~480ms (plus some guard) */ |
| 3598 | [] RSL.receive(tr_RSL_MEAS_RES(g_pars.chan_nr)) { |
| 3599 | /* Reschedule the MEAS RES timer */ |
| 3600 | Tmr.start(0.480 + 0.120); |
| 3601 | repeat; |
| 3602 | } |
| 3603 | [] RSL.receive { repeat; } |
| 3604 | [] Tmr.timeout { |
| 3605 | setverdict(fail, "Timeout waiting for RSL MEAS RES"); |
| 3606 | } |
| 3607 | /* Inject some SAPI=3 traffic on SACCH every 2 seconds */ |
| 3608 | [] Timpf.timeout { |
| 3609 | f_tx_lapdm(ts_LAPDm_SABM(3, cr_MO_CMD, true, ''O), ts_RslLinkID_SACCH(3)); |
| 3610 | log("Injected SAPI=3 traffic on SACCH"); |
| 3611 | Timpf.start; |
| 3612 | repeat; |
| 3613 | } |
| 3614 | /* We're good if survived so far */ |
| 3615 | [] Texec.timeout { |
| 3616 | setverdict(pass); |
| 3617 | } |
| 3618 | } |
| 3619 | |
| 3620 | f_rsl_chan_deact(); |
| 3621 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3622 | f_rslem_unregister(0, g_chan_nr); |
| 3623 | } |
| 3624 | testcase TC_meas_res_speech_tchf_sapi3() runs on test_CT { |
| 3625 | var template RSL_IE_ChannelMode ch_mode; |
| 3626 | var template ConnHdlrPars pars; |
| 3627 | var ConnHdlr vc_conn; |
| 3628 | |
| 3629 | f_init(); |
| 3630 | |
| 3631 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3632 | pars := t_Pars(t_RslChanNr_Bm(1), ch_mode); |
| 3633 | |
| 3634 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3635 | vc_conn.done; |
| 3636 | |
| 3637 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3638 | } |
| 3639 | testcase TC_meas_res_speech_tchh_sapi3() runs on test_CT { |
| 3640 | var template RSL_IE_ChannelMode ch_mode; |
| 3641 | var template ConnHdlrPars pars; |
| 3642 | var ConnHdlr vc_conn; |
| 3643 | |
| 3644 | f_init(); |
| 3645 | |
| 3646 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3647 | pars := t_Pars(t_RslChanNr_Lm(5, 0), ch_mode); |
| 3648 | |
| 3649 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3650 | vc_conn.done; |
| 3651 | |
| 3652 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3653 | } |
| 3654 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3655 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3656 | * 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] | 3657 | private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3658 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3659 | var RSL_IE_MS_Power ms_power; |
| 3660 | var RSL_Message rsl; |
| 3661 | var uint5_t power_level := 0; |
| 3662 | |
| 3663 | f_l1_tune(L1CTL); |
| 3664 | RSL.clear; |
| 3665 | |
| 3666 | f_est_dchan(); |
| 3667 | |
| 3668 | ms_power.reserved := 0; |
| 3669 | ms_power.fpc_epc := false; |
| 3670 | |
| 3671 | /* Send the first power control command. This will disable any BTS/TRX |
| 3672 | * internal power control and switch the MS (which is not in scope of |
| 3673 | * this test) to a constant power level. We start with a power level |
| 3674 | * of 0 */ |
| 3675 | ms_power.power_level := power_level; |
| 3676 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3677 | RSL.send(rsl); |
| 3678 | |
| 3679 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3680 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3681 | if (l1h.ms_power_lvl != power_level) { |
| 3682 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3683 | "match the signaled (RSL) power level := ", power_level); |
| 3684 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | /* Signal a new power level via RSL for the next turn. */ |
| 3688 | if (power_level < 31) { |
| 3689 | power_level := power_level + 1; |
| 3690 | ms_power.power_level := power_level; |
| 3691 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3692 | RSL.send(rsl); |
| 3693 | repeat; |
| 3694 | } |
| 3695 | |
| 3696 | } |
| 3697 | |
| 3698 | /* Ignore all other blocks */ |
| 3699 | [] L1CTL.receive { repeat; } |
| 3700 | |
| 3701 | } |
| 3702 | |
| 3703 | f_rsl_chan_deact(); |
| 3704 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3705 | |
| 3706 | setverdict(pass); |
| 3707 | } |
| 3708 | |
| 3709 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3710 | var ConnHdlr vc_conn; |
| 3711 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3712 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3713 | |
| 3714 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3715 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3716 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3717 | vc_conn.done; |
| 3718 | } |
| 3719 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3720 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3721 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3722 | /* 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] | 3723 | 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] | 3724 | 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] | 3725 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3726 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3727 | |
| 3728 | f_l1_tune(L1CTL); |
| 3729 | RSL.clear; |
| 3730 | |
| 3731 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3732 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3733 | |
| 3734 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3735 | |
| 3736 | |
| 3737 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3738 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3739 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3740 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3741 | } |
| 3742 | |
| 3743 | } |
| 3744 | |
| 3745 | /* Ignore all other blocks */ |
| 3746 | [] L1CTL.receive { repeat; } |
| 3747 | |
| 3748 | } |
| 3749 | |
| 3750 | f_rsl_chan_deact(); |
| 3751 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3752 | |
| 3753 | setverdict(pass); |
| 3754 | } |
| 3755 | |
| 3756 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3757 | var ConnHdlr vc_conn; |
| 3758 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3759 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3760 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3761 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3762 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3763 | vc_conn.done; |
| 3764 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3765 | } |
| 3766 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3767 | /* 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] | 3768 | 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] | 3769 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3770 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3771 | |
| 3772 | var RSL_IE_MS_Power ms_power; |
| 3773 | ms_power.reserved := 0; |
| 3774 | ms_power.fpc_epc := false; |
| 3775 | ms_power.power_level := ms_power_level; |
| 3776 | |
| 3777 | f_l1_tune(L1CTL); |
| 3778 | RSL.clear; |
| 3779 | |
| 3780 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3781 | |
| 3782 | timer T := 1.0; |
| 3783 | T.start; |
| 3784 | alt { |
| 3785 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3786 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3787 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3788 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3789 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3790 | } |
| 3791 | } |
| 3792 | /* Ignore all other blocks */ |
| 3793 | [] L1CTL.receive { repeat; } |
| 3794 | [] T.timeout { |
| 3795 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3796 | } |
| 3797 | } |
| 3798 | |
| 3799 | f_rsl_chan_deact(); |
| 3800 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3801 | setverdict(pass); |
| 3802 | } |
| 3803 | |
| 3804 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3805 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3806 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3807 | } |
| 3808 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3809 | /* 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] | 3810 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3811 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3812 | RSL.clear; |
| 3813 | |
| 3814 | f_est_dchan(); |
| 3815 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3816 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3817 | |
| 3818 | timer T := 40.0; |
| 3819 | T.start; |
| 3820 | alt { |
| 3821 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3822 | setverdict(pass) |
| 3823 | } |
| 3824 | [] RSL.receive { repeat }; |
| 3825 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3826 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3827 | } |
| 3828 | } |
| 3829 | f_rsl_chan_deact(); |
| 3830 | } |
| 3831 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3832 | var ConnHdlr vc_conn; |
| 3833 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3834 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3835 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3836 | pars.t_guard := 60.0; |
| 3837 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3838 | vc_conn.done; |
| 3839 | } |
| 3840 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3841 | /*********************************************************************** |
| 3842 | * Paging |
| 3843 | ***********************************************************************/ |
| 3844 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3845 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3846 | if (tmsi == 'FFFFFFFF'O) { |
| 3847 | return true; |
| 3848 | } else { |
| 3849 | return false; |
| 3850 | } |
| 3851 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3852 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3853 | private type record allowedFn { integer frame_nr } |
| 3854 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3855 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3856 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3857 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3858 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3859 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3860 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3861 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3862 | 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] | 3863 | { |
| 3864 | var integer frame_nr_51; |
| 3865 | frame_nr_51 := frame_nr mod 51 |
| 3866 | |
| 3867 | var allowedFn fn_check; |
| 3868 | fn_check.frame_nr := frame_nr_51; |
| 3869 | |
| 3870 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3871 | 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] | 3872 | return; |
| 3873 | } |
| 3874 | |
| 3875 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 3876 | return; |
| 3877 | } |
| 3878 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 3879 | return; |
| 3880 | } |
| 3881 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 3882 | return; |
| 3883 | } |
| 3884 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 3885 | return; |
| 3886 | } |
| 3887 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 3888 | return; |
| 3889 | } |
| 3890 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 3891 | return; |
| 3892 | } |
| 3893 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 3894 | return; |
| 3895 | } |
| 3896 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 3897 | return; |
| 3898 | } |
| 3899 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3900 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3901 | return; |
| 3902 | } |
| 3903 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3904 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 3905 | inout integer num_paging_rcv_ids, |
| 3906 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3907 | runs on test_CT { |
| 3908 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3909 | [] 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] | 3910 | repeat; |
| 3911 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3912 | [] 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] | 3913 | var octetstring without_plen := |
| 3914 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 3915 | 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] | 3916 | |
| 3917 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 3918 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 3919 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 3920 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 3921 | * TODO: does it make sense to count them? */ |
| 3922 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3923 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3924 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3925 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3926 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3927 | } |
| 3928 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 3929 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3930 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 3931 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3932 | } |
| 3933 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 3934 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3935 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 3936 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3937 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3938 | } |
| 3939 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 3940 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 3941 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 3942 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3943 | } |
| 3944 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 3945 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3946 | } |
| 3947 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 3948 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3949 | } |
| 3950 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 3951 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 3952 | } |
| 3953 | } |
| 3954 | repeat; |
| 3955 | } |
| 3956 | } |
| 3957 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3958 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3959 | boolean combined_ccch, |
| 3960 | integer bs_ag_blks_res, |
| 3961 | float load_factor, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3962 | /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus) |
| 3963 | * paging command that is issued via RSL. */ |
| 3964 | integer ps_load_modulus, |
| 3965 | /* Wait until the paging queue inside the BTS is congested before starting to add |
| 3966 | * pagings via the PCU socket (0 = disabled) */ |
| 3967 | boolean ps_wait_cong, |
| 3968 | /* Maximum time to wait until the paging queue is drained at the end of the test. |
| 3969 | * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended |
| 3970 | * to set this value to 18s, however the draining process may take significantly |
| 3971 | * longer when the queue contains paging requests for PS as those are implemented |
| 3972 | * as immediate assignments and require an entire MAC block alone. */ |
| 3973 | float queue_drain_timeout, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3974 | boolean exp_load_ind, |
| 3975 | boolean exp_overload, |
| 3976 | boolean use_tmsi |
| 3977 | } |
| 3978 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3979 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3980 | integer num_paging_sent, |
| 3981 | integer num_paging_rcv_msgs, |
| 3982 | integer num_paging_rcv_ids, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3983 | integer num_overload, |
| 3984 | /* When free space inside the paging queue reaches more than 2 thirds |
| 3985 | * of its capacity cong_detected is set to true. */ |
| 3986 | boolean cong_detected |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3987 | } |
| 3988 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3989 | /* Helper function for paging related testing */ |
| 3990 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 3991 | /* Using the PCU socket affects the timing of the paging processing. We only |
| 3992 | * activate the PCU socket if we do paging load tests that include additional |
| 3993 | * paging load that is introduced through the PCU socket. */ |
| 3994 | if (cfg.ps_load_modulus > 0) { |
| 3995 | f_init_with_pcuif(); |
| 3996 | } else { |
| 3997 | f_init(); |
| 3998 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3999 | f_init_l1ctl(); |
| 4000 | f_l1_tune(L1CTL); |
| 4001 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4002 | var octetstring imm_ass := f_rnd_octstring(23); |
| 4003 | var ASP_RSL_Unitdata load_ind; |
| 4004 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4005 | var PagingTestState st := { |
| 4006 | num_paging_sent := 0, |
| 4007 | num_paging_rcv_msgs := 0, |
| 4008 | num_paging_rcv_ids := 0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4009 | num_overload := 0, |
| 4010 | cong_detected := false |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4011 | }; |
| 4012 | |
| 4013 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 4014 | var float max_pch_imsi_per_sec; |
| 4015 | if (cfg.use_tmsi) { |
| 4016 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 4017 | } else { |
| 4018 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 4019 | } |
| 4020 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 4021 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4022 | var float time_total := 20.0; |
| 4023 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 4024 | 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] | 4025 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4026 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 4027 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4028 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4029 | timer T_itv := 0.0; |
| 4030 | T_itv.start; |
| 4031 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4032 | alt { |
| 4033 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4034 | [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] | 4035 | st.num_overload := st.num_overload + 1; |
| 4036 | repeat; |
| 4037 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4038 | [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] | 4039 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4040 | } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4041 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4042 | log("Rx LOAD_IND"); |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4043 | |
| 4044 | /* Detect paging congestion: The logic inside the BTS will diagnose the |
| 4045 | * paging queue as congested when the fill state is more than 66% (which |
| 4046 | * is two thirds fill state, or approx. 66 of 200 paging slots. When a |
| 4047 | * paging congestion is detected pagings that are issued through the PCU |
| 4048 | * socket (PS) are dropped in order to prefer the CS related pagings. */ |
| 4049 | if (load_ind.rsl.ies[1].body.paging_load < 66) { |
| 4050 | st.cong_detected := true; |
| 4051 | } |
| 4052 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4053 | /* FIXME: analyze/verify interval + contents */ |
| 4054 | repeat; |
| 4055 | } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4056 | /* ignore other RSL messages like RF RESource INDication */ |
| 4057 | [] RSL_CCHAN.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4058 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4059 | [] 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] | 4060 | [] L1CTL.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4061 | /* Only relevant when testing including with PCU sock connected */ |
| 4062 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4063 | [] T_itv.timeout { |
| 4064 | /* Send paging cmds based on elapsed time */ |
| 4065 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 4066 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4067 | var MobileIdentityV mi; |
| 4068 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4069 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4070 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4071 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4072 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4073 | 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] | 4074 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4075 | |
| 4076 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4077 | 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] | 4078 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4079 | /* Add additional pagings through the PCU socket interface. */ |
| 4080 | if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) { |
| 4081 | if (st.cong_detected == true or cfg.ps_wait_cong == false) { |
| 4082 | f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false); |
| 4083 | } |
| 4084 | } |
| 4085 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4086 | st.num_paging_sent := st.num_paging_sent + 1; |
| 4087 | } |
| 4088 | if (st.num_paging_sent < pkt_total) { |
| 4089 | /* Wait for interval to next PAGING COMMAND */ |
| 4090 | var float time_now := T_total.read; |
| 4091 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 4092 | if (next_sched > time_now) { |
| 4093 | T_itv.start(next_sched - time_now); |
| 4094 | } else { |
| 4095 | T_itv.start(0.0); |
| 4096 | } |
| 4097 | } else { |
| 4098 | /* We are done, no need to keep counting */ |
| 4099 | T_total.stop; |
| 4100 | } |
| 4101 | } |
| 4102 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4103 | } |
| 4104 | } |
| 4105 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4106 | timer T_wait := cfg.queue_drain_timeout |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4107 | T_wait.start; |
| 4108 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4109 | [] 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] | 4110 | [] L1CTL.receive { repeat; } |
| 4111 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4112 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4113 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { repeat; } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4114 | /* ignore other RSL messages like RF RESource INDication */ |
| 4115 | [] RSL_CCHAN.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4116 | /* Only relevant when testing including with PCU sock connected */ |
| 4117 | [] PCU.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4118 | [] T_wait.timeout { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4119 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Waiting for paging queue, last detected fill state: ", load_ind.rsl.ies[1].body.paging_load)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4120 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4121 | } |
| 4122 | |
| 4123 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 4124 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 4125 | return st; |
| 4126 | } |
| 4127 | |
| 4128 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 4129 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4130 | * - that CCCH LOAD IND (PCH) are being generated |
| 4131 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4132 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4133 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4134 | var PagingTestCfg cfg := { |
| 4135 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4136 | 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] | 4137 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4138 | ps_load_modulus := 0, |
| 4139 | ps_wait_cong := false, |
| 4140 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4141 | exp_load_ind := true, |
| 4142 | exp_overload := false, |
| 4143 | use_tmsi := false |
| 4144 | }; |
| 4145 | var PagingTestState st := f_TC_paging(cfg); |
| 4146 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4147 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4148 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4149 | } else { |
| 4150 | setverdict(pass); |
| 4151 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4152 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4153 | } |
| 4154 | |
| 4155 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 4156 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4157 | * - that CCCH LOAD IND (PCH) are being generated |
| 4158 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4159 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4160 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4161 | var PagingTestCfg cfg := { |
| 4162 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4163 | 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] | 4164 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4165 | ps_load_modulus := 0, |
| 4166 | ps_wait_cong := false, |
| 4167 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4168 | exp_load_ind := true, |
| 4169 | exp_overload := false, |
| 4170 | use_tmsi := true |
| 4171 | }; |
| 4172 | var PagingTestState st := f_TC_paging(cfg); |
| 4173 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4174 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4175 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4176 | } else { |
| 4177 | setverdict(pass); |
| 4178 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4180 | } |
| 4181 | |
| 4182 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 4183 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4184 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4185 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4186 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4187 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4188 | var PagingTestCfg cfg := { |
| 4189 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4190 | 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] | 4191 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4192 | ps_load_modulus := 0, |
| 4193 | ps_wait_cong := false, |
| 4194 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4195 | exp_load_ind := true, |
| 4196 | exp_overload := true, |
| 4197 | use_tmsi := false |
| 4198 | }; |
| 4199 | var PagingTestState st := f_TC_paging(cfg); |
| 4200 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4201 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4202 | 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] | 4203 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4204 | 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] | 4205 | } else { |
| 4206 | setverdict(pass); |
| 4207 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4208 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4209 | } |
| 4210 | |
| 4211 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 4212 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4213 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4214 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4215 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4216 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4217 | var PagingTestCfg cfg := { |
| 4218 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4219 | 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] | 4220 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4221 | ps_load_modulus := 0, |
| 4222 | ps_wait_cong := false, |
| 4223 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4224 | exp_load_ind := true, |
| 4225 | exp_overload := true, |
| 4226 | use_tmsi := true |
| 4227 | }; |
| 4228 | var PagingTestState st := f_TC_paging(cfg); |
| 4229 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 4230 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4231 | 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] | 4232 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4233 | 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] | 4234 | } else { |
| 4235 | setverdict(pass); |
| 4236 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4237 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4238 | } |
| 4239 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4240 | /* Same as above, but with additional paging load created by PS pagings that |
| 4241 | * are issued through the PCU socket. The additional load is introduced when |
| 4242 | * the paging queue is already two thirds full. Since the BTS implements a |
| 4243 | * prioritization logic that drops the pagings from the PCU under in those |
| 4244 | * congestive sitautions the behaviour on the PS side is expected to be |
| 4245 | * unaffected and match the behavior of TC_paging_imsi_200percent() */ |
| 4246 | testcase TC_paging_imsi_200percent_with_ps() runs on test_CT { |
| 4247 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 4248 | var PagingTestCfg cfg := { |
| 4249 | combined_ccch := true, |
| 4250 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
| 4251 | load_factor := 2.0, |
| 4252 | ps_load_modulus := 16, |
| 4253 | ps_wait_cong := true, |
| 4254 | queue_drain_timeout := 18.0, |
| 4255 | exp_load_ind := true, |
| 4256 | exp_overload := true, |
| 4257 | use_tmsi := false |
| 4258 | }; |
| 4259 | var PagingTestState st := f_TC_paging(cfg); |
| 4260 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4261 | * slots and will fully drain that buffer before returning */ |
| 4262 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
| 4263 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 4264 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
| 4265 | } else { |
| 4266 | setverdict(pass); |
| 4267 | } |
| 4268 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4269 | } |
| 4270 | |
| 4271 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4272 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4273 | /*********************************************************************** |
| 4274 | * Immediate Assignment / AGCH |
| 4275 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 4276 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4277 | len := 0, |
| 4278 | ma := ''B |
| 4279 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4280 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4281 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 4282 | return int2str(num_tx) & " sent, " |
| 4283 | & int2str(num_rx) & " received, " |
| 4284 | & int2str(num_del) & " deleted"; |
| 4285 | } |
| 4286 | |
| 4287 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 4288 | var L1ctlDlMessage l1_dl; |
| 4289 | timer T := 10.0; |
| 4290 | var integer num_tx := 0; |
| 4291 | var integer num_rx := 0; |
| 4292 | var integer num_del := 0; |
| 4293 | var charstring res_str; |
| 4294 | var float rx_ratio; |
| 4295 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4296 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4297 | f_init_l1ctl(); |
| 4298 | f_l1_tune(L1CTL); |
| 4299 | |
| 4300 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 4301 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 4302 | mp_trx_pars[0].arfcn, |
| 4303 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4304 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 4305 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4306 | 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] | 4307 | num_tx := num_tx+1; |
| 4308 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4309 | } |
| 4310 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4311 | T.start; |
| 4312 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4313 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4314 | num_del := num_del+1; |
| 4315 | repeat; |
| 4316 | } |
| 4317 | [] RSL_CCHAN.receive { |
| 4318 | repeat; |
| 4319 | } |
| 4320 | [] 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] | 4321 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 4322 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 4323 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4324 | //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] | 4325 | } else { |
| 4326 | num_rx := num_rx+1; |
| 4327 | } |
| 4328 | repeat; |
| 4329 | } |
| 4330 | [] L1CTL.receive { repeat; } |
| 4331 | [] T.timeout { } |
| 4332 | } |
| 4333 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 4334 | log("AGCH test: " & res_str); |
| 4335 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4336 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4337 | } |
| 4338 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 4339 | 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] | 4340 | 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] | 4341 | } else { |
| 4342 | setverdict(pass); |
| 4343 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4344 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4345 | } |
| 4346 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4347 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 4348 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 4349 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 4350 | } |
| 4351 | |
| 4352 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 4353 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 4354 | f_TC_imm_ass(200, 0.0, 0.05); |
| 4355 | } |
| 4356 | |
| 4357 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 4358 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 4359 | f_TC_imm_ass(150, 0.076, 1.00); |
| 4360 | } |
| 4361 | |
| 4362 | |
| 4363 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4364 | /*********************************************************************** |
| 4365 | * BCCH |
| 4366 | ***********************************************************************/ |
| 4367 | |
| 4368 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4369 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4370 | GsmFrameNumber frame_number, |
| 4371 | SystemInformation si |
| 4372 | } |
| 4373 | |
| 4374 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4375 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4376 | |
| 4377 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4378 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4379 | |
| 4380 | /* 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] | 4381 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 4382 | RrMessageType key, |
| 4383 | boolean bcch_ext := false) |
| 4384 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4385 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4386 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4387 | if (not bcch_ext and fn_mod51 == 2 or |
| 4388 | bcch_ext and fn_mod51 == 6) { |
| 4389 | if (arr[i].si.header.message_type == key) { |
| 4390 | return true; |
| 4391 | } |
| 4392 | } |
| 4393 | } |
| 4394 | return false; |
| 4395 | } |
| 4396 | |
| 4397 | /* 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] | 4398 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4399 | integer tc, RrMessageType key, |
| 4400 | boolean ext_bcch := false) |
| 4401 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4402 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4403 | 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] | 4404 | } |
| 4405 | } |
| 4406 | |
| 4407 | /* 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] | 4408 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4409 | RrMessageType key) |
| 4410 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4411 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 4412 | if (f_si_vecslot_contains(arr[tc], key) or |
| 4413 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 4414 | return true; |
| 4415 | } |
| 4416 | } |
| 4417 | return false; |
| 4418 | } |
| 4419 | |
| 4420 | /* 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] | 4421 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 4422 | RrMessageType key, |
| 4423 | boolean bcch_ext := false, |
| 4424 | integer n := 1, integer m := 4) |
| 4425 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4426 | var integer count := 0; |
| 4427 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 4428 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 4429 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4430 | } |
| 4431 | for (var integer i:= 0; i < m; i := i + 1) { |
| 4432 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4433 | if (not bcch_ext and fn_mod51 == 2 or |
| 4434 | bcch_ext and fn_mod51 == 6) { |
| 4435 | if (arr[i].si.header.message_type == key) { |
| 4436 | count := count + 1; |
| 4437 | } |
| 4438 | } |
| 4439 | } |
| 4440 | if (count >= n) { |
| 4441 | return true; |
| 4442 | } else { |
| 4443 | return false; |
| 4444 | } |
| 4445 | } |
| 4446 | |
| 4447 | /* 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] | 4448 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 4449 | integer tc, RrMessageType key, |
| 4450 | boolean ext_bcch := false, |
| 4451 | integer n, integer m) |
| 4452 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4453 | 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] | 4454 | 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] | 4455 | } |
| 4456 | } |
| 4457 | |
| 4458 | /* 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] | 4459 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 4460 | RrMessageType key, |
| 4461 | boolean bcch_ext := false) |
| 4462 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4463 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4464 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4465 | if (not bcch_ext and fn_mod51 == 2 or |
| 4466 | bcch_ext and fn_mod51 == 6) { |
| 4467 | if (arr[i].si.header.message_type != key) { |
| 4468 | return false; |
| 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | return true; |
| 4473 | } |
| 4474 | |
| 4475 | /* 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] | 4476 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 4477 | integer tc, RrMessageType key, |
| 4478 | boolean ext_bcch := false) |
| 4479 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4480 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4481 | 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] | 4482 | } |
| 4483 | } |
| 4484 | |
| 4485 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4486 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4487 | boolean bcch_extended, |
| 4488 | boolean si1_present, |
| 4489 | boolean si2bis_present, |
| 4490 | boolean si2ter_present, |
| 4491 | boolean si2quater_present, |
| 4492 | boolean si7_present, |
| 4493 | boolean si8_present, |
| 4494 | boolean si9_present, |
| 4495 | boolean si13_present, |
| 4496 | boolean si13alt_present, |
| 4497 | boolean si15_present, |
| 4498 | boolean si16_present, |
| 4499 | boolean si17_present, |
| 4500 | boolean si2n_present, |
| 4501 | boolean si21_present, |
| 4502 | boolean si22_present |
| 4503 | } |
| 4504 | |
| 4505 | /* 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] | 4506 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 4507 | SystemInformationVectorPerTc si_per_tc) |
| 4508 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4509 | var integer i; |
| 4510 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 4511 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4512 | 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] | 4513 | } |
| 4514 | } |
| 4515 | if (cfg.si1_present) { |
| 4516 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 4517 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 4518 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 4519 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4520 | /* make sure *ALL* contain SI1 */ |
| 4521 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4522 | } |
| 4523 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4524 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4525 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4526 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4527 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4528 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4529 | |
| 4530 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4531 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4532 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4533 | * consecutive occurrences of TC = 4. */ |
| 4534 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4535 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4536 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4537 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4538 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4539 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4540 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4541 | } |
| 4542 | |
| 4543 | if (cfg.si7_present or cfg.si8_present) { |
| 4544 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4545 | * if System Information type 4 does not contain all information needed for cell |
| 4546 | * selection and reselection. */ |
| 4547 | if (not cfg.bcch_extended) { |
| 4548 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4549 | } |
| 4550 | if (cfg.si7_present) { |
| 4551 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4552 | } |
| 4553 | if (cfg.si8_present) { |
| 4554 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4555 | } |
| 4556 | } |
| 4557 | |
| 4558 | if (cfg.si2quater_present) { |
| 4559 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4560 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4561 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4562 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4563 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4564 | if (not (cfg.bcch_extended)) { |
| 4565 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4566 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4567 | } else { |
| 4568 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4569 | } |
| 4570 | } else { |
| 4571 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4572 | } |
| 4573 | } |
| 4574 | if (cfg.si9_present) { |
| 4575 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4576 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4577 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4578 | } |
| 4579 | if (cfg.si13_present) { |
| 4580 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4581 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4582 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4583 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4584 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4585 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4586 | if (not cfg.bcch_extended) { |
| 4587 | log("not-bccch-extended"); |
| 4588 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4589 | } else { |
| 4590 | log("bccch-extended"); |
| 4591 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4592 | } |
| 4593 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4594 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4595 | } |
| 4596 | } |
| 4597 | if (cfg.si16_present or cfg.si17_present) { |
| 4598 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4599 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4600 | if (cfg.si22_present) { |
| 4601 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4602 | } |
| 4603 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4604 | 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] | 4605 | } |
| 4606 | if (not cfg.bcch_extended) { |
| 4607 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4608 | } |
| 4609 | if (cfg.si16_present) { |
| 4610 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4611 | } |
| 4612 | if (cfg.si17_present) { |
| 4613 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4614 | } |
| 4615 | } |
| 4616 | |
| 4617 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4618 | * broadcast information. The frequency with which they are sent is determined by the |
| 4619 | * system operator. System Information type 9 identifies the scheduling of System |
| 4620 | * Information type 18 and 20 messages. */ |
| 4621 | |
| 4622 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4623 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4624 | * Information Type 9. */ |
| 4625 | |
| 4626 | if (cfg.si15_present) { |
| 4627 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4628 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4629 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4630 | * 4 consecutive occurrences of TC = 1. */ |
| 4631 | if (not cfg.bcch_extended) { |
| 4632 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4633 | } else { |
| 4634 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4635 | } |
| 4636 | } |
| 4637 | if (cfg.si13alt_present) { |
| 4638 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4639 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4640 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4641 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4642 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4643 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4644 | * of TC = 4. */ |
| 4645 | if (cfg.si13_present) { |
| 4646 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4647 | } |
| 4648 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4649 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4650 | } |
| 4651 | if (not cfg.bcch_extended) { |
| 4652 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4653 | } else { |
| 4654 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4655 | } |
| 4656 | } |
| 4657 | if (cfg.si2n_present) { |
| 4658 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4659 | * as determined by the system operator. In the case that the message is sent on the |
| 4660 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4661 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4662 | * consecutive occurrences of TC = 4. */ |
| 4663 | if (not cfg.bcch_extended) { |
| 4664 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4665 | } else { |
| 4666 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4667 | } |
| 4668 | } |
| 4669 | if (cfg.si21_present) { |
| 4670 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4671 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4672 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4673 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4674 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4675 | if (not cfg.bcch_extended) { |
| 4676 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4677 | } else { |
| 4678 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4679 | 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] | 4680 | 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] | 4681 | } |
| 4682 | } |
| 4683 | } |
| 4684 | if (cfg.si22_present) { |
| 4685 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4686 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4687 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4688 | * =2 and TC=6. */ |
| 4689 | if (cfg.si16_present or cfg.si17_present) { |
| 4690 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4691 | } |
| 4692 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4693 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4694 | 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] | 4695 | } |
| 4696 | if (not cfg.bcch_extended) { |
| 4697 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4698 | } else { |
| 4699 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4700 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4701 | } |
| 4702 | } |
| 4703 | } |
| 4704 | |
| 4705 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4706 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4707 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4708 | timer T := duration; |
| 4709 | var SystemInformationVectorPerTc si_per_tc; |
| 4710 | var L1ctlDlMessage l1_dl; |
| 4711 | |
| 4712 | /* initialize all per-TC vectors empty */ |
| 4713 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4714 | si_per_tc[i] := {}; |
| 4715 | } |
| 4716 | |
| 4717 | /* flush all previous L1 queued msgs */ |
| 4718 | pt.clear; |
| 4719 | |
| 4720 | T.start; |
| 4721 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4722 | [] 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] | 4723 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4724 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4725 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4726 | repeat; |
| 4727 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4728 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4729 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4730 | log("SI received at TC=", tc, ": ", sig.si); |
| 4731 | /* append to the per-TC bucket */ |
| 4732 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4733 | repeat; |
| 4734 | } |
| 4735 | [] pt.receive { repeat; } |
| 4736 | [] T.timeout { } |
| 4737 | } |
| 4738 | |
| 4739 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4740 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4741 | } |
| 4742 | log("si_per_tc=", si_per_tc); |
| 4743 | return si_per_tc; |
| 4744 | } |
| 4745 | |
| 4746 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4747 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4748 | 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] | 4749 | var SystemInformationVectorPerTc si_per_tc; |
| 4750 | f_init_l1ctl(); |
| 4751 | f_l1_tune(L1CTL); |
| 4752 | |
| 4753 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4754 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4755 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4756 | |
| 4757 | setverdict(pass); |
| 4758 | } |
| 4759 | |
| 4760 | testcase TC_si_sched_default() runs on test_CT { |
| 4761 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4762 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4763 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4764 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4765 | } |
| 4766 | |
| 4767 | testcase TC_si_sched_1() runs on test_CT { |
| 4768 | f_init(); |
| 4769 | si_cfg.si1_present := true; |
| 4770 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4771 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4772 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4773 | } |
| 4774 | |
| 4775 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4776 | f_init(); |
| 4777 | si_cfg.si2bis_present := true; |
| 4778 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4779 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4780 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4781 | } |
| 4782 | |
| 4783 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4784 | f_init(); |
| 4785 | si_cfg.si2ter_present := true; |
| 4786 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4787 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4788 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4789 | } |
| 4790 | |
| 4791 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4792 | f_init(); |
| 4793 | si_cfg.si2bis_present := true; |
| 4794 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4795 | si_cfg.si2ter_present := true; |
| 4796 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4797 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4798 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4799 | } |
| 4800 | |
| 4801 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4802 | f_init(); |
| 4803 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4804 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4805 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4806 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4807 | } |
| 4808 | |
| 4809 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4810 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4811 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4812 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4813 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4814 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4815 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4816 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4817 | } |
| 4818 | |
| 4819 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4820 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4821 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4822 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4823 | si_cfg.si2bis_present := true; |
| 4824 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4825 | si_cfg.si2ter_present := true; |
| 4826 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4827 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4828 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4829 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4830 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4831 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4832 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4833 | } |
| 4834 | |
| 4835 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4836 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4837 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4838 | /* FIXME: enable / disable individual BCCH info */ |
| 4839 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4840 | /* expect no ERROR REPORT after either of them * |
| 4841 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4842 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4843 | } |
| 4844 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4845 | /*********************************************************************** |
| 4846 | * Low-Level Protocol Errors / ERROR REPORT |
| 4847 | ***********************************************************************/ |
| 4848 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4849 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4850 | timer T := 5.0; |
| 4851 | T.start; |
| 4852 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4853 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4854 | setverdict(pass); |
| 4855 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4856 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4857 | 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] | 4858 | } |
| 4859 | [] RSL_CCHAN.receive { |
| 4860 | repeat; |
| 4861 | } |
| 4862 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4863 | 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] | 4864 | } |
| 4865 | } |
| 4866 | } |
| 4867 | |
| 4868 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4869 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4870 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4871 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4872 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4873 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4874 | |
| 4875 | f_exp_err_rep(RSL_ERR_PROTO); |
| 4876 | } |
| 4877 | |
| 4878 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 4879 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4880 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4881 | |
| 4882 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4883 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4884 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4885 | |
| 4886 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 4887 | } |
| 4888 | |
| 4889 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 4890 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4891 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4892 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4893 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4894 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4895 | |
| 4896 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 4897 | } |
| 4898 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4899 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 4900 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 4901 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4902 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 4903 | RSL.send(rsl); |
| 4904 | f_rslem_unregister(0, g_chan_nr); |
| 4905 | } |
| 4906 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 4907 | var ConnHdlr vc_conn; |
| 4908 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4909 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4910 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4911 | |
| 4912 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 4913 | vc_conn.done; |
| 4914 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 4915 | |
| 4916 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4917 | } |
| 4918 | |
| 4919 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4920 | 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] | 4921 | var template (value) RSL_Message rsl_tx; |
| 4922 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 4923 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 4924 | RSL.send(rsl_tx); |
| 4925 | f_rslem_unregister(0, g_chan_nr); |
| 4926 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4927 | 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] | 4928 | var template (value) RSL_Message rsl_tx; |
| 4929 | /* we first have to activate the dedicated channel */ |
| 4930 | f_rsl_chan_act(g_pars.chan_mode); |
| 4931 | /* ... to then send an invalid RLL message */ |
| 4932 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 4933 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 4934 | RSL.send(rsl_tx); |
| 4935 | f_rslem_unregister(0, g_chan_nr); |
| 4936 | } |
| 4937 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 4938 | var ConnHdlr vc_conn; |
| 4939 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4940 | var template (value) RSL_Message rsl_tx; |
| 4941 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4942 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4943 | |
| 4944 | /* Common Channel with wrong message type */ |
| 4945 | RSL_CCHAN.clear; |
| 4946 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 4947 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4948 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4949 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4950 | |
| 4951 | /* TRX Management */ |
| 4952 | RSL_CCHAN.clear; |
| 4953 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 4954 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4955 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4956 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4957 | |
| 4958 | /* Dedicated Channel */ |
| 4959 | RSL_CCHAN.clear; |
| 4960 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 4961 | vc_conn.done; |
| 4962 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4963 | |
| 4964 | /* RLL */ |
| 4965 | RSL_CCHAN.clear; |
| 4966 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 4967 | vc_conn.done; |
| 4968 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 4969 | } |
| 4970 | |
| 4971 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4972 | 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] | 4973 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 4974 | f_rslem_unregister(0, g_chan_nr); |
| 4975 | } |
| 4976 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 4977 | var ConnHdlr vc_conn; |
| 4978 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 4979 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4980 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 4981 | |
| 4982 | RSL_CCHAN.clear; |
| 4983 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 4984 | vc_conn.done; |
| 4985 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 4986 | } |
| 4987 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4988 | /*********************************************************************** |
| 4989 | * IPA CRCX/MDCX/DLCS media stream handling |
| 4990 | ***********************************************************************/ |
| 4991 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4992 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 4993 | 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] | 4994 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 4995 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 4996 | } |
| 4997 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 4998 | 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] | 4999 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5000 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 5001 | vc_conn.done; |
| 5002 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5003 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5004 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5005 | 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] | 5006 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5007 | "IPA CRCX ACK"); |
| 5008 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 5009 | "IPA CRCX NACK"); |
| 5010 | } |
| 5011 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 5012 | 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] | 5013 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5014 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 5015 | vc_conn.done; |
| 5016 | } |
| 5017 | |
| 5018 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5019 | 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] | 5020 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5021 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5022 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5023 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5024 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5025 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5026 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5027 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5028 | "IPA MDCX ACK"); |
| 5029 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5030 | "IPA DLCX ACK"); |
| 5031 | } |
| 5032 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5033 | 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] | 5034 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5035 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 5036 | vc_conn.done; |
| 5037 | } |
| 5038 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5039 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5040 | 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] | 5041 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5042 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5043 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5044 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5045 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5046 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5047 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5048 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5049 | "IPA MDCX ACK"); |
| 5050 | /* Second MDCX */ |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5051 | remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5052 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 5053 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5054 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5055 | "IPA MDCX ACK"); |
| 5056 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5057 | "IPA DLCX ACK"); |
| 5058 | } |
| 5059 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5060 | 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] | 5061 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5062 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 5063 | vc_conn.done; |
| 5064 | } |
| 5065 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5066 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5067 | 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] | 5068 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 5069 | "IPA CRCX NACK"); |
| 5070 | } |
| 5071 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 5072 | var ConnHdlrPars pars; |
| 5073 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5074 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5075 | |
| 5076 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 5077 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5078 | vc_conn.done; |
| 5079 | |
| 5080 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 5081 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5082 | vc_conn.done; |
| 5083 | } |
| 5084 | |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 5085 | /* Make sure that CRCX ACK contains a valid listen address (see OS#5242) */ |
| 5086 | private function f_TC_ipa_crcx_ack_addr(charstring id) runs on ConnHdlr { |
| 5087 | var OCT4 bind_ip := f_inet_addr("192.168.1.1"); |
| 5088 | var PortNumber bind_port := 16811; |
| 5089 | var RSL_Message crcx_ack; |
| 5090 | |
| 5091 | crcx_ack := f_rsl_transceive_ret(ts_RSL_IPA_CRCX(g_chan_nr, bind_ip, bind_port), |
| 5092 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5093 | "IPA CRCX ACK"); |
| 5094 | var HostName bts_bind_ip := f_inet_ntoa(crcx_ack.ies[2].body.ipa_local_ip); |
| 5095 | if (match(bts_bind_ip, "0.0.0.0")) { |
| 5096 | setverdict(fail, "CRCX ACK indicates nonsense addr ", bts_bind_ip); |
| 5097 | } |
| 5098 | |
| 5099 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 5100 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, conn_id), |
| 5101 | tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5102 | "IPA DLCX ACK"); |
| 5103 | } |
| 5104 | testcase TC_ipa_crcx_ack_addr() runs on test_CT { |
| 5105 | var ConnHdlrPars pars; |
| 5106 | var ConnHdlr vc_conn; |
| 5107 | f_init(); |
| 5108 | |
| 5109 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 5110 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5111 | vc_conn.done; |
| 5112 | |
| 5113 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 5114 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5115 | vc_conn.done; |
| 5116 | } |
| 5117 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5118 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5119 | /*********************************************************************** |
| 5120 | * PCU Socket related tests |
| 5121 | ***********************************************************************/ |
| 5122 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5123 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5124 | 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] | 5125 | runs on test_CT { |
| 5126 | timer T := 3.0; |
| 5127 | |
| 5128 | /* we don't expect any RTS.req before PDCH are active */ |
| 5129 | T.start; |
| 5130 | alt { |
| 5131 | [] 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] | 5132 | 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] | 5133 | } |
| 5134 | [] PCU.receive { repeat; } |
| 5135 | [] T.timeout { } |
| 5136 | } |
| 5137 | |
| 5138 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5139 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 5140 | |
| 5141 | /* we now expect RTS.req for this timeslot (only) */ |
| 5142 | T.start; |
| 5143 | alt { |
| 5144 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 5145 | setverdict(pass); |
| 5146 | } |
| 5147 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5148 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5149 | 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] | 5150 | } |
| 5151 | [] 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] | 5152 | 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] | 5153 | } |
| 5154 | [] PCU.receive { repeat; } |
| 5155 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5156 | 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] | 5157 | } |
| 5158 | [not exp_success] T.timeout { |
| 5159 | setverdict(pass); |
| 5160 | } |
| 5161 | } |
| 5162 | } |
| 5163 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5164 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5165 | 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] | 5166 | runs on test_CT { |
| 5167 | timer T := 3.0; |
| 5168 | |
| 5169 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5170 | 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] | 5171 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 5172 | * when it will actually have been executed in the BTS */ |
| 5173 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5174 | PCU.clear; |
| 5175 | /* we now expect no RTS.req for this timeslot */ |
| 5176 | T.start; |
| 5177 | alt { |
| 5178 | [] 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] | 5179 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5180 | } |
| 5181 | [] PCU.receive { repeat; } |
| 5182 | [] T.timeout { |
| 5183 | setverdict(pass); |
| 5184 | } |
| 5185 | } |
| 5186 | } |
| 5187 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5188 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5189 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5190 | map(self:PCU, system:PCU); |
| 5191 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5192 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 5193 | } |
| 5194 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5195 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 5196 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5197 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5198 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5199 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5200 | } |
| 5201 | |
| 5202 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 5203 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5204 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5205 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5206 | f_TC_pcu_act_req(0, 0, 1, false); |
| 5207 | } |
| 5208 | |
| 5209 | /* PDCH activation via PCU socket on wrong BTS */ |
| 5210 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5211 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5212 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5213 | f_TC_pcu_act_req(23, 0, 7, false); |
| 5214 | } |
| 5215 | |
| 5216 | /* PDCH activation via PCU socket on wrong TRX */ |
| 5217 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5218 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5219 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5220 | f_TC_pcu_act_req(0, 23, 7, false); |
| 5221 | } |
| 5222 | |
| 5223 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 5224 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5225 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5226 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5227 | /* Activate PDCH */ |
| 5228 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5229 | f_sleep(1.0); |
| 5230 | /* and De-Activate again */ |
| 5231 | f_TC_pcu_deact_req(0, 0, 7); |
| 5232 | } |
| 5233 | |
| 5234 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 5235 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5236 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5237 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5238 | f_TC_pcu_deact_req(0, 0, 1); |
| 5239 | } |
| 5240 | |
| 5241 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5242 | function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5243 | var PCUIF_send_data sd; |
| 5244 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5245 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5246 | |
| 5247 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5248 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5249 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5250 | T.start; |
| 5251 | alt { |
| 5252 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5253 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5254 | setverdict(pass); |
| 5255 | } else { |
| 5256 | repeat; |
| 5257 | } |
| 5258 | } |
| 5259 | [] PCU.receive { repeat; } |
| 5260 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5261 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5262 | } |
| 5263 | } |
| 5264 | } |
| 5265 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5266 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 5267 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 5268 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 5269 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 5270 | } |
| 5271 | |
| 5272 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 5273 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 5274 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 5275 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 5276 | } |
| 5277 | |
| 5278 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 5279 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 5280 | const octetstring si13 := '01010203040506070909'O; |
| 5281 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 5282 | } |
| 5283 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5284 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 5285 | |
| 5286 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5287 | 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] | 5288 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 5289 | runs on test_CT |
| 5290 | { |
| 5291 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 5292 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 5293 | } |
| 5294 | |
| 5295 | /* 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] | 5296 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 5297 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5298 | runs on test_CT |
| 5299 | { |
| 5300 | var PCUIF_send_data sd; |
| 5301 | |
| 5302 | timer T := 3.0; |
| 5303 | T.start; |
| 5304 | alt { |
| 5305 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5306 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 5307 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 5308 | sd.data.u.rts_req.fn, sapi, data); |
| 5309 | } |
| 5310 | [] PCU.receive { repeat; } |
| 5311 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5312 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5313 | } |
| 5314 | } |
| 5315 | } |
| 5316 | |
| 5317 | /* Send DATA.req on invalid BTS */ |
| 5318 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5319 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5320 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5321 | |
| 5322 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5323 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5324 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5325 | f_TfiUsfArrSet(tua, 7, 0); |
| 5326 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5327 | f_sleep(1.0); |
| 5328 | |
| 5329 | 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] | 5330 | } |
| 5331 | |
| 5332 | /* Send DATA.req on invalid TRX */ |
| 5333 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5334 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5335 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5336 | |
| 5337 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5338 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5339 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5340 | f_TfiUsfArrSet(tua, 7, 0); |
| 5341 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5342 | f_sleep(1.0); |
| 5343 | |
| 5344 | 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] | 5345 | } |
| 5346 | |
| 5347 | /* Send DATA.req on invalid timeslot */ |
| 5348 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5349 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5350 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5351 | |
| 5352 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5353 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5354 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5355 | f_TfiUsfArrSet(tua, 7, 0); |
| 5356 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5357 | f_sleep(1.0); |
| 5358 | |
| 5359 | 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] | 5360 | } |
| 5361 | |
| 5362 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 5363 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5364 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5365 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5366 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5367 | f_virtphy_common(); |
| 5368 | |
| 5369 | f_TfiUsfArrSet(tua, 7, 0); |
| 5370 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5371 | f_sleep(1.0); |
| 5372 | |
| 5373 | 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] | 5374 | } |
| 5375 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5376 | 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] | 5377 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 5378 | boolean wait_rts := true) |
| 5379 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5380 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5381 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5382 | |
| 5383 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5384 | if (wait_rts) { |
| 5385 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 5386 | } else { |
| 5387 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 5388 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5389 | |
| 5390 | T.start; |
| 5391 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5392 | [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] | 5393 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 5394 | setverdict(pass); |
| 5395 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5396 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 5397 | setverdict(fail, "Received unexpected ", rx_dl); |
| 5398 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5399 | [] L1CTL.receive { |
| 5400 | repeat; |
| 5401 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5402 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5403 | setverdict(fail, "Timeout waiting for ", data); |
| 5404 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5405 | [not expect_data] T.timeout { |
| 5406 | setverdict(pass); |
| 5407 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | |
| 5411 | private function f_disable_dynamic_ts() runs on test_CT |
| 5412 | { |
| 5413 | f_init_vty_bsc(); |
| 5414 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 5415 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 5416 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 5417 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5418 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5419 | } |
| 5420 | |
| 5421 | private function f_virtphy_common() runs on test_CT { |
| 5422 | f_disable_dynamic_ts(); |
| 5423 | f_init_l1ctl(); |
| 5424 | f_l1_tune(L1CTL); |
| 5425 | } |
| 5426 | |
| 5427 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 5428 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5429 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5430 | |
| 5431 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5432 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5433 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5434 | f_TfiUsfArrSet(tua, 7, 0); |
| 5435 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5436 | f_sleep(1.0); |
| 5437 | |
| 5438 | 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] | 5439 | } |
| 5440 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5441 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5442 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5443 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5444 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5445 | |
| 5446 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5447 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5448 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5449 | f_TfiUsfArrSet(tua, 7, 0); |
| 5450 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5451 | f_sleep(1.0); |
| 5452 | |
| 5453 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5454 | } |
| 5455 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5456 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 5457 | runs on test_CT { |
| 5458 | var template PCUIF_Message pcu_rach_ind; |
| 5459 | var PCUIF_send_data sd; |
| 5460 | var GsmFrameNumber fn; |
| 5461 | timer T; |
| 5462 | |
| 5463 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 5464 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 5465 | chan_nr := ts_RslChanNr_PDCH(7), |
| 5466 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 5467 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5468 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 5469 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5470 | |
| 5471 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 5472 | T.start(52.0 * 4.615 / 1000.0); |
| 5473 | alt { |
| 5474 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 5475 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 5476 | setverdict(pass); |
| 5477 | T.stop; |
| 5478 | } |
| 5479 | [] PCU.receive { repeat; } |
| 5480 | [] T.timeout { |
| 5481 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 5482 | /* Keep going, that's not the end of the world */ |
| 5483 | } |
| 5484 | } |
| 5485 | } |
| 5486 | |
| 5487 | testcase TC_pcu_ptcch() runs on test_CT { |
| 5488 | var L1ctlDlMessage dl; |
| 5489 | var octetstring data; |
| 5490 | timer T; |
| 5491 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5492 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5493 | f_init_l1ctl(); |
| 5494 | f_l1_tune(L1CTL); |
| 5495 | |
| 5496 | /* Activate PDCH channel on TS7 */ |
| 5497 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5498 | |
| 5499 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5500 | 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] | 5501 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5502 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5503 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5504 | |
| 5505 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 5506 | for (var integer i := 0; i < 16; i := i + 1) { |
| 5507 | log("Sending an Access Burst towards the L1CTL interface"); |
| 5508 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 5509 | } |
| 5510 | |
| 5511 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 5512 | data := f_rnd_octstring(23); |
| 5513 | |
| 5514 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 5515 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 5516 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 5517 | |
| 5518 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 5519 | * let's give it more time in case if we miss the beginning. */ |
| 5520 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 5521 | alt { |
| 5522 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 5523 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5524 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5525 | frame := data)) -> value dl { |
| 5526 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 5527 | setverdict(pass); |
| 5528 | T.stop; |
| 5529 | } |
| 5530 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 5531 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5532 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5533 | l2_data := data)) -> value dl { |
| 5534 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 5535 | setverdict(pass); |
| 5536 | T.stop; |
| 5537 | } |
| 5538 | [] L1CTL.receive { repeat; } |
| 5539 | [] T.timeout { |
| 5540 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 5541 | } |
| 5542 | } |
| 5543 | } |
| 5544 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5545 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5546 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 5547 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5548 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5549 | f_init_l1ctl(); |
| 5550 | f_l1_tune(L1CTL); |
| 5551 | |
| 5552 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5553 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5554 | |
| 5555 | T.start; |
| 5556 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5557 | [] 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] | 5558 | setverdict(pass); |
| 5559 | } |
| 5560 | [] L1CTL.receive { repeat; } |
| 5561 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5562 | 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] | 5563 | } |
| 5564 | } |
| 5565 | } |
| 5566 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5567 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5568 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5569 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5570 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5571 | f_init_l1ctl(); |
| 5572 | f_l1_tune(L1CTL); |
| 5573 | |
| 5574 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5575 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5576 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5577 | |
| 5578 | T.start; |
| 5579 | alt { |
| 5580 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5581 | setverdict(pass); |
| 5582 | } |
| 5583 | [] L1CTL.receive { repeat; } |
| 5584 | [] T.timeout { |
| 5585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5586 | } |
| 5587 | } |
| 5588 | } |
| 5589 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5590 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5591 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5592 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5593 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5594 | f_init_l1ctl(); |
| 5595 | f_l1_tune(L1CTL); |
| 5596 | |
| 5597 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5598 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5599 | |
| 5600 | timer T := 0.5; |
| 5601 | T.start; |
| 5602 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5603 | [] 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] | 5604 | /* TODO: verify paging group */ |
| 5605 | setverdict(pass); |
| 5606 | } |
| 5607 | [] L1CTL.receive { repeat; } |
| 5608 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5609 | 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] | 5610 | } |
| 5611 | } |
| 5612 | } |
| 5613 | |
| 5614 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5615 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5616 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5617 | f_init_l1ctl(); |
| 5618 | f_l1_tune(L1CTL); |
| 5619 | |
| 5620 | var GsmFrameNumber fn_last := 0; |
| 5621 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5622 | var OCT1 ra := f_rnd_ra_ps(); |
| 5623 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5624 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5625 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5626 | } |
| 5627 | fn_last := fn; |
| 5628 | |
| 5629 | timer T := 2.0; |
| 5630 | T.start; |
| 5631 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5632 | [] 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] | 5633 | T.stop; |
| 5634 | } |
| 5635 | [] 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] | 5636 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5637 | } |
| 5638 | [] PCU.receive { repeat; } |
| 5639 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5640 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5641 | } |
| 5642 | } |
| 5643 | } |
| 5644 | setverdict(pass); |
| 5645 | } |
| 5646 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5647 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5648 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5649 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5650 | var template PCUIF_Message pcu_rach_ind; |
| 5651 | var GsmFrameNumber fn_last := 0; |
| 5652 | var L1ctlRachSynchSeq synch_seq; |
| 5653 | var PCUIF_BurstType pcu_bt; |
| 5654 | var GsmFrameNumber fn; |
| 5655 | var BIT11 ra11; |
| 5656 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5657 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5658 | f_init_l1ctl(); |
| 5659 | f_l1_tune(L1CTL); |
| 5660 | |
| 5661 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5662 | /* We need to test both TS1 & TS2 */ |
| 5663 | if (i rem 2 == 0) { |
| 5664 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5665 | pcu_bt := BURST_TYPE_1; |
| 5666 | } else { |
| 5667 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5668 | pcu_bt := BURST_TYPE_2; |
| 5669 | } |
| 5670 | |
| 5671 | ra11 := f_rnd_ra11_ps(); |
| 5672 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5673 | if (fn == fn_last) { |
| 5674 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5675 | "Two RACH in same FN?!?"); |
| 5676 | } |
| 5677 | fn_last := fn; |
| 5678 | |
| 5679 | /* Compose the expected message */ |
| 5680 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5681 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5682 | ra := bit2int(ra11), |
| 5683 | is_11bit := 1, |
| 5684 | burst_type := pcu_bt, |
| 5685 | fn := fn); |
| 5686 | |
| 5687 | timer T := 2.0; |
| 5688 | T.start; |
| 5689 | alt { |
| 5690 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5691 | T.stop; |
| 5692 | } |
| 5693 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5694 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5695 | } |
| 5696 | [] PCU.receive { repeat; } |
| 5697 | [] T.timeout { |
| 5698 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5699 | } |
| 5700 | } |
| 5701 | } |
| 5702 | setverdict(pass); |
| 5703 | } |
| 5704 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5705 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5706 | runs on test_CT { |
| 5707 | var template PCUIF_send_data sdt; |
| 5708 | var PCUIF_send_data sd; |
| 5709 | var int16_t lqual_cb; |
| 5710 | timer T := 1.0; |
| 5711 | |
| 5712 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5713 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5714 | |
| 5715 | /* Send a random PDTCH frame over Um */ |
| 5716 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5717 | '0000'O & f_rnd_octstring(21))); |
| 5718 | |
| 5719 | T.start; |
| 5720 | alt { |
| 5721 | /* If expected link quality is above the threshold */ |
| 5722 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5723 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5724 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5725 | |
| 5726 | /* Make sure the actual link quality matches the expected value */ |
| 5727 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5728 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5729 | "expected value ", lqual_cb_exp)); |
| 5730 | } else { |
| 5731 | setverdict(pass); |
| 5732 | } |
| 5733 | } |
| 5734 | /* If expected link quality is below the threshold */ |
| 5735 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5736 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5737 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5738 | } |
| 5739 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5740 | [] PCU.receive { repeat; } |
| 5741 | [lqual_cb_exp < thresh] T.timeout { |
| 5742 | log("Rx nothing, as expected"); |
| 5743 | setverdict(pass); |
| 5744 | } |
| 5745 | [lqual_cb_exp >= thresh] T.timeout { |
| 5746 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5747 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5748 | } |
| 5749 | } |
| 5750 | } |
| 5751 | |
| 5752 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5753 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5754 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5755 | PCU.clear; |
| 5756 | |
| 5757 | f_init_l1ctl(); |
| 5758 | f_l1_tune(L1CTL); |
| 5759 | |
| 5760 | /* Activate a PDCH channel on TS7 */ |
| 5761 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5762 | |
| 5763 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5764 | 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] | 5765 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5766 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5767 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5768 | |
| 5769 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5770 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5771 | var TrxcMessage ret; |
| 5772 | |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 5773 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(i)); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5774 | |
| 5775 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5776 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5777 | } |
| 5778 | } |
| 5779 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5780 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5781 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5782 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5783 | |
| 5784 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5785 | var MobileIdentityLV mi_lv; |
| 5786 | var octetstring mi_lv_enc; |
| 5787 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5788 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5789 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5790 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5791 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5792 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5793 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5794 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5795 | |
| 5796 | /* Fancy encoding for PCUIF */ |
| 5797 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5798 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5799 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5800 | |
| 5801 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5802 | 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] | 5803 | T.start; |
| 5804 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5805 | [] 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] | 5806 | } |
| 5807 | [] 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] | 5808 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5809 | } |
| 5810 | [] PCU.receive { repeat; } |
| 5811 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5812 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5813 | } |
| 5814 | } |
| 5815 | } |
| 5816 | setverdict(pass); |
| 5817 | } |
| 5818 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5819 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5820 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5821 | var PCUIF_send_data pcu_sd; |
| 5822 | var integer num_time_ind := 0; |
| 5823 | var integer first_fn, last_fn; |
| 5824 | var float test_duration := 5.0; |
| 5825 | timer T; |
| 5826 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5827 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5828 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5829 | |
| 5830 | PCU.clear; |
| 5831 | T.start(test_duration); |
| 5832 | alt { |
| 5833 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5834 | num_time_ind := num_time_ind + 1; |
| 5835 | if (not isbound(first_fn)) { |
| 5836 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5837 | } |
| 5838 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5839 | repeat; |
| 5840 | } |
| 5841 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5842 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5843 | repeat; |
| 5844 | } |
| 5845 | [] PCU.receive { |
| 5846 | repeat; |
| 5847 | } |
| 5848 | [] T.timeout {} |
| 5849 | } |
| 5850 | var integer fn_expired := last_fn - first_fn; |
| 5851 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5852 | |
| 5853 | /* verify the number of frames expired matches our expectation */ |
| 5854 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5855 | 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] | 5856 | 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] | 5857 | if (not match(fn_expired, t_fn_expected)) { |
| 5858 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5859 | } |
| 5860 | |
| 5861 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5862 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5863 | /* Add some tolerance */ |
| 5864 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5865 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5866 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5867 | } |
| 5868 | |
| 5869 | setverdict(pass); |
| 5870 | } |
| 5871 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5872 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 5873 | testcase TC_pcu_rts_req() runs on test_CT { |
| 5874 | var PCUIF_send_data pcu_sd; |
| 5875 | var integer first_fn, last_fn; |
| 5876 | var integer num_rts_pdtch := 0; |
| 5877 | var integer num_rts_ptcch := 0; |
| 5878 | var float test_duration := 5.0; |
| 5879 | timer T; |
| 5880 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5881 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 5882 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5883 | |
| 5884 | PCU.clear; |
| 5885 | T.start(test_duration); |
| 5886 | alt { |
| 5887 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 5888 | -> value pcu_sd { |
| 5889 | num_rts_pdtch := num_rts_pdtch + 1; |
| 5890 | if (not isbound(first_fn)) { |
| 5891 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5892 | } |
| 5893 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5894 | repeat; |
| 5895 | } |
| 5896 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 5897 | -> value pcu_sd { |
| 5898 | num_rts_ptcch := num_rts_ptcch + 1; |
| 5899 | if (not isbound(first_fn)) { |
| 5900 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 5901 | } |
| 5902 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 5903 | repeat; |
| 5904 | } |
| 5905 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 5906 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 5907 | repeat; |
| 5908 | } |
| 5909 | [] PCU.receive { |
| 5910 | repeat; |
| 5911 | } |
| 5912 | [] T.timeout {} |
| 5913 | } |
| 5914 | var integer fn_expired := last_fn - first_fn; |
| 5915 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 5916 | ", num_rts_ptcch=", num_rts_ptcch); |
| 5917 | |
| 5918 | /* verify the number of frames expired matches our expectation */ |
| 5919 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5920 | 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] | 5921 | 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] | 5922 | if (not match(fn_expired, t_fn_expected)) { |
| 5923 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5924 | } |
| 5925 | |
| 5926 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 5927 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 5928 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 5929 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 5930 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 5931 | t_ptcch_exp); |
| 5932 | } |
| 5933 | |
| 5934 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 5935 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 5936 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 5937 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 5938 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 5939 | t_pdtch_exp); |
| 5940 | } |
| 5941 | |
| 5942 | setverdict(pass); |
| 5943 | } |
| 5944 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5945 | /* test for generating Abis side OML ALERT from the PCU */ |
| 5946 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 5947 | var PCUIF_send_data pcu_sd; |
| 5948 | var integer num_time_ind := 0; |
| 5949 | var integer first_fn, last_fn; |
| 5950 | var float test_duration := 5.0; |
| 5951 | timer T; |
| 5952 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5953 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5954 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5955 | |
| 5956 | /* re-connect CTRL port from BTS to BSC */ |
| 5957 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 5958 | f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5959 | |
| 5960 | /* Send that OML Alert */ |
| 5961 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 5962 | |
| 5963 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 5964 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 5965 | setverdict(pass); |
| 5966 | } |
| 5967 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 5968 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 5969 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 5970 | var PCUIF_Message first_info; |
| 5971 | var integer pcu_conn_id := -1; |
| 5972 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5973 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 5974 | var OCT4 tlli := '01020304'O; |
| 5975 | var OCT1 cause := '23'O; |
| 5976 | timer T := 5.0; |
| 5977 | |
| 5978 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5979 | |
| 5980 | f_l1_tune(L1CTL); |
| 5981 | RSL.clear; |
| 5982 | |
| 5983 | f_est_dchan(); |
| 5984 | L1CTL.clear; |
| 5985 | |
| 5986 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5987 | |
| 5988 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 5989 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 5990 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 5991 | |
| 5992 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 5993 | T.start; |
| 5994 | alt { |
| 5995 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 5996 | setverdict(pass); |
| 5997 | } |
| 5998 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 5999 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 6000 | } |
| 6001 | [] PCU.receive { |
| 6002 | repeat; |
| 6003 | } |
| 6004 | [] T.timeout { |
| 6005 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 6006 | } |
| 6007 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 6008 | |
| 6009 | /* release the channel */ |
| 6010 | f_rsl_chan_deact(); |
| 6011 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6012 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6013 | } |
| 6014 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 6015 | var ConnHdlrPars pars; |
| 6016 | var ConnHdlr vc_conn; |
| 6017 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6018 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6019 | |
| 6020 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 6021 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 6022 | vc_conn.done; |
| 6023 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6024 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6025 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 6026 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6027 | var boolean connected := false; |
| 6028 | var UD_connect_result cr; |
| 6029 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6030 | timer T := 5.0; |
| 6031 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6032 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 6033 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 6034 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6035 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6036 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6037 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6038 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6039 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 6040 | T.start; |
| 6041 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6042 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 6043 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 6044 | log("BTS has accept()ed connection"); |
| 6045 | connected := true; |
| 6046 | cid := cr.id; |
| 6047 | repeat; |
| 6048 | } |
| 6049 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 6050 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6051 | setverdict(pass); |
| 6052 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6053 | /* ignore other messages related to the first connection */ |
| 6054 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6055 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6056 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6057 | } |
| 6058 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6059 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6060 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6061 | } |
| 6062 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6063 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 6064 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 6065 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6066 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6067 | |
| 6068 | f_sleep(1.0); |
| 6069 | |
| 6070 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6071 | g_pcu_conn_id := -1; |
| 6072 | |
| 6073 | f_sleep(1.0); |
| 6074 | |
| 6075 | /* re-connect */ |
| 6076 | PCU.clear; |
| 6077 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6078 | setverdict(pass); |
| 6079 | |
| 6080 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6081 | } |
| 6082 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6083 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6084 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 6085 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6086 | var L1ctlDlMessage l1_dl; |
| 6087 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 6088 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6089 | timer T := 5.0; |
| 6090 | T.start; |
| 6091 | alt { |
| 6092 | [] 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] | 6093 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 6094 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6095 | repeat; |
| 6096 | } |
| 6097 | } |
| 6098 | [] pt.receive { |
| 6099 | repeat; |
| 6100 | } |
| 6101 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6102 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6103 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6104 | } |
| 6105 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6106 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6107 | } |
| 6108 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6109 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 6110 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 6111 | runs on test_CT return boolean { |
| 6112 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 6113 | |
| 6114 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6115 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6116 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6117 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6118 | } |
| 6119 | |
| 6120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 6121 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6122 | } |
| 6123 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6124 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 6125 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 6126 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6127 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6128 | f_init_l1ctl(); |
| 6129 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6130 | f_sleep(2.0); |
| 6131 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6132 | |
| 6133 | if (f_si_has_gprs_indicator(si_type)) { |
| 6134 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6135 | } else { |
| 6136 | setverdict(pass); |
| 6137 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6138 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6139 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6140 | } |
| 6141 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6142 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 6143 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6144 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6145 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6146 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 6147 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6148 | } |
| 6149 | |
| 6150 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 6151 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 6152 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6153 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6154 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6155 | f_init_l1ctl(); |
| 6156 | f_l1_tune(L1CTL); |
| 6157 | |
| 6158 | f_sleep(2.0); |
| 6159 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6160 | |
| 6161 | if (not f_si_has_gprs_indicator(si_type)) { |
| 6162 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6163 | } else { |
| 6164 | setverdict(pass); |
| 6165 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6166 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6167 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6168 | } |
| 6169 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6170 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 6171 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 6172 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6173 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6174 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 6175 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 6176 | } |
| 6177 | |
| 6178 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 6179 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 6180 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6181 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6182 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6183 | f_init_l1ctl(); |
| 6184 | f_l1_tune(L1CTL); |
| 6185 | |
| 6186 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6187 | g_pcu_conn_id := -1; |
| 6188 | |
| 6189 | f_sleep(1.0); |
| 6190 | |
| 6191 | /* re-connect */ |
| 6192 | PCU.clear; |
| 6193 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6194 | |
| 6195 | f_sleep(2.0); |
| 6196 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6197 | |
| 6198 | if (f_si_has_gprs_indicator(si_type)) { |
| 6199 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6200 | } else { |
| 6201 | setverdict(pass); |
| 6202 | } |
| 6203 | |
| 6204 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6205 | } |
| 6206 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6207 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 6208 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6209 | } |
| 6210 | |
| 6211 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 6212 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6213 | } |
| 6214 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6215 | /* 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) */ |
| 6216 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 6217 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 6218 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6219 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6220 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 6221 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 6222 | * information */ |
| 6223 | timer T := 2.0; |
| 6224 | T.start; |
| 6225 | alt { |
| 6226 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 6227 | [] T.timeout {} |
| 6228 | } |
| 6229 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6230 | /* Verify cell_id */ |
| 6231 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 6232 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 6233 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 6234 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 6235 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 6236 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6237 | } |
| 6238 | |
| 6239 | /* Verify LAC */ |
| 6240 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 6241 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 6242 | if (lac_si3 != lac_pcu) { |
| 6243 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 6244 | } |
| 6245 | |
| 6246 | setverdict(pass); |
| 6247 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6248 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6249 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 6250 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 6251 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6252 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6253 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6254 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6255 | |
| 6256 | info_ind := g_pcu_last_info.u.info_ind; |
| 6257 | |
| 6258 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 6259 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6260 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6261 | /* Skip inactive timeslots */ |
| 6262 | continue; |
| 6263 | } |
| 6264 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6265 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 6266 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6267 | else |
| 6268 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6269 | |
| 6270 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6271 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6272 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6273 | hsn := fhp.maio_hsn.hsn, |
| 6274 | maio := fhp.maio_hsn.maio, |
| 6275 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 6276 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6277 | } else { |
| 6278 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 6279 | } |
| 6280 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6281 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6282 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 6283 | if (not match(ts, tr_ts)) { |
| 6284 | setverdict(fail, "Hopping parameters do not match: ", |
| 6285 | "received ", ts, " vs expected ", tr_ts); |
| 6286 | } else { |
| 6287 | setverdict(pass); |
| 6288 | } |
| 6289 | } |
| 6290 | } |
| 6291 | } |
| 6292 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6293 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6294 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 6295 | f_init_vty_bsc(); |
| 6296 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6297 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6298 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6299 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6300 | |
| 6301 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6302 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6303 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6304 | addr := { f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), ? } |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6305 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6306 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6307 | if (not match(remote_addr, tr_remote_addr)) { |
| 6308 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6309 | } |
| 6310 | |
| 6311 | setverdict(pass); |
| 6312 | } |
| 6313 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6314 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6315 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 6316 | f_init_vty_bsc(); |
| 6317 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 6318 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6319 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6320 | |
| 6321 | var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr; |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6322 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6323 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 6324 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 6325 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6326 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6327 | if (not match(remote_addr, tr_remote_addr)) { |
| 6328 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6329 | } |
| 6330 | |
| 6331 | setverdict(pass); |
| 6332 | } |
| 6333 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6334 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 6335 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 6336 | f_init_vty_bsc(); |
| 6337 | |
| 6338 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 6339 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 6340 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6341 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 6342 | |
| 6343 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 6344 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 6345 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 6346 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 6347 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6348 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6349 | |
| 6350 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 6351 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 6352 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6353 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6354 | addr := { |
| 6355 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 6356 | f_inet6_addr("fd00::ca:ff:ee") |
| 6357 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6358 | }; |
| 6359 | |
| 6360 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 6361 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 6362 | if (not match(remote_addr, tr_remote_addr)) |
| 6363 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 6364 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 6365 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 6366 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 6367 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 6368 | |
| 6369 | setverdict(pass); |
| 6370 | } |
| 6371 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6372 | /* Verify periodic interference reports on PDCH */ |
| 6373 | testcase TC_pcu_interf_ind() runs on test_CT { |
| 6374 | var template PCUIF_Message tr_interf_ind; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6375 | var integer interf_ind_num := 0; |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6376 | var boolean first := true; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6377 | var PCUIF_send_data sd; |
| 6378 | timer T; |
| 6379 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6380 | /* Set the averaging/reporting period to 480ms */ |
| 6381 | f_init_vty_bsc(); |
| 6382 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 1" }); |
| 6383 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6384 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6385 | f_init_with_pcuif(); |
| 6386 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6387 | |
| 6388 | /* We need trxcon for NOPE indications */ |
| 6389 | f_init_l1ctl(); |
| 6390 | f_l1_tune(L1CTL); |
| 6391 | |
| 6392 | /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */ |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6393 | tr_interf_ind := tr_PCUIF_INTERF_IND( |
| 6394 | bts_nr := 0, |
| 6395 | trx_nr := 0, |
| 6396 | fn := ?, |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 6397 | interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) } |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6398 | ); |
| 6399 | |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6400 | T.start(0.480 * 1.5); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6401 | alt { |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6402 | /* The first interference report may contain unreliable values, so we ignore it */ |
| 6403 | [first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) { |
| 6404 | /* 4 SACCH periods => 4 reports (plus some guard time) */ |
| 6405 | T.start(0.480 * 4.0 + 0.480 / 2.0); |
| 6406 | first := false; |
| 6407 | repeat; |
| 6408 | } |
| 6409 | /* Subsequent interference reports shall match our expectations */ |
| 6410 | [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd { |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6411 | /* Check TDMA frame number period */ |
| 6412 | if (sd.data.u.interf_ind.fn mod 104 != 0) { |
| 6413 | setverdict(fail, "Odd TDMA frame number := ", |
| 6414 | sd.data.u.interf_ind.fn); |
| 6415 | } |
| 6416 | interf_ind_num := interf_ind_num + 1; |
| 6417 | if (interf_ind_num < 4) |
| 6418 | { repeat; } |
| 6419 | } |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6420 | [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd { |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6421 | setverdict(fail, "Received unexpected interference report: ", sd.data); |
| 6422 | } |
| 6423 | [] PCU.receive { repeat; } |
| 6424 | [] T.timeout { |
| 6425 | setverdict(fail, "Timeout waiting for interference reports"); |
| 6426 | } |
| 6427 | } |
| 6428 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6429 | /* Reset the averaging/reporting period back to default */ |
| 6430 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 6" }); |
| 6431 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6432 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6433 | } |
| 6434 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6435 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6436 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6437 | ***********************************************************************/ |
| 6438 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6439 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 6440 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6441 | runs on ConnHdlr { |
| 6442 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6443 | |
| 6444 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6445 | var BIT8 pdch_mask := sd.data.u.info_ind.trx[trx_nr].pdch_mask; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6446 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 6447 | repeat; |
| 6448 | } |
| 6449 | } |
| 6450 | } |
| 6451 | |
| 6452 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6453 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6454 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6455 | PCU.clear; |
| 6456 | f_rsl_chan_act(g_pars.chan_mode); |
| 6457 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6458 | timer T_wait := 2.0; |
| 6459 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6460 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6461 | [] 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] | 6462 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6463 | [] T_wait.timeout { |
| 6464 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6465 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6466 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6467 | } |
| 6468 | /* try to activate this PDCH from the PCU point of view */ |
| 6469 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6470 | /* FIXME: is there a response? */ |
| 6471 | } |
| 6472 | |
| 6473 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6474 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6475 | /* Send RSL CHAN REL (deactivate) */ |
| 6476 | PCU.clear; |
| 6477 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6478 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6479 | timer T_wait := 2.0; |
| 6480 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6481 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6482 | [] 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] | 6483 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6484 | [] T_wait.timeout { |
| 6485 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6486 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6487 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6488 | } |
| 6489 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6490 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6491 | alt { |
| 6492 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 6493 | setverdict(pass); |
| 6494 | } |
| 6495 | [] RSL.receive { repeat; } |
| 6496 | } |
| 6497 | } |
| 6498 | |
| 6499 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6500 | 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] | 6501 | var PCUIF_Message first_info; |
| 6502 | var integer ts_nr := g_chan_nr.tn; |
| 6503 | var integer trx_nr := 0; |
| 6504 | var integer bts_nr := 0; |
| 6505 | var integer pcu_conn_id := -1; |
| 6506 | |
| 6507 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6508 | |
| 6509 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6510 | f_sleep(3.0); |
| 6511 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6512 | setverdict(pass); |
| 6513 | } |
| 6514 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 6515 | var ConnHdlrPars pars; |
| 6516 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6517 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6518 | |
| 6519 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6520 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 6521 | vc_conn.done; |
| 6522 | } |
| 6523 | |
| 6524 | /* 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] | 6525 | 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] | 6526 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6527 | var integer pcu_conn_id := -1; |
| 6528 | |
| 6529 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6530 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 6531 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6532 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 6533 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6534 | setverdict(pass); |
| 6535 | } |
| 6536 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 6537 | var ConnHdlrPars pars; |
| 6538 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6539 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6540 | |
| 6541 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6542 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 6543 | vc_conn.done; |
| 6544 | } |
| 6545 | |
| 6546 | /* 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] | 6547 | 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] | 6548 | var PCUIF_Message first_info; |
| 6549 | var integer ts_nr := g_chan_nr.tn; |
| 6550 | var integer trx_nr := 0; |
| 6551 | var integer bts_nr := 0; |
| 6552 | var integer pcu_conn_id := -1; |
| 6553 | |
| 6554 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6555 | |
| 6556 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 6557 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 6558 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6559 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6560 | setverdict(pass); |
| 6561 | } |
| 6562 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 6563 | var ConnHdlrPars pars; |
| 6564 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6565 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6566 | |
| 6567 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6568 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 6569 | vc_conn.done; |
| 6570 | } |
| 6571 | |
| 6572 | /* 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] | 6573 | 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] | 6574 | var PCUIF_Message first_info; |
| 6575 | var integer ts_nr := g_chan_nr.tn; |
| 6576 | var integer trx_nr := 0; |
| 6577 | var integer bts_nr := 0; |
| 6578 | var integer pcu_conn_id := -1; |
| 6579 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 6580 | |
| 6581 | /* register for the TCH/F channel number */ |
| 6582 | f_rslem_register(0, chan_nr); |
| 6583 | |
| 6584 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6585 | |
| 6586 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 6587 | "RSL CHAN ACT"); |
| 6588 | setverdict(pass); |
| 6589 | } |
| 6590 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 6591 | var ConnHdlrPars pars; |
| 6592 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6593 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6594 | |
| 6595 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6596 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 6597 | vc_conn.done; |
| 6598 | } |
| 6599 | |
| 6600 | /* 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] | 6601 | 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] | 6602 | var PCUIF_Message first_info; |
| 6603 | var integer ts_nr := g_chan_nr.tn; |
| 6604 | var integer trx_nr := 0; |
| 6605 | var integer bts_nr := 0; |
| 6606 | var integer pcu_conn_id := -1; |
| 6607 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 6608 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 6609 | |
| 6610 | /* register for the TCH/H channel numbers */ |
| 6611 | f_rslem_register(0, chan_nr[0]); |
| 6612 | f_rslem_register(0, chan_nr[1]); |
| 6613 | |
| 6614 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6615 | |
| 6616 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6617 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6618 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6619 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6620 | setverdict(pass); |
| 6621 | } |
| 6622 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6623 | var ConnHdlrPars pars; |
| 6624 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6625 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6626 | |
| 6627 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6628 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6629 | vc_conn.done; |
| 6630 | } |
| 6631 | |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 6632 | /* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */ |
| 6633 | private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr { |
| 6634 | var PCUIF_Message first_info; |
| 6635 | var integer ts_nr := g_chan_nr.tn; |
| 6636 | var integer trx_nr := 0; |
| 6637 | var integer bts_nr := 0; |
| 6638 | var integer pcu_conn_id := -1; |
| 6639 | var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)), |
| 6640 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)), |
| 6641 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)), |
| 6642 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)), |
| 6643 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)), |
| 6644 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)), |
| 6645 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)), |
| 6646 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) }; |
| 6647 | |
| 6648 | /* register for the TCH/H channel numbers */ |
| 6649 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6650 | f_rslem_register(0, chan_nr[i]); |
| 6651 | } |
| 6652 | |
| 6653 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6654 | |
| 6655 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6656 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode), |
| 6657 | tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]"); |
| 6658 | } |
| 6659 | setverdict(pass); |
| 6660 | } |
| 6661 | testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT { |
| 6662 | var ConnHdlrPars pars; |
| 6663 | var ConnHdlr vc_conn; |
| 6664 | f_init(); |
| 6665 | |
| 6666 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6667 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true); |
| 6668 | vc_conn.done; |
| 6669 | } |
| 6670 | |
Vadim Yanitskiy | 64043d8 | 2021-10-03 15:00:20 +0600 | [diff] [blame] | 6671 | /* Reproduce a race condition described in OS#5245 */ |
| 6672 | private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr { |
| 6673 | f_rsl_chan_act(g_pars.chan_mode); |
| 6674 | f_sleep(1.0); |
| 6675 | f_rsl_chan_deact(); |
| 6676 | setverdict(pass); |
| 6677 | } |
| 6678 | testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT { |
| 6679 | var ConnHdlrPars pars[2]; |
| 6680 | var ConnHdlr vc_conn[2]; |
| 6681 | var TrxcMessage rsp; |
| 6682 | |
| 6683 | f_init(); |
| 6684 | |
| 6685 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6686 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6687 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6688 | |
| 6689 | /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second |
| 6690 | * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */ |
| 6691 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6692 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */ |
| 6693 | pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN)); |
| 6694 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6695 | pars[i], l1ctl := false); |
| 6696 | } |
| 6697 | |
| 6698 | /* Wait for all components to finish */ |
| 6699 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6700 | vc_conn[i].done; |
| 6701 | } |
| 6702 | |
| 6703 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6704 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6705 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6706 | } |
| 6707 | testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT { |
| 6708 | var ConnHdlrPars pars[8]; |
| 6709 | var ConnHdlr vc_conn[8]; |
| 6710 | var TrxcMessage rsp; |
| 6711 | |
| 6712 | f_init(); |
| 6713 | |
| 6714 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6715 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6716 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6717 | |
| 6718 | /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent |
| 6719 | * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */ |
| 6720 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6721 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */ |
| 6722 | pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN)); |
| 6723 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6724 | pars[i], l1ctl := false); |
| 6725 | } |
| 6726 | |
| 6727 | /* Wait for all components to finish */ |
| 6728 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6729 | vc_conn[i].done; |
| 6730 | } |
| 6731 | |
| 6732 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6733 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6734 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6735 | } |
| 6736 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6737 | /*********************************************************************** |
| 6738 | * IPA Style Dynamic Timeslot Support |
| 6739 | ***********************************************************************/ |
| 6740 | |
| 6741 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6742 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6743 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6744 | PCU.clear; |
| 6745 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6746 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6747 | timer T_wait := 2.0; |
| 6748 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6749 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6750 | [] 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] | 6751 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6752 | [] T_wait.timeout { |
| 6753 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6754 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6755 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6756 | } |
| 6757 | /* try to activate this PDCH from the PCU point of view */ |
| 6758 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6759 | /* FIXME: is there a response? */ |
| 6760 | |
| 6761 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6762 | } |
| 6763 | |
| 6764 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6765 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6766 | /* Send RSL CHAN REL (deactivate) */ |
| 6767 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6768 | PCU.clear; |
| 6769 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6770 | timer T_wait := 2.0; |
| 6771 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6772 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6773 | [] 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] | 6774 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6775 | [] T_wait.timeout { |
| 6776 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6777 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6778 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6779 | } |
| 6780 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6781 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6782 | alt { |
| 6783 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6784 | setverdict(pass); |
| 6785 | } |
| 6786 | [] RSL.receive { repeat; } |
| 6787 | } |
| 6788 | } |
| 6789 | |
| 6790 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6791 | 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] | 6792 | var PCUIF_Message first_info; |
| 6793 | var integer ts_nr := g_chan_nr.tn; |
| 6794 | var integer trx_nr := 0; |
| 6795 | var integer bts_nr := 0; |
| 6796 | var integer pcu_conn_id := -1; |
| 6797 | |
| 6798 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6799 | |
| 6800 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6801 | f_sleep(3.0); |
| 6802 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6803 | |
| 6804 | setverdict(pass); |
| 6805 | |
| 6806 | } |
| 6807 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6808 | var ConnHdlrPars pars; |
| 6809 | var ConnHdlr vc_conn; |
| 6810 | f_init(); |
| 6811 | |
| 6812 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6813 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6814 | vc_conn.done; |
| 6815 | } |
| 6816 | |
| 6817 | /* 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] | 6818 | 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] | 6819 | var PCUIF_Message first_info; |
| 6820 | var integer ts_nr := g_chan_nr.tn; |
| 6821 | var integer trx_nr := 0; |
| 6822 | var integer bts_nr := 0; |
| 6823 | var integer pcu_conn_id := -1; |
| 6824 | |
| 6825 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6826 | |
| 6827 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6828 | "RSL CHAN ACT"); |
| 6829 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6830 | "RF CHAN REL", true); |
| 6831 | setverdict(pass); |
| 6832 | } |
| 6833 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6834 | var ConnHdlrPars pars; |
| 6835 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6836 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6837 | |
| 6838 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6839 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6840 | vc_conn.done; |
| 6841 | } |
| 6842 | |
| 6843 | /* 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] | 6844 | 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] | 6845 | var PCUIF_Message first_info; |
| 6846 | var integer ts_nr := g_chan_nr.tn; |
| 6847 | var integer trx_nr := 0; |
| 6848 | var integer bts_nr := 0; |
| 6849 | var integer pcu_conn_id := -1; |
| 6850 | |
| 6851 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6852 | |
| 6853 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6854 | "RSL CHAN ACT"); |
| 6855 | |
| 6856 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6857 | alt { |
| 6858 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6859 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6860 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6861 | } |
| 6862 | [] RSL.receive { repeat; } |
| 6863 | } |
| 6864 | |
| 6865 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6866 | "RF CHAN REL", true); |
| 6867 | setverdict(pass); |
| 6868 | } |
| 6869 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6870 | var ConnHdlrPars pars; |
| 6871 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6872 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6873 | |
| 6874 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6875 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 6876 | vc_conn.done; |
| 6877 | } |
| 6878 | |
| 6879 | /* 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] | 6880 | 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] | 6881 | var PCUIF_Message first_info; |
| 6882 | var integer ts_nr := g_chan_nr.tn; |
| 6883 | var integer trx_nr := 0; |
| 6884 | var integer bts_nr := 0; |
| 6885 | var integer pcu_conn_id := -1; |
| 6886 | |
| 6887 | /* register for the TCH/F channel number */ |
| 6888 | f_rslem_register(0, g_chan_nr); |
| 6889 | |
| 6890 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6891 | |
| 6892 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6893 | |
| 6894 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6895 | "RSL CHAN ACT"); |
| 6896 | |
| 6897 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6898 | |
| 6899 | setverdict(pass); |
| 6900 | } |
| 6901 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 6902 | var ConnHdlrPars pars; |
| 6903 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6904 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6905 | |
| 6906 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6907 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 6908 | vc_conn.done; |
| 6909 | } |
| 6910 | |
| 6911 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6912 | /*********************************************************************** |
| 6913 | * LAPDm / RLL related |
| 6914 | ***********************************************************************/ |
| 6915 | |
| 6916 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 6917 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 6918 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6919 | var template (value) SacchL1Header l1h; |
| 6920 | |
| 6921 | /* 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] | 6922 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6923 | /* Compose dummy L1 header */ |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 6924 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6925 | 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] | 6926 | } else { |
| 6927 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 6928 | 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] | 6929 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6930 | } |
| 6931 | |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6932 | friend type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6933 | uint3_t sapi, |
| 6934 | RslLinkId link_id, |
| 6935 | octetstring l3, |
| 6936 | boolean exp |
| 6937 | } |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6938 | friend type record of RllTestCase RllTestCases; |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 6939 | friend template RllTestCase t_EITC(template (present) uint3_t sapi, |
| 6940 | template (present) RslLinkId id, |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 6941 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6942 | sapi := sapi, |
| 6943 | link_id := id, |
| 6944 | l3 := l3, |
| 6945 | exp := exp |
| 6946 | } |
| 6947 | |
| 6948 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 6949 | * variety of logical channels */ |
| 6950 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 6951 | var ConnHdlrPars pars; |
| 6952 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6953 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6954 | |
| 6955 | /* test on each of the channels we have */ |
| 6956 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 6957 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 6958 | |
| 6959 | /* test each of the test cases on the current channel */ |
| 6960 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 6961 | pars.spec.rll := tcs[j]; |
| 6962 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 6963 | vc_conn := f_start_handler(fn, pars); |
| 6964 | vc_conn.done; |
| 6965 | } |
| 6966 | } |
| 6967 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6968 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6969 | } |
| 6970 | |
| 6971 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 6972 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 6973 | var RllTestCase tc := g_pars.spec.rll; |
| 6974 | timer T := 3.0; |
| 6975 | |
| 6976 | f_l1_tune(L1CTL); |
| 6977 | RSL.clear; |
| 6978 | |
| 6979 | /* activate the logical channel */ |
| 6980 | f_est_dchan(); |
| 6981 | L1CTL.clear; |
| 6982 | |
| 6983 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 6984 | T.start; |
| 6985 | alt { |
| 6986 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 6987 | if (tc.exp) { |
| 6988 | setverdict(pass); |
| 6989 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6990 | 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] | 6991 | } |
| 6992 | } |
| 6993 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 6994 | if (tc.exp) { |
| 6995 | setverdict(pass); |
| 6996 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6997 | 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] | 6998 | } |
| 6999 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7000 | /* We also expect to receive the measurements */ |
| 7001 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7002 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7003 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7004 | } |
| 7005 | [not tc.exp] T.timeout { |
| 7006 | setverdict(pass); |
| 7007 | } |
| 7008 | } |
| 7009 | |
| 7010 | f_rsl_chan_deact(); |
| 7011 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7012 | f_rslem_unregister(0, g_chan_nr); |
| 7013 | } |
| 7014 | testcase TC_rll_est_ind() runs on test_CT { |
| 7015 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7016 | /* SAPI0 establishment (contention resolution) */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7017 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7018 | /* normal SAPI0 establishment */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7019 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7020 | /* SAPI 3 doesn't support contention resolution */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7021 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)), |
| 7022 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7023 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7024 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7025 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7026 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7027 | }; |
| 7028 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 7029 | } |
| 7030 | |
| 7031 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 7032 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 7033 | var RllTestCase tc := g_pars.spec.rll; |
| 7034 | var L1ctlDlMessage dl; |
| 7035 | timer T := 3.0; |
| 7036 | |
| 7037 | f_l1_tune(L1CTL); |
| 7038 | RSL.clear; |
| 7039 | |
| 7040 | /* activate the logical channel */ |
| 7041 | f_est_dchan(); |
| 7042 | L1CTL.clear; |
| 7043 | |
| 7044 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 7045 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 7046 | T.start; |
| 7047 | alt { |
Vadim Yanitskiy | 0310f63 | 2021-06-01 01:22:24 +0200 | [diff] [blame] | 7048 | [] as_l1_exp_lapdm(tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7049 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7050 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7051 | } |
| 7052 | } |
| 7053 | |
| 7054 | f_rsl_chan_deact(); |
| 7055 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7056 | f_rslem_unregister(0, g_chan_nr); |
| 7057 | } |
| 7058 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 7059 | var RllTestCases tcs := { |
| 7060 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7061 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7062 | }; |
| 7063 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7064 | } |
| 7065 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 7066 | var RllTestCases tcs := { |
| 7067 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7068 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7069 | } |
| 7070 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7071 | } |
| 7072 | |
| 7073 | /* altstep to receive a LAPDm frame matching the given template */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7074 | friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7075 | var L1ctlDlMessage dl; |
| 7076 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 7077 | var LapdmFrame lapdm; |
| 7078 | var octetstring l2 := dl.payload.data_ind.payload; |
| 7079 | if (dl.dl_info.link_id.c == SACCH) { |
| 7080 | /* remove L1 header */ |
| 7081 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 7082 | } |
| 7083 | if (ischosen(exp.ab)) { |
| 7084 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 7085 | } else if (ischosen(exp.b4)) { |
| 7086 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 7087 | } else if (ischosen(exp.bbis)) { |
| 7088 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 7089 | } |
| 7090 | log("Rx LAPDm ", lapdm); |
| 7091 | if (match(lapdm, exp)) { |
| 7092 | setverdict(pass); |
| 7093 | } else { |
| 7094 | repeat; |
| 7095 | } |
| 7096 | } |
| 7097 | [] L1CTL.receive { repeat; } |
| 7098 | } |
| 7099 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 7100 | timer T := t; |
| 7101 | T.start; |
| 7102 | alt { |
| 7103 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7104 | 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] | 7105 | } |
| 7106 | [] as_l1_exp_lapdm(exp); |
| 7107 | } |
| 7108 | } |
| 7109 | |
| 7110 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 7111 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7112 | timer T := 2.0; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7113 | /* send SABM from MS -> BTS */ |
| 7114 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 7115 | /* expect RLL EST IND on Abis */ |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7116 | T.start; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7117 | alt { |
| 7118 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 7119 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 7120 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7121 | 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] | 7122 | } |
| 7123 | [] RSL.receive { repeat; } |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7124 | [] T.timeout { |
| 7125 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RLL EST IND"); |
| 7126 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7127 | } |
| 7128 | /* expect UA from BTS -> MS */ |
| 7129 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 7130 | } |
| 7131 | |
| 7132 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 7133 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 7134 | var RllTestCase tc := g_pars.spec.rll; |
| 7135 | |
| 7136 | f_l1_tune(L1CTL); |
| 7137 | RSL.clear; |
| 7138 | |
| 7139 | /* activate the logical channel */ |
| 7140 | f_est_dchan(); |
| 7141 | L1CTL.clear; |
| 7142 | |
| 7143 | /* first establish the link-layer */ |
| 7144 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7145 | |
| 7146 | /* then send the DISC */ |
| 7147 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 7148 | /* ... and expect the REL IND on the RSL side */ |
| 7149 | alt { |
| 7150 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 7151 | setverdict(pass); |
| 7152 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7153 | /* We also expect to receive the measurements */ |
| 7154 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7155 | } |
| 7156 | |
| 7157 | /* release the channel */ |
| 7158 | f_rsl_chan_deact(); |
| 7159 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7160 | f_rslem_unregister(0, g_chan_nr); |
| 7161 | } |
| 7162 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 7163 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7164 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7165 | }; |
| 7166 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7167 | } |
| 7168 | |
| 7169 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 7170 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7171 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7172 | }; |
| 7173 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7174 | } |
| 7175 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 7176 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7177 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7178 | }; |
| 7179 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7180 | } |
| 7181 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 7182 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7183 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7184 | }; |
| 7185 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7186 | } |
| 7187 | |
| 7188 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 7189 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 7190 | var RllTestCase tc := g_pars.spec.rll; |
| 7191 | f_l1_tune(L1CTL); |
| 7192 | RSL.clear; |
| 7193 | |
| 7194 | /* activate the logical channel */ |
| 7195 | f_est_dchan(); |
| 7196 | L1CTL.clear; |
| 7197 | |
| 7198 | /* first establish the link-layer */ |
| 7199 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7200 | |
| 7201 | /* then send the REL REQ via RSL */ |
| 7202 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 7203 | /* ... and expect the DISC on the Um side */ |
| 7204 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 7205 | [] 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] | 7206 | /* FIXME: send a UA in resposne to the DISC */ |
| 7207 | } |
| 7208 | } |
| 7209 | |
| 7210 | /* release the channel */ |
| 7211 | f_rsl_chan_deact(); |
| 7212 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7213 | f_rslem_unregister(0, g_chan_nr); |
| 7214 | } |
| 7215 | testcase TC_rll_rel_req() runs on test_CT { |
| 7216 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7217 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
| 7218 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)), |
| 7219 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
| 7220 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7221 | }; |
| 7222 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 7223 | } |
| 7224 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7225 | /* 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] | 7226 | testcase TC_rll_data_req() runs on test_CT { |
| 7227 | } |
| 7228 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7229 | /* 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] | 7230 | testcase TC_rll_data_ind() runs on test_CT { |
| 7231 | } |
| 7232 | |
| 7233 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 7234 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 7235 | var RllTestCase tc := g_pars.spec.rll; |
| 7236 | |
| 7237 | f_l1_tune(L1CTL); |
| 7238 | RSL.clear; |
| 7239 | |
| 7240 | f_est_dchan(); |
| 7241 | L1CTL.clear; |
| 7242 | |
| 7243 | /* Send UNITDATA REQ on RSL side */ |
| 7244 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 7245 | /* Expect it to arrive on the other side */ |
| 7246 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7247 | 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] | 7248 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7249 | 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] | 7250 | } |
| 7251 | |
| 7252 | /* release the channel */ |
| 7253 | f_rsl_chan_deact(); |
| 7254 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7255 | f_rslem_unregister(0, g_chan_nr); |
| 7256 | } |
| 7257 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 7258 | var octetstring l3 := f_rnd_octstring(15); |
| 7259 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7260 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7261 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7262 | }; |
| 7263 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7264 | } |
| 7265 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 7266 | var octetstring l3 := f_rnd_octstring(19); |
| 7267 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7268 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7269 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7270 | }; |
| 7271 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7272 | } |
| 7273 | |
| 7274 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 7275 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 7276 | var RllTestCase tc := g_pars.spec.rll; |
| 7277 | |
| 7278 | f_l1_tune(L1CTL); |
| 7279 | RSL.clear; |
| 7280 | |
| 7281 | f_est_dchan(); |
| 7282 | L1CTL.clear; |
| 7283 | |
| 7284 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7285 | 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] | 7286 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 7287 | alt { |
| 7288 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7289 | setverdict(pass); |
| 7290 | } |
| 7291 | [] RSL.receive { repeat; } |
| 7292 | } |
| 7293 | |
| 7294 | /* release the channel */ |
| 7295 | f_rsl_chan_deact(); |
| 7296 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7297 | f_rslem_unregister(0, g_chan_nr); |
| 7298 | } |
| 7299 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 7300 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7301 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7302 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7303 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7304 | }; |
| 7305 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7306 | } |
| 7307 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 7308 | var octetstring l3 := f_rnd_octstring(18); |
| 7309 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7310 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7311 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7312 | }; |
| 7313 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7314 | } |
| 7315 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7316 | /*********************************************************************** |
| 7317 | * Encryption Related |
| 7318 | ***********************************************************************/ |
| 7319 | |
| 7320 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 7321 | 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] | 7322 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 7323 | if (link_id.c == SACCH) { |
| 7324 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7325 | } else { |
| 7326 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7327 | } |
| 7328 | } |
| 7329 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7330 | /* Expect (or not expect) other kinds of messages */ |
| 7331 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 7332 | [exp_any] RSL.receive { repeat; } |
| 7333 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7334 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7335 | } |
| 7336 | } |
| 7337 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7338 | /* 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] | 7339 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7340 | RslLinkId link_id, |
| 7341 | octetstring l3, |
| 7342 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7343 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7344 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7345 | timer T := 3.0; |
| 7346 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 7347 | T.start; |
| 7348 | /* Expect RLL UNITDATA IND on RSL side */ |
| 7349 | alt { |
| 7350 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 7351 | setverdict(pass); |
| 7352 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7353 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7354 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7355 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7356 | 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] | 7357 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7358 | } |
| 7359 | } |
| 7360 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7361 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 7362 | private function f_data_mo( |
| 7363 | RslLinkId link_id, |
| 7364 | boolean p, uint3_t nr, uint3_t ns, |
| 7365 | octetstring l3, |
| 7366 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7367 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7368 | ) runs on ConnHdlr { |
| 7369 | timer T := 3.0; |
| 7370 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 7371 | T.start; |
| 7372 | /* Expect RLL DATA IND on RSL side */ |
| 7373 | alt { |
| 7374 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 7375 | setverdict(pass); |
| 7376 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7377 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7378 | [] as_rsl_any_ind(exp_any); |
| 7379 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7381 | } |
| 7382 | } |
| 7383 | } |
| 7384 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7385 | /* 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] | 7386 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7387 | f_l1_tune(L1CTL); |
| 7388 | f_est_dchan(true); |
| 7389 | |
| 7390 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7391 | var L1ctlDlMessage dl; |
| 7392 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 7393 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7394 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7395 | |
| 7396 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7397 | f_unitdata_mt(link_id, l3); |
| 7398 | |
| 7399 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7400 | f_unitdata_mo(link_id, l3); |
| 7401 | |
| 7402 | /* release the channel */ |
| 7403 | f_rsl_chan_deact(); |
| 7404 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7405 | f_rslem_unregister(0, g_chan_nr); |
| 7406 | } |
| 7407 | testcase TC_chan_act_a51() runs on test_CT { |
| 7408 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7409 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7410 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7411 | } |
| 7412 | testcase TC_chan_act_a52() runs on test_CT { |
| 7413 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7414 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7415 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7416 | } |
| 7417 | testcase TC_chan_act_a53() runs on test_CT { |
| 7418 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7419 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7420 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7421 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7422 | testcase TC_chan_act_a54() runs on test_CT { |
| 7423 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7424 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7425 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7426 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7427 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7428 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 7429 | 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] | 7430 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7431 | f_l1_tune(L1CTL); |
| 7432 | f_est_dchan(true); |
| 7433 | |
| 7434 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7435 | var L1ctlDlMessage dl; |
| 7436 | |
| 7437 | var octetstring l3 := f_rnd_octstring(20); |
| 7438 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7439 | |
| 7440 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7441 | f_unitdata_mt(link_id, l3); |
| 7442 | |
| 7443 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7444 | f_unitdata_mo(link_id, l3); |
| 7445 | |
| 7446 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7447 | 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] | 7448 | |
| 7449 | /* modify key to break proper encryption */ |
| 7450 | g_pars.encr.key := f_rnd_octstring(8); |
| 7451 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 7452 | rsl.ies := rsl.ies & { ei }; |
| 7453 | RSL.send(rsl); |
| 7454 | |
| 7455 | timer T0 := 1.0; |
| 7456 | T0.start; |
| 7457 | /* Expect RSL MODIFY ACK */ |
| 7458 | alt { |
| 7459 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 7460 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 7461 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 7462 | } |
| 7463 | [] T0.timeout { |
| 7464 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 7465 | } |
| 7466 | } |
| 7467 | |
| 7468 | var octetstring l3msg := f_rnd_octstring(15); |
| 7469 | timer T1 := 3.0; |
| 7470 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 7471 | due to broken encryption */ |
| 7472 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 7473 | T1.start; |
| 7474 | alt { |
| 7475 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 7476 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 7477 | } |
| 7478 | [] T1.timeout { |
| 7479 | setverdict(pass); |
| 7480 | } |
| 7481 | } |
| 7482 | |
| 7483 | /* release the channel */ |
| 7484 | f_rsl_chan_deact(); |
| 7485 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7486 | f_rslem_unregister(0, g_chan_nr); |
| 7487 | } |
| 7488 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 7489 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7490 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7491 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 7492 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7493 | |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7494 | /* Verify RF RESource INDication messages (periodically sent over the RSL) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 7495 | private function f_TC_rsl_rf_resource_ind(template (present) RSL_ResourceInfo info) |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7496 | runs on test_CT { |
| 7497 | const IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
| 7498 | var ASP_RSL_Unitdata ud; |
| 7499 | timer T; |
| 7500 | |
| 7501 | /* Intave is 6 SACCH periods by default */ |
| 7502 | var float Tval := int2float(6 * 480) / 1000.0 + 0.5; |
| 7503 | |
| 7504 | T.start(Tval); |
| 7505 | alt { |
| 7506 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) { |
| 7507 | setverdict(pass); |
| 7508 | } |
| 7509 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud { |
| 7510 | setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl); |
| 7511 | } |
| 7512 | [] RSL_CCHAN.receive { repeat; } |
| 7513 | [] T.timeout { |
| 7514 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 7515 | "Timeout waiting for RF RESource INDication"); |
| 7516 | } |
| 7517 | } |
| 7518 | } |
| 7519 | testcase TC_rsl_rf_resource_ind() runs on test_CT { |
| 7520 | var RSL_ResourceInfo info := { }; |
| 7521 | |
| 7522 | f_init(trx_nr := 0); |
| 7523 | |
| 7524 | f_init_l1ctl(); |
| 7525 | f_l1_tune(L1CTL); |
| 7526 | |
| 7527 | /* g_AllChannels contains all logical channels */ |
| 7528 | for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) { |
| 7529 | var RslChannelNr chan_nr := g_AllChannels[i]; |
| 7530 | |
| 7531 | /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */ |
| 7532 | if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH) |
| 7533 | { continue; } |
| 7534 | |
| 7535 | info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) }; |
| 7536 | } |
| 7537 | |
| 7538 | /* Align to the first interference report */ |
| 7539 | f_TC_rsl_rf_resource_ind(?); |
| 7540 | |
| 7541 | /* Test 4 consecutive messages */ |
| 7542 | for (var integer i := 0; i < 4; i := i + 1) { |
| 7543 | f_TC_rsl_rf_resource_ind(info); |
| 7544 | } |
| 7545 | |
| 7546 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7547 | } |
| 7548 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7549 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7550 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7551 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 7552 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 7553 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 7554 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7555 | |
| 7556 | f_l1_tune(L1CTL); |
| 7557 | |
| 7558 | /* first establish a dedicated channel in the clear */ |
| 7559 | f_est_dchan(false); |
| 7560 | |
| 7561 | /* Establish ABM */ |
| 7562 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 7563 | |
| 7564 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 7565 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 7566 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 7567 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 7568 | |
| 7569 | /* configure L1 to apply ciphering */ |
| 7570 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 7571 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 7572 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7573 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 7574 | 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] | 7575 | |
| 7576 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 7577 | * and hence enable encryption also on the downlink */ |
| 7578 | |
| 7579 | /* expect bi-directional communication work in encrypted mode */ |
| 7580 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 7581 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 7582 | |
| 7583 | /* release the channel */ |
| 7584 | f_rsl_chan_deact(); |
| 7585 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7586 | f_rslem_unregister(0, g_chan_nr); |
| 7587 | } |
| 7588 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 7589 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7590 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7591 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7592 | } |
| 7593 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 7594 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7595 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7596 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7597 | } |
| 7598 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 7599 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7600 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7601 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7602 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7603 | testcase TC_encr_cmd_a54() runs on test_CT { |
| 7604 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7605 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7606 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7607 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7608 | |
| 7609 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 7610 | var LapdmFrame lf; |
| 7611 | var octetstring reenc; |
| 7612 | |
| 7613 | /* decode the LAPDm frame */ |
| 7614 | if (ischosen(exp_match.ab)) { |
| 7615 | lf.ab := dec_LapdmFrameAB(enc); |
| 7616 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7617 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7618 | } |
| 7619 | |
| 7620 | /* check if decoder result matches expectation */ |
| 7621 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7622 | 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] | 7623 | } else { |
| 7624 | log(name, ": matched"); |
| 7625 | setverdict(pass); |
| 7626 | } |
| 7627 | |
| 7628 | /* test if re-encoded frame equals original input */ |
| 7629 | reenc := enc_LapdmFrame(lf); |
| 7630 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7631 | 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] | 7632 | } else { |
| 7633 | setverdict(pass); |
| 7634 | } |
| 7635 | } |
| 7636 | |
| 7637 | testcase TC_lapdm_selftest() runs on test_CT { |
| 7638 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 7639 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 7640 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 7641 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 7642 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 7643 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 7644 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 7645 | } |
| 7646 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7647 | /*********************************************************************** |
| 7648 | * DTX Related (see GSM 05.08, section 8.3) |
| 7649 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7650 | 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] | 7651 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7652 | var GsmFrameNumber first_fn; |
| 7653 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7654 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7655 | 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] | 7656 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 7657 | 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] | 7658 | const integer frame_dtx_tchf_mod := 104; |
| 7659 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 7660 | * which operates in terms of blocks rather than frames. */ |
| 7661 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 7662 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7663 | timer T := 5.0; |
| 7664 | |
| 7665 | f_l1_tune(L1CTL); |
| 7666 | RSL.clear; |
| 7667 | L1CTL.clear; |
| 7668 | |
| 7669 | /* activate TCHF signalling channel */ |
| 7670 | f_est_dchan(false); |
| 7671 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7672 | /* A template for matching dummy LAPDm func=UA frames */ |
| 7673 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 7674 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 7675 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 7676 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7677 | T.start; |
| 7678 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7679 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7680 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7681 | |
| 7682 | if (is_first_frame) { |
| 7683 | is_first_frame := false; |
| 7684 | first_fn := dl.dl_info.frame_nr; |
| 7685 | } |
| 7686 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7687 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7688 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7689 | T.stop; |
| 7690 | f_rsl_chan_deact(); |
| 7691 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7692 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7693 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 7694 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7695 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7696 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7697 | setverdict(fail, "Not enough fill frames received: ", |
| 7698 | nfill_frames, " out of ", expected_fill_frames); |
| 7699 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7700 | } else { |
| 7701 | setverdict(pass); |
| 7702 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7703 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7704 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 7705 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 7706 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 7707 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 7708 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 7709 | 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] | 7710 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7711 | repeat; |
| 7712 | } |
| 7713 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7714 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 7715 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 7716 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7717 | f_rsl_chan_deact(); |
| 7718 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7719 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7720 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7721 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7722 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7723 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7724 | |
| 7725 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7726 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 7727 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7728 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 7729 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 7730 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7731 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 7732 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7733 | case else { |
| 7734 | /* This shall not happen, just to be sure */ |
| 7735 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7736 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7737 | } |
| 7738 | |
| 7739 | f_rsl_chan_deact(); |
| 7740 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7741 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7742 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7743 | setverdict(pass); |
| 7744 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7745 | setverdict(fail, "Not enough fill frames received: ", |
| 7746 | nfill_frames, " out of ", expected_fill_frames); |
| 7747 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7748 | } |
| 7749 | } else { |
| 7750 | repeat; |
| 7751 | } |
| 7752 | } |
| 7753 | } |
| 7754 | [] L1CTL.receive { repeat; } |
| 7755 | [] T.timeout { |
| 7756 | f_rsl_chan_deact(); |
| 7757 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7758 | 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] | 7759 | } |
| 7760 | } |
| 7761 | } |
| 7762 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7763 | 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] | 7764 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7765 | var ConnHdlr vc_conn; |
| 7766 | var ConnHdlrPars pars; |
| 7767 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7768 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7769 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7770 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7771 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7772 | if (dtxd) { |
| 7773 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 7774 | break; |
| 7775 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7776 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7777 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7778 | vc_conn.done; |
| 7779 | } |
| 7780 | } |
| 7781 | |
| 7782 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7783 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7784 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7785 | f_tch_sign_l2_fill_frame(false); |
| 7786 | } |
| 7787 | |
| 7788 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7789 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7790 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7791 | f_tch_sign_l2_fill_frame(true); |
| 7792 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7793 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7794 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7795 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7796 | } |
| 7797 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7798 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7799 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7800 | } |
| 7801 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7802 | |
| 7803 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7804 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7805 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7806 | runs on ConnHdlr return octetstring; |
| 7807 | |
| 7808 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7809 | runs on ConnHdlr { |
| 7810 | var L1ctlDlMessage l1_dl; |
| 7811 | var SacchL1Header l1h; |
| 7812 | var octetstring l2; |
| 7813 | |
| 7814 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7815 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7816 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7817 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7818 | |
| 7819 | /* Pass it to the user specified call-back function */ |
| 7820 | l2 := cb.apply(l1h, num_blocks); |
| 7821 | /* Send a Measurement Report generated by the call-back */ |
| 7822 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 7823 | l1_dl.dl_info.link_id, |
| 7824 | l1h, l2)); |
| 7825 | |
| 7826 | /* Shall we keep going? */ |
| 7827 | num_blocks := num_blocks - 1; |
| 7828 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 7829 | if (num_blocks > 0) { repeat; } |
| 7830 | } |
| 7831 | [] L1CTL.receive { repeat; } |
| 7832 | } |
| 7833 | |
| 7834 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 7835 | runs on ConnHdlr return octetstring { |
| 7836 | /* Command the L1 to apply received parameters */ |
| 7837 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 7838 | |
| 7839 | /* Dummy measurement report (the results are invalid) */ |
| 7840 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 7841 | } |
| 7842 | |
| 7843 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 7844 | runs on ConnHdlr return octetstring { |
| 7845 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 7846 | setverdict(fail, "Unexpected MS Power level change: ", |
| 7847 | g_pars.l1_pars.ms_power_level, " -> ", |
| 7848 | l1h.ms_power_lvl); |
| 7849 | } |
| 7850 | |
| 7851 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7852 | } |
| 7853 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7854 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7855 | runs on ConnHdlr return octetstring { |
| 7856 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7857 | if (num_blocks rem 2 == 0) { |
| 7858 | f_trxc_fake_rssi(-100); |
| 7859 | } else { |
| 7860 | f_trxc_fake_rssi(-50); |
| 7861 | } |
| 7862 | |
| 7863 | /* Make sure that MS power level remains constant */ |
| 7864 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7865 | } |
| 7866 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7867 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7868 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7869 | runs on ConnHdlr { |
| 7870 | var integer num_blocks := 8; |
| 7871 | timer T := int2float(num_blocks); |
| 7872 | |
| 7873 | f_l1_tune(L1CTL); |
| 7874 | RSL.clear; |
| 7875 | |
| 7876 | /* These IEs are needed for autonomous MS power control */ |
| 7877 | var template (value) RSL_IE_List ies := { |
| 7878 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7879 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7880 | }), |
| 7881 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7882 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7883 | }) |
| 7884 | }; |
| 7885 | |
| 7886 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7887 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7888 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 7889 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 7890 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 7891 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7892 | /* Establish a dedicated channel */ |
| 7893 | f_est_dchan(more_ies := valueof(ies)); |
| 7894 | |
| 7895 | L1CTL.clear; |
| 7896 | T.start; |
| 7897 | alt { |
| 7898 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 7899 | [] T.timeout { |
| 7900 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7901 | num_blocks, " were not handled"); |
| 7902 | } |
| 7903 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7904 | |
| 7905 | /* Release the channel */ |
| 7906 | f_rsl_chan_deact(); |
| 7907 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7908 | } |
| 7909 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 7910 | var ConnHdlr vc_conn; |
| 7911 | var ConnHdlrPars pars; |
| 7912 | |
| 7913 | f_init(); |
| 7914 | |
| 7915 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 7916 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 7917 | |
| 7918 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7919 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7920 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7921 | |
| 7922 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 7923 | pars, trxc_comp := true); |
| 7924 | vc_conn.done; |
| 7925 | } |
| 7926 | |
| 7927 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7928 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7929 | } |
| 7930 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7931 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 7932 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 7933 | runs on ConnHdlr { |
| 7934 | var integer num_blocks := 16; |
| 7935 | timer T := int2float(num_blocks); |
| 7936 | |
| 7937 | f_l1_tune(L1CTL); |
| 7938 | RSL.clear; |
| 7939 | |
| 7940 | /* These IEs are needed for autonomous MS power control */ |
| 7941 | var template (value) RSL_IE_List ies := { |
| 7942 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 7943 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 7944 | }), |
| 7945 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 7946 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 7947 | }) |
| 7948 | }; |
| 7949 | |
| 7950 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 7951 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 7952 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 7953 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 7954 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 7955 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7956 | /* Establish a dedicated channel */ |
| 7957 | f_est_dchan(more_ies := valueof(ies)); |
| 7958 | |
| 7959 | L1CTL.clear; |
| 7960 | T.start; |
| 7961 | alt { |
| 7962 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 7963 | [] T.timeout { |
| 7964 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 7965 | num_blocks, " were not handled"); |
| 7966 | } |
| 7967 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 7968 | |
| 7969 | /* Release the channel */ |
| 7970 | f_rsl_chan_deact(); |
| 7971 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7972 | } |
| 7973 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 7974 | var ConnHdlr vc_conn; |
| 7975 | var ConnHdlrPars pars; |
| 7976 | |
| 7977 | f_init(); |
| 7978 | |
| 7979 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 7980 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 7981 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 7982 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 7983 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 7984 | |
| 7985 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 7986 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7987 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 7988 | |
| 7989 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 7990 | pars, trxc_comp := true); |
| 7991 | vc_conn.done; |
| 7992 | } |
| 7993 | |
| 7994 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 7995 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7996 | } |
| 7997 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 7998 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 7999 | var template L1ctlDlMessage tr_bad_frame; |
| 8000 | var L1ctlDlMessage l1_dl; |
| 8001 | timer T := 8.0; |
| 8002 | |
| 8003 | f_l1_tune(L1CTL); |
| 8004 | RSL.clear; |
| 8005 | |
| 8006 | f_est_dchan(); |
| 8007 | |
| 8008 | /* There may be a few errors right after the channel activation */ |
| 8009 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 8010 | L1CTL.clear; |
| 8011 | |
| 8012 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 8013 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 8014 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 8015 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 8016 | tr_bad_frame.payload := ?; |
| 8017 | |
| 8018 | T.start; |
| 8019 | alt { |
| 8020 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 8021 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 8022 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 8023 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 8024 | } |
| 8025 | [] as_l1_sacch(); |
| 8026 | [] L1CTL.receive { repeat; } |
| 8027 | [] T.timeout { |
| 8028 | /* We're done, break the loop */ |
| 8029 | setverdict(pass); |
| 8030 | } |
| 8031 | } |
| 8032 | |
| 8033 | f_rsl_chan_deact(); |
| 8034 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8035 | } |
| 8036 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 8037 | var ConnHdlr vc_conn; |
| 8038 | var ConnHdlrPars pars; |
| 8039 | |
| 8040 | f_init(); |
| 8041 | |
| 8042 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8043 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8044 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8045 | vc_conn.done; |
| 8046 | } |
| 8047 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 8048 | var ConnHdlr vc_conn; |
| 8049 | var ConnHdlrPars pars; |
| 8050 | |
| 8051 | f_init(); |
| 8052 | |
| 8053 | /* TS5, TCH/H, V1 (HR codec) */ |
| 8054 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8055 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8056 | vc_conn.done; |
| 8057 | } |
| 8058 | |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8059 | /* Verify handling of Downlink and Uplink speech frames */ |
| 8060 | private function f_TC_speech_rtp(charstring id) runs on ConnHdlr { |
| 8061 | var L1ctlDlMessage l1_dl; |
| 8062 | var PDU_RTP rtp_pdu; |
| 8063 | var octetstring pl; |
| 8064 | timer Td, Tu; |
| 8065 | |
| 8066 | f_l1_tune(L1CTL); |
| 8067 | f_est_dchan(); |
| 8068 | |
| 8069 | /* Activate the RTP emulation */ |
| 8070 | pl := f_rnd_octstring(6); |
| 8071 | f_rtpem_activate(pl); |
| 8072 | |
| 8073 | /* Give the scheduler some time to fill up the buffers */ |
| 8074 | f_sleep(2.0); |
| 8075 | L1CTL.clear; |
| 8076 | RSL.clear; |
| 8077 | |
| 8078 | /* Make sure that Downlink frames are received at the UE */ |
| 8079 | Td.start(2.0); |
| 8080 | alt { |
| 8081 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl { |
| 8082 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8083 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8084 | l1_dl.payload.traffic_ind.data)); |
| 8085 | setverdict(pass); |
| 8086 | } |
| 8087 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8088 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8089 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8090 | "expected (", pl, ")"); |
| 8091 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8092 | } |
| 8093 | [] as_l1_sacch(); |
| 8094 | [] L1CTL.receive { repeat; } |
| 8095 | [] Td.timeout { |
| 8096 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8097 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8098 | } |
| 8099 | } |
| 8100 | |
| 8101 | /* Make sure that Uplink frames are received at the BTS */ |
| 8102 | RTPEM_DATA.clear; |
| 8103 | Tu.start(2.0); |
| 8104 | alt { |
| 8105 | [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu { |
| 8106 | if (rtp_pdu.data != pl) |
| 8107 | { repeat; } |
| 8108 | } |
| 8109 | [] RTPEM_DATA.receive { repeat; } |
| 8110 | [] Tu.timeout { |
| 8111 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8112 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8113 | } |
| 8114 | } |
| 8115 | |
| 8116 | f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE); |
| 8117 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8118 | f_rsl_chan_deact(); |
| 8119 | f_rslem_unregister(0, g_chan_nr); |
| 8120 | } |
| 8121 | testcase TC_speech_rtp_tchf() runs on test_CT { |
| 8122 | var ConnHdlr vc_conn; |
| 8123 | var ConnHdlrPars pars; |
| 8124 | |
| 8125 | f_init(); |
| 8126 | |
| 8127 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8128 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8129 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8130 | vc_conn.done; |
| 8131 | |
| 8132 | /* TS1, TCH/F, V2 (EFR codec) */ |
| 8133 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))); |
| 8134 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8135 | vc_conn.done; |
| 8136 | |
| 8137 | /* TODO: also test V3 (AMR codec) */ |
| 8138 | |
| 8139 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8140 | } |
| 8141 | testcase TC_speech_rtp_tchh() runs on test_CT { |
| 8142 | var ConnHdlr vc_conn; |
| 8143 | var ConnHdlrPars pars; |
| 8144 | |
| 8145 | f_init(); |
| 8146 | |
| 8147 | /* TS5, TCH/H0, V1 (HR codec) */ |
| 8148 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8149 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8150 | vc_conn.done; |
| 8151 | |
| 8152 | /* TODO: also test V3 (AMR codec) */ |
| 8153 | |
| 8154 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8155 | } |
| 8156 | |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8157 | private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr { |
| 8158 | var GsmFrameNumber fn; |
| 8159 | var ChannelDescription ch_desc; |
| 8160 | var integer ra := 23; |
| 8161 | |
| 8162 | f_l1_tune(L1CTL); |
| 8163 | RSL.clear; |
| 8164 | |
| 8165 | /* Send RACH request and wait for ChanReq */ |
| 8166 | fn := f_rach_req_wait_chan_rqd(ra); |
| 8167 | |
| 8168 | /* The BSC already sends the Immediate Assignment, before the channel is active. |
| 8169 | * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM |
| 8170 | * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the |
| 8171 | * IMM ASS. So move the IMM ASS even before the Chan Activ.) */ |
| 8172 | if (g_pars.fhp.enabled) { |
| 8173 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8174 | } else { |
| 8175 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8176 | } |
| 8177 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8178 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8179 | |
| 8180 | /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC |
| 8181 | * requests Chan Activ, to make sure the RR IMM ASS is held back. */ |
| 8182 | var L1ctlDlMessage dl; |
| 8183 | var GsmRrMessage rr; |
| 8184 | |
| 8185 | var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn); |
| 8186 | rr_imm_ass.payload.imm_ass.ded_or_tbf := ?; |
| 8187 | rr_imm_ass.payload.imm_ass.pkt_chan_desc := *; |
| 8188 | rr_imm_ass.payload.imm_ass.chan_desc := *; |
| 8189 | |
| 8190 | timer T := 1.0; |
| 8191 | T.start; |
| 8192 | alt { |
| 8193 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 8194 | rr := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 8195 | if (match(rr, rr_imm_ass)) { |
| 8196 | setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately"); |
| 8197 | mtc.stop; |
| 8198 | } else { |
| 8199 | repeat; |
| 8200 | } |
| 8201 | } |
| 8202 | [] L1CTL.receive { repeat; } |
| 8203 | [] T.timeout; |
| 8204 | } |
| 8205 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA)); |
| 8206 | RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)); |
| 8207 | |
| 8208 | /* Now expect the IMM ASS on Um */ |
| 8209 | f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8210 | setverdict(pass); |
| 8211 | |
| 8212 | /* Release the channel */ |
| 8213 | f_rsl_chan_deact(); |
| 8214 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8215 | } |
| 8216 | |
| 8217 | testcase TC_early_immediate_assignment() runs on test_CT { |
| 8218 | var ConnHdlr vc_conn; |
| 8219 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 8220 | f_init(); |
| 8221 | vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars); |
| 8222 | vc_conn.done; |
| 8223 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8224 | } |
| 8225 | |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8226 | private function f_TC_est_dchan(charstring id) runs on ConnHdlr { |
| 8227 | var integer ra := oct2int(f_rnd_ra_cs()); |
| 8228 | var ChannelDescription ch_desc; |
| 8229 | |
| 8230 | /* Tune the MS to BCCH */ |
| 8231 | f_l1_tune(L1CTL); |
| 8232 | |
| 8233 | /* Send RACH request and wait for ChanReq */ |
| 8234 | var GsmFrameNumber fn := f_rach_req_wait_chan_rqd(ra); |
| 8235 | |
| 8236 | /* Activate channel on the BTS side */ |
| 8237 | f_rsl_chan_act(g_pars.chan_mode); |
| 8238 | |
| 8239 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 8240 | if (g_pars.fhp.enabled) { |
| 8241 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8242 | } else { |
| 8243 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8244 | } |
| 8245 | |
| 8246 | /* Send IMM.ASS via CCHAN */ |
| 8247 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8248 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8249 | |
| 8250 | /* Receive IMM.ASS on the MS side */ |
| 8251 | var ImmediateAssignment imm_ass := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8252 | |
| 8253 | /* Match the Channel Description IE in received IMM.ASS */ |
| 8254 | if (not match(imm_ass.chan_desc, ch_desc)) { |
| 8255 | setverdict(fail, "Channel Description IE does not match"); |
| 8256 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8257 | } |
| 8258 | |
| 8259 | /* Tune the MS to a dedicated channel indicated in the IMM.ASS */ |
| 8260 | f_L1CTL_DM_EST_REQ_IA(L1CTL, imm_ass, g_pars.fhp.ma); |
| 8261 | |
| 8262 | /* Expect SACCH frames on Downlink */ |
| 8263 | L1CTL.clear; |
| 8264 | f_exp_sacch(true); |
| 8265 | |
| 8266 | /* We're done, deactivate and release */ |
| 8267 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8268 | f_rsl_chan_deact(); |
| 8269 | } |
| 8270 | testcase TC_est_dchan() runs on test_CT { |
| 8271 | var ConnHdlr vc_conn; |
| 8272 | var ConnHdlrPars pars; |
| 8273 | |
| 8274 | f_init(); |
| 8275 | |
| 8276 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 8277 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 8278 | vc_conn := f_start_handler(refers(f_TC_est_dchan), pars); |
| 8279 | vc_conn.done; |
| 8280 | } |
| 8281 | |
| 8282 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8283 | } |
| 8284 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8285 | private type record TopTestCase { |
| 8286 | RSL_IE_BS_Power bs_power, |
| 8287 | RSL_IE_OSMO_TopAcchCap top_cap, |
| 8288 | record of TopTestStep steps |
| 8289 | }; |
| 8290 | private type record TopTestStep { |
| 8291 | MeasurementResults meas_res optional, |
| 8292 | GsmRxLev overpower_sacch, |
| 8293 | GsmRxLev overpower_facch |
| 8294 | }; |
| 8295 | |
| 8296 | private function f_rxlev_match(template (present) RslLinkId link_id, |
| 8297 | template (present) GsmRxLev rxlev) |
| 8298 | runs on ConnHdlr { |
| 8299 | var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id); |
| 8300 | if (not match(dl.dl_info.rx_level, rxlev)) { |
| 8301 | setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level, |
| 8302 | " does not match expected RxLev := ", rxlev); |
| 8303 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8304 | } |
| 8305 | } |
| 8306 | |
| 8307 | private function f_TC_acch_overpower(charstring id) runs on ConnHdlr { |
| 8308 | var TopTestCase tc := g_pars.spec.top; |
| 8309 | var GsmRxLev rxlev_dcch; |
| 8310 | var L1ctlDlMessage dl; |
| 8311 | |
| 8312 | /* Wait for Pau ramping to complete */ |
| 8313 | f_sleep(6.0); |
| 8314 | |
| 8315 | f_l1_tune(L1CTL); |
| 8316 | L1CTL.clear; |
| 8317 | RSL.clear; |
| 8318 | |
| 8319 | /* Measure RxLev(BCCH), calculate RxLev(DCCH) */ |
| 8320 | dl := f_L1CTL_rx_data(L1CTL, t_RslChanNr_BCCH(0)); |
| 8321 | rxlev_dcch := dl.dl_info.rx_level - (tc.bs_power.power_level * 2); |
| 8322 | |
| 8323 | log("RxLev(BCCH) := ", dl.dl_info.rx_level); |
| 8324 | log("Expected RxLev(DCCH) := ", rxlev_dcch); |
| 8325 | |
| 8326 | /* Additional IEs for the CHANnel ACTIVation message */ |
| 8327 | var template (value) RSL_IE_List ies := { |
| 8328 | /* Employ BS power control in static mode */ |
| 8329 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8330 | bs_power := tc.bs_power |
| 8331 | }), |
| 8332 | /* Indicate the given Temporary Overpower capability */ |
| 8333 | t_RSL_IE(RSL_IE_OSMO_TOP_ACCH_CAP, RSL_IE_Body:{ |
| 8334 | top_acch_cap := tc.top_cap |
| 8335 | }) |
| 8336 | }; |
| 8337 | |
| 8338 | /* Establish a dedicated channel */ |
| 8339 | f_est_dchan(more_ies := valueof(ies)); |
| 8340 | |
| 8341 | /* Give it some time to stabilize */ |
| 8342 | f_sleep(0.480 * 2.0); |
| 8343 | L1CTL.clear; |
| 8344 | RSL.clear; |
| 8345 | |
| 8346 | for (var integer i := 0; i < lengthof(tc.steps); i := i + 1) { |
| 8347 | var TopTestStep step := tc.steps[i]; |
| 8348 | var GsmRxLev rxlev_facch := rxlev_dcch + step.overpower_facch; |
| 8349 | var GsmRxLev rxlev_sacch := rxlev_dcch + step.overpower_sacch; |
| 8350 | |
| 8351 | log("Executing step[", i, "] := ", step); |
| 8352 | |
| 8353 | /* Send RR Measurement Report (if present) */ |
| 8354 | if (ispresent(step.meas_res)) { |
| 8355 | f_transceive_meas_rep(step.meas_res); |
| 8356 | f_sleep(0.480 * 2.0); |
| 8357 | L1CTL.clear; |
| 8358 | } |
| 8359 | |
| 8360 | /* Check RxLev on both FACCH and SACCH */ |
| 8361 | f_rxlev_match(tr_RslLinkID_DCCH(?), rxlev_facch); |
| 8362 | f_rxlev_match(tr_RslLinkID_SACCH(?), rxlev_sacch); |
| 8363 | |
| 8364 | setverdict(pass); |
| 8365 | } |
| 8366 | } |
| 8367 | testcase TC_acch_overpower_rxqual_thresh() runs on test_CT { |
| 8368 | var ConnHdlrPars pars; |
| 8369 | var ConnHdlr vc_conn; |
| 8370 | |
| 8371 | f_init(); |
| 8372 | |
| 8373 | /* Verify lower and upper RxQual thresholds */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8374 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8375 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8376 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8377 | steps := { |
| 8378 | /* Channel established, no overpower */ |
| 8379 | { meas_res := omit, |
| 8380 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8381 | |
| 8382 | /* Worst possible RxQual value, overpower of 4dB */ |
| 8383 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8384 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8385 | /* Worst possible RxQual value, disabling overpower */ |
| 8386 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8387 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8388 | |
| 8389 | /* Lower threshold not reached, no overpower */ |
| 8390 | { meas_res := ts_MeasurementResults(rxq_f := 1), |
| 8391 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8392 | /* Lower threshold not reached, no overpower */ |
| 8393 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8394 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8395 | /* Lower threshold reached, overpower of 4dB */ |
| 8396 | { meas_res := ts_MeasurementResults(rxq_f := 4), |
| 8397 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8398 | /* Upper threshold not reached, keeping overpower */ |
| 8399 | { meas_res := ts_MeasurementResults(rxq_f := 3), |
| 8400 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8401 | /* Upper threshold reached, disabling overpower */ |
| 8402 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8403 | overpower_sacch := 0, overpower_facch := 0 } |
| 8404 | } |
| 8405 | }; |
| 8406 | |
| 8407 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8408 | spec := { top := top }, trx_nr := 1)); |
| 8409 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8410 | vc_conn.done; |
| 8411 | |
| 8412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8413 | } |
| 8414 | testcase TC_acch_overpower_rxqual_thresh_dtx() runs on test_CT { |
| 8415 | var ConnHdlrPars pars; |
| 8416 | var ConnHdlr vc_conn; |
| 8417 | |
| 8418 | f_init(); |
| 8419 | |
| 8420 | /* Verify handling of FULL and SUB values */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8421 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8422 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8423 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8424 | steps := { |
| 8425 | /* Channel established, no overpower */ |
| 8426 | { meas_res := omit, |
| 8427 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8428 | |
| 8429 | /* Invalid measurement results, no overpower */ |
| 8430 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8431 | rxq_s := 7, |
| 8432 | valid := false), |
| 8433 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8434 | |
| 8435 | /* DTXu was in use, no overpower */ |
| 8436 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8437 | rxq_s := 0, |
| 8438 | dtx_used := true), |
| 8439 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8440 | /* DTXu was in use, overpower of 4 dB */ |
| 8441 | { meas_res := ts_MeasurementResults(rxq_f := 0, |
| 8442 | rxq_s := 7, |
| 8443 | dtx_used := true), |
| 8444 | overpower_sacch := 4, overpower_facch := 4 } |
| 8445 | } |
| 8446 | }; |
| 8447 | |
| 8448 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8449 | spec := { top := top }, trx_nr := 1)); |
| 8450 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8451 | vc_conn.done; |
| 8452 | |
| 8453 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8454 | } |
| 8455 | testcase TC_acch_overpower_always_on_facch() runs on test_CT { |
| 8456 | var ConnHdlrPars pars; |
| 8457 | var ConnHdlr vc_conn; |
| 8458 | |
| 8459 | f_init(); |
| 8460 | |
| 8461 | /* Overpower is always on, SACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8462 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8463 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8464 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8465 | rxqual := 0, /* always on */ |
| 8466 | sacch_enable := false), |
| 8467 | steps := { |
| 8468 | /* Channel established, FACCH overpower */ |
| 8469 | { meas_res := omit, |
| 8470 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8471 | /* MS indicates good RxQual, no difference */ |
| 8472 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8473 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8474 | /* MS indicates bad RxQual, no difference */ |
| 8475 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8476 | overpower_sacch := 0, overpower_facch := 4 } |
| 8477 | } |
| 8478 | }; |
| 8479 | |
| 8480 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8481 | spec := { top := top }, trx_nr := 1)); |
| 8482 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8483 | vc_conn.done; |
| 8484 | |
| 8485 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8486 | } |
| 8487 | testcase TC_acch_overpower_always_on_sacch() runs on test_CT { |
| 8488 | var ConnHdlrPars pars; |
| 8489 | var ConnHdlr vc_conn; |
| 8490 | |
| 8491 | f_init(); |
| 8492 | |
| 8493 | /* Overpower is always on, FACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8494 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8495 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8496 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8497 | rxqual := 0, /* always on */ |
| 8498 | facch_enable := false), |
| 8499 | steps := { |
| 8500 | /* Channel established, SACCH overpower */ |
| 8501 | { meas_res := omit, |
| 8502 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8503 | /* MS indicates good RxQual, no difference */ |
| 8504 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8505 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8506 | /* MS indicates bad RxQual, no difference */ |
| 8507 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8508 | overpower_sacch := 4, overpower_facch := 0 } |
| 8509 | } |
| 8510 | }; |
| 8511 | |
| 8512 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8513 | spec := { top := top }, trx_nr := 1)); |
| 8514 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8515 | vc_conn.done; |
| 8516 | |
| 8517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8518 | } |
| 8519 | testcase TC_acch_overpower_limit() runs on test_CT { |
| 8520 | var ConnHdlrPars pars; |
| 8521 | var ConnHdlr vc_conn; |
| 8522 | |
| 8523 | f_init(); |
| 8524 | |
| 8525 | /* Overpower higher than current power reduction level (2dB) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8526 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8527 | bs_power := ts_RSL_IE_BS_Power(1), /* 1 x 2dB = 2dB */ |
| 8528 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8529 | rxqual := 0 /* always on */), |
| 8530 | steps := { |
| 8531 | /* Channel established, ACCH overpower of 2dB */ |
| 8532 | { meas_res := omit, |
| 8533 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8534 | /* MS indicates good RxQual, no difference */ |
| 8535 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8536 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8537 | /* MS indicates bad RxQual, no difference */ |
| 8538 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8539 | overpower_sacch := 2, overpower_facch := 2 } |
| 8540 | } |
| 8541 | }; |
| 8542 | |
| 8543 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8544 | spec := { top := top }, trx_nr := 1)); |
| 8545 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8546 | vc_conn.done; |
| 8547 | |
| 8548 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8549 | } |
| 8550 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8551 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 8552 | /* protocol error as per 44.006 */ |
| 8553 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 8554 | /* repetition of SABM or DISC N200 times without ACK */ |
| 8555 | /* receptiom of SABM in multi-frame established state */ |
| 8556 | |
| 8557 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8558 | /* TODO Areas: |
| 8559 | |
| 8560 | * channel activation |
| 8561 | ** with BS_Power / MS_Power, bypassing power control loop |
| 8562 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8563 | ** with timing advance from initial activation on |
| 8564 | * mode modify |
| 8565 | ** encryption |
| 8566 | ** multirate |
| 8567 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8568 | ** unsupported algorithm |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8569 | * BS Power Control |
| 8570 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8571 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8572 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8573 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8574 | ** DATA_IND from BTS->PCU |
| 8575 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8576 | |
| 8577 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8578 | |
| 8579 | control { |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8580 | execute( TC_est_dchan() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8581 | execute( TC_chan_act_stress() ); |
| 8582 | execute( TC_chan_act_react() ); |
| 8583 | execute( TC_chan_deact_not_active() ); |
| 8584 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 8585 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 8586 | execute( TC_sacch_filling() ); |
| 8587 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 8588 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 8589 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 8590 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 8591 | execute( TC_sacch_chan_act_ho_async() ); |
| 8592 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8593 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 8594 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8595 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 8596 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 8597 | execute( TC_ho_rach() ); |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 8598 | execute( TC_ho_physical_info() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 8599 | execute( TC_rach_load_idle_thresh0() ); |
| 8600 | execute( TC_rach_load_idle_below_thresh() ); |
| 8601 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8602 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8603 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8604 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8605 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 8606 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8607 | execute( TC_meas_res_sign_tchf() ); |
| 8608 | execute( TC_meas_res_sign_tchh() ); |
| 8609 | execute( TC_meas_res_sign_sdcch4() ); |
| 8610 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 8611 | execute( TC_meas_res_sign_tchh_toa256() ); |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 8612 | execute( TC_meas_res_speech_tchf_sapi3() ); |
| 8613 | execute( TC_meas_res_speech_tchh_sapi3() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 8614 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 8615 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 8616 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 8617 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 8618 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 8619 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 8620 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 8621 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 8622 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 8623 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 8624 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 8625 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 8626 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 8627 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 8628 | execute( TC_rsl_modify_encr() ); |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 8629 | execute( TC_rsl_rf_resource_ind() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8630 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8631 | execute( TC_paging_imsi_80percent() ); |
| 8632 | execute( TC_paging_tmsi_80percent() ); |
| 8633 | execute( TC_paging_imsi_200percent() ); |
| 8634 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 8635 | execute( TC_rsl_protocol_error() ); |
| 8636 | execute( TC_rsl_mand_ie_error() ); |
| 8637 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8638 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 8639 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8640 | execute( TC_si_sched_2bis() ); |
| 8641 | execute( TC_si_sched_2ter() ); |
| 8642 | execute( TC_si_sched_2ter_2bis() ); |
| 8643 | execute( TC_si_sched_2quater() ); |
| 8644 | execute( TC_si_sched_13() ); |
| 8645 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 8646 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 8647 | execute( TC_ipa_crcx_twice_not_active() ); |
| 8648 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 8649 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 8650 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 8651 | execute( TC_ipa_crcx_ack_addr() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8652 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8653 | if (mp_pcu_socket != "") { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 8654 | execute( TC_paging_imsi_200percent_with_ps() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8655 | execute( TC_pcu_act_req() ); |
| 8656 | execute( TC_pcu_act_req_wrong_ts() ); |
| 8657 | execute( TC_pcu_act_req_wrong_bts() ); |
| 8658 | execute( TC_pcu_act_req_wrong_trx() ); |
| 8659 | execute( TC_pcu_deact_req() ); |
| 8660 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 8661 | execute( TC_pcu_ver_si1() ); |
| 8662 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8663 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8664 | if (mp_l1_supports_gprs) { |
| 8665 | execute( TC_pcu_data_req_pdtch() ); |
| 8666 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 8667 | execute( TC_pcu_data_req_wrong_bts() ); |
| 8668 | execute( TC_pcu_data_req_wrong_trx() ); |
| 8669 | execute( TC_pcu_data_req_wrong_ts() ); |
| 8670 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8671 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 8672 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8673 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 8674 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8675 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 8676 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 8677 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 8678 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8679 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 8680 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 8681 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 8682 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 8683 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 8684 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 8685 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8686 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8687 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8688 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8689 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8690 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8691 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 8692 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 8693 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 8694 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 8695 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 8696 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 8697 | execute( TC_pcu_info_ind_fh_params() ); |
| 8698 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 8699 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 8700 | execute( TC_pcu_socket_two_nsvc() ); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 8701 | execute( TC_pcu_interf_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8702 | } else { |
| 8703 | log("PCU socket path not available, skipping PCU tests"); |
| 8704 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8705 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8706 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8707 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 8708 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 8709 | execute( TC_dyn_osmo_pdch_sdcch8_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 8710 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 8711 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8712 | |
| 8713 | execute( TC_rll_est_ind() ); |
| 8714 | execute( TC_rll_est_req_DCCH_3() ); |
| 8715 | execute( TC_rll_est_req_ACCH_3() ); |
| 8716 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 8717 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 8718 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 8719 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 8720 | execute( TC_rll_rel_req() ); |
| 8721 | execute( TC_rll_unit_data_req_DCCH() ); |
| 8722 | execute( TC_rll_unit_data_req_ACCH() ); |
| 8723 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 8724 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8725 | |
| 8726 | execute( TC_chan_act_a51() ); |
| 8727 | execute( TC_chan_act_a52() ); |
| 8728 | execute( TC_chan_act_a53() ); |
| 8729 | execute( TC_encr_cmd_a51() ); |
| 8730 | execute( TC_encr_cmd_a52() ); |
| 8731 | execute( TC_encr_cmd_a53() ); |
| 8732 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 8733 | execute( TC_err_rep_wrong_mdisc() ); |
| 8734 | execute( TC_err_rep_wrong_msg_type() ); |
| 8735 | execute( TC_err_rep_wrong_sequence() ); |
| 8736 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8737 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 8738 | |
| 8739 | execute( TC_tch_sign_l2_fill_frame() ); |
| 8740 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 8741 | |
| 8742 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 8743 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8744 | |
| 8745 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8746 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8747 | |
| 8748 | execute( TC_speech_no_rtp_tchf() ); |
| 8749 | execute( TC_speech_no_rtp_tchh() ); |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8750 | execute( TC_speech_rtp_tchf() ); |
| 8751 | execute( TC_speech_rtp_tchh() ); |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8752 | |
| 8753 | execute( TC_early_immediate_assignment() ); |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 8754 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8755 | execute( TC_acch_overpower_rxqual_thresh() ); |
| 8756 | execute( TC_acch_overpower_rxqual_thresh_dtx() ); |
| 8757 | execute( TC_acch_overpower_always_on_facch() ); |
| 8758 | execute( TC_acch_overpower_always_on_sacch() ); |
| 8759 | execute( TC_acch_overpower_limit() ); |
| 8760 | |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 8761 | /* BEWARE: these test cases can potentially break the IUT or cause |
| 8762 | * weird/unexpected behavior. Ensure that they are executed last. */ |
| 8763 | execute( TC_dyn_osmo_pdch_tchh_race_act() ); |
| 8764 | execute( TC_dyn_osmo_pdch_sdcch8_race_act() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8765 | } |
| 8766 | |
| 8767 | |
| 8768 | } |