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 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 50 | import from AMR_Types all; |
| 51 | |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 52 | import from OSMUX_Types all; |
| 53 | import from OSMUX_CodecPort all; |
| 54 | import from OSMUX_CodecPort_CtrlFunct all; |
| 55 | import from OSMUX_Emulation all; |
| 56 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 57 | import from IPL4asp_Types all; |
| 58 | import from TRXC_Types all; |
| 59 | import from TRXC_CodecPort all; |
| 60 | import from TRXC_CodecPort_CtrlFunct all; |
| 61 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 62 | import from PCUIF_Types all; |
| 63 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 64 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 65 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 66 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 67 | import from MobileL3_RRM_Types all; |
| 68 | import from MobileL3_Types all; |
| 69 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 70 | import from L3_Common all; |
| 71 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 72 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 73 | import from Osmocom_VTY_Functions all; |
| 74 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 75 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 76 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 77 | friend module BTS_Tests_SMSCB; |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 78 | friend module BTS_Tests_VAMOS; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 79 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 80 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 81 | friend module BTS_Tests_perf; |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 82 | friend module BTS_Tests_OML; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 83 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 84 | /* The tests assume a BTS with the following timeslot configuration: |
| 85 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 86 | * TS1 : TCH/F |
| 87 | * TS2 : TCH/F |
| 88 | * TS3 : TCH/F_PDCH (IPA Style) |
| 89 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 90 | * TS5 : TCH/H |
| 91 | * TS6 : SDCCH/8 |
| 92 | * TS7 : PDCH |
| 93 | */ |
| 94 | |
| 95 | modulepar { |
| 96 | charstring mp_rsl_ip := "127.0.0.2"; |
| 97 | integer mp_rsl_port := 3003; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 98 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 99 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 100 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 101 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 102 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 103 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 104 | integer mp_bsc_ctrl_port := 4249; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 105 | charstring mp_rtpem_bind_ip := "127.0.0.1"; |
| 106 | integer mp_rtpem_bind_port := 6766; |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 107 | charstring mp_osmuxem_bind_ip := "127.0.0.1"; |
| 108 | integer mp_osmuxem_bind_port := 1984; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 109 | integer mp_tolerance_rxqual := 1; |
| 110 | integer mp_tolerance_rxlev := 3; |
| 111 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 112 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 113 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 114 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 115 | integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */ |
| 116 | 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] | 117 | integer mp_ms_actual_ta_exp := 0; |
| 118 | integer mp_timing_offset_256syms_exp := 512; |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 119 | integer mp_uplink_power_target := -75; |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 120 | integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */ |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 121 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 122 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 123 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 124 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 125 | boolean mp_l1_supports_gprs := false; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 126 | /* how many transceivers do we expect to connect */ |
| 127 | integer mp_transceiver_num := 1; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 128 | /* frequency hopping status */ |
| 129 | boolean mp_freq_hop_enabled := false; |
| 130 | /* frequency hopping parameters */ |
| 131 | FreqHopConfig mp_fh_config; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 132 | /* configuration for each individual transceiver */ |
| 133 | TrxPars mp_trx_pars; /* see BTS_Tests.default */ |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 134 | /* default Training Sequence Code */ |
| 135 | GsmTsc mp_tsc_def := 7; |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 136 | /* Default interference boundaries in osmo-bsc (in dBm): |
| 137 | * 0(-85) X1(-91) X2(-97) X3(-103) X4(-109) X5(-115) |
| 138 | * Default interference level reported by fake_trx.py: |
| 139 | * 0: -109 >= -85 dBm (no) |
| 140 | * X1: -109 >= -91 dBm (no) |
| 141 | * X2: -109 >= -97 dBm (no) |
| 142 | * X3: -109 >= -103 dBm (no) |
| 143 | * X4: -109 >= -109 dBm (yes) |
| 144 | * X5: -109 >= -115 dBm (no) |
| 145 | * So all channels should be in band 4. */ |
| 146 | uint3_t mp_interf_band := 4; |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 147 | /* T3105 timer (see 3GPP TS 44.018, section 11.1.2) */ |
| 148 | integer mp_ho_t3105_ms := 100; |
| 149 | /* Ny1 counter (see 3GPP TS 44.018, section 11.1.3) */ |
| 150 | integer mp_ho_ny1 := 10; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 153 | type record of RslChannelNr ChannelNrs; |
| 154 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 155 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 156 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 157 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 158 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 159 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 160 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 161 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 162 | |
| 163 | /* L1CTL port (for classic tests) */ |
| 164 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 165 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 166 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 167 | port TRXC_CODEC_PT BTS_TRXC; |
| 168 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 169 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 170 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 171 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 172 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 173 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 174 | /* PCU Interface of BTS */ |
| 175 | port PCUIF_CODEC_PT PCU; |
| 176 | var integer g_pcu_conn_id; |
| 177 | /* Last PCU INFO IND we received */ |
| 178 | var PCUIF_Message g_pcu_last_info; |
| 179 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 180 | /* SI configuration */ |
| 181 | var SystemInformationConfig si_cfg := { |
| 182 | bcch_extended := false, |
| 183 | si1_present := false, |
| 184 | si2bis_present := false, |
| 185 | si2ter_present := false, |
| 186 | si2quater_present := false, |
| 187 | si7_present := false, |
| 188 | si8_present := false, |
| 189 | si9_present := false, |
| 190 | si13_present := false, |
| 191 | si13alt_present := false, |
| 192 | si15_present := false, |
| 193 | si16_present := false, |
| 194 | si17_present := false, |
| 195 | si2n_present := false, |
| 196 | si21_present := false, |
| 197 | si22_present := false |
| 198 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 199 | |
| 200 | /* all logical channels available on the BTS */ |
| 201 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 202 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 206 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 207 | port L1CTL_PT L1CTL; |
| 208 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 209 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 210 | port TRXC_CODEC_PT BTS_TRXC; |
| 211 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 212 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 213 | /* port to be initialized optionally to access BSC VTY */ |
| 214 | port TELNETasp_PT BSCVTY; |
| 215 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 216 | timer g_Tguard; |
| 217 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 218 | |
| 219 | var ConnHdlrPars g_pars; |
| 220 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 221 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 222 | |
| 223 | /* PCU Interface of BTS */ |
| 224 | port PCUIF_CODEC_PT PCU; |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 225 | |
| 226 | var RTP_Emulation_CT vc_RTPEM; |
| 227 | port RTPEM_CTRL_PT RTPEM_CTRL; |
| 228 | port RTPEM_DATA_PT RTPEM_DATA; |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 229 | var OSMUX_Emulation_CT vc_OsmuxEM; |
| 230 | port OsmuxEM_CTRL_PT OsmuxEM_CTRL; |
| 231 | port OsmuxEM_DATA_PT OsmuxEM_DATA; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 232 | } |
| 233 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 234 | private function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 235 | var bitstring trx_mask := '00000000'B; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 236 | var bitstring rfind_mask := '00000000'B; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 237 | var integer trx_count := 0; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 238 | var integer rfind_count := 0; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 239 | var RSLEm_Event ev; |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 240 | var ASP_RSL_Unitdata rx_ud; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 241 | timer T; |
| 242 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 243 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 244 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 245 | |
| 246 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 247 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 248 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 249 | |
| 250 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 251 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 252 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 253 | /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here. |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 254 | * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 255 | T.start(mp_ipa_up_timeout); |
| 256 | alt { |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 257 | /* These events are sent by the RSL_Emulation_CT */ |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 258 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev { |
| 259 | /* Make sure that all transceivers use unique stream ID */ |
| 260 | if (trx_mask[enum2int(ev.sid)] == '1'B) { |
| 261 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 262 | log2str("Duplicate RSL stream ID (", ev.sid, ")")); |
| 263 | } |
Vadim Yanitskiy | fc631d1 | 2020-06-02 23:48:49 +0700 | [diff] [blame] | 264 | |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 265 | trx_mask[enum2int(ev.sid)] := '1'B; |
| 266 | trx_count := trx_count + 1; |
| 267 | |
| 268 | log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected"); |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 269 | repeat; |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 270 | } |
Pau Espin Pedrol | 9a053c0 | 2020-10-16 13:52:28 +0200 | [diff] [blame] | 271 | /* This message (RF RESource INDication) is sent by the IUT itself */ |
| 272 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud { |
| 273 | if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) { |
| 274 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 275 | log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")")); |
| 276 | } |
| 277 | if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) { |
| 278 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 279 | log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")")); |
| 280 | } |
| 281 | |
| 282 | rfind_mask[enum2int(rx_ud.streamId)] := '1'B; |
| 283 | rfind_count := rfind_count + 1; |
| 284 | log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received"); |
| 285 | if (rfind_count < mp_transceiver_num) { repeat; } |
| 286 | } |
Vadim Yanitskiy | 89db3e0 | 2020-06-22 17:49:39 +0700 | [diff] [blame] | 287 | /* osmo-bts may send us CCCH LOAD INDication or whatever else */ |
| 288 | [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; } |
| 289 | [] T.timeout { |
| 290 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 291 | "Timeout waiting for RSL bring up"); |
| 292 | } |
| 293 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 294 | } |
| 295 | |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 296 | friend type record length(1 .. 256) of TrxParsItem TrxPars; |
| 297 | friend type record TrxParsItem { |
| 298 | GsmArfcn arfcn, |
| 299 | TrxTsPars ts |
| 300 | }; |
| 301 | |
| 302 | friend type record length(8) of TrxTsParsItem TrxTsPars; |
| 303 | friend type record TrxTsParsItem { |
| 304 | PchanConfig config |
| 305 | }; |
| 306 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 307 | friend type record FreqHopPars { |
| 308 | /* Whether frequency hopping is in use */ |
| 309 | boolean enabled, |
| 310 | /* Mobile Allocation Index Offset / Hopping Sequence Number */ |
| 311 | MaioHsn maio_hsn, |
| 312 | /* MA bitmap to be indicated in RR Immediate Assignment */ |
| 313 | MobileAllocationLV ma_map, |
| 314 | /* The actual Mobile Allocation (ARFCN list) to be used */ |
| 315 | L1ctlMA ma |
| 316 | }; |
| 317 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 318 | type record ConnHdlrPars { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 319 | uint8_t trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 320 | RslChannelNr chan_nr, |
| 321 | RSL_IE_ChannelMode chan_mode, |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 322 | RSL_IE_MultirateCfg mr_conf optional, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 323 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 324 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 325 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 326 | RSL_IE_EncryptionInfo encr optional, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 327 | BtsBand bts0_band optional, |
| 328 | |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 329 | /* Training Sequence Code */ |
| 330 | GsmTsc tsc, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 331 | /* Frequency hopping parameters */ |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 332 | FreqHopPars fhp, |
| 333 | OsmuxCID loc_osmux_cid, |
| 334 | OsmuxCID rem_osmux_cid optional |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 335 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 336 | |
| 337 | /* Test-specific parameters */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 338 | friend type union TestSpecUnion { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 339 | RllTestCase rll, |
| 340 | TopTestCase top |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 341 | } |
| 342 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 343 | private template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 344 | max_retrans := RACH_MAX_RETRANS_7, |
| 345 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 346 | cell_barr_access := false, |
| 347 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 348 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 349 | }; |
| 350 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 351 | private template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 352 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 353 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 354 | acs := '0'B, |
| 355 | neci := true, |
| 356 | rxlev_access_min := 0 |
| 357 | } |
| 358 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 359 | private template (value) LocationAreaIdentification ts_LAI_default := { |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 360 | mcc_mnc := '262F42'H, |
| 361 | lac := 42 |
| 362 | } |
| 363 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 364 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 365 | ra_colour := 0, |
| 366 | si13_pos := '0'B |
| 367 | } |
| 368 | |
| 369 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 370 | modifies ts_SI3RestOctets := { |
| 371 | gprs_ind := { |
| 372 | presence := CSN1_H, |
| 373 | ind := ts_GPRSIndicator_def |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 378 | modifies ts_SI4RestOctets := { |
| 379 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 380 | presence := CSN1_H, |
| 381 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 385 | /* Default SYSTEM INFORMATION 3 */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 386 | private template (value) SystemInformation ts_SI3_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 387 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 388 | payload := { |
| 389 | si3 := { |
| 390 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 391 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 392 | ctrl_chan_desc := { |
| 393 | msc_r99 := true, |
| 394 | att := true, |
| 395 | bs_ag_blks_res := 1, |
| 396 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 397 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 398 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 399 | spare := '00'B, |
| 400 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 401 | t3212 := 1 /* 6 minutes */ |
| 402 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 403 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 404 | dn_ind := false, |
| 405 | pwrc := false, |
| 406 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 407 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 408 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 409 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 410 | rach_control := ts_RachCtrl_default, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 411 | rest_octets := valueof(ts_SI3RestOctets_def) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 415 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 416 | private template (value) SystemInformation ts_SI2_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 417 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 418 | payload := { |
| 419 | si2 := { |
| 420 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 421 | ncc_permitted := '11111111'B, |
| 422 | rach_control := ts_RachCtrl_default |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 427 | private template (value) SystemInformation ts_SI4_default := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 428 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 429 | payload := { |
| 430 | si4 := { |
| 431 | lai := ts_LAI_default, |
| 432 | cell_sel_par := ts_CellSelPar_default, |
| 433 | rach_control := ts_RachCtrl_default, |
| 434 | cbch_chan_desc := omit, |
| 435 | cbch_mobile_alloc := omit, |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 436 | rest_octets := valueof(ts_SI4RestOctets_def) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 441 | 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] | 442 | runs on test_CT { |
| 443 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 444 | 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] | 445 | } |
| 446 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 447 | 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] | 448 | runs on test_CT { |
| 449 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 450 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 451 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 452 | } |
| 453 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 454 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 455 | map(self:BTSVTY, system:BTSVTY); |
| 456 | f_vty_set_prompts(BTSVTY); |
| 457 | f_vty_transceive(BTSVTY, "enable"); |
| 458 | } |
| 459 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 460 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 461 | map(self:BSCVTY, system:BSCVTY); |
| 462 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 463 | f_vty_transceive(BSCVTY, "enable"); |
| 464 | } |
| 465 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 466 | friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr { |
| 467 | map(self:BSCVTY, system:BSCVTY); |
| 468 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 469 | f_vty_transceive(BSCVTY, "enable"); |
| 470 | } |
| 471 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 472 | /* PCU socket may at any time receive a new INFO.ind */ |
Pau Espin Pedrol | 65d712e | 2021-06-25 13:55:38 +0200 | [diff] [blame] | 473 | 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] | 474 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 475 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 476 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 477 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 478 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 479 | [] 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] | 480 | 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] | 481 | } |
| 482 | } |
| 483 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 484 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 485 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 486 | timer T := 2.0; |
| 487 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 488 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 489 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 490 | return; |
| 491 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 492 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 493 | |
| 494 | T.start; |
| 495 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 496 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 497 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 498 | 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] | 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 503 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 504 | out integer trxc_conn_id) { |
| 505 | var Result res; |
| 506 | |
| 507 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 508 | "", -1, -1, { udp := {} }, {}); |
| 509 | if (not ispresent(res.connId)) { |
| 510 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 511 | "Could not connect to the control (TRXC) interface " & |
| 512 | "of FakeTRX, check your configuration"); |
| 513 | } |
| 514 | trxc_conn_id := res.connId; |
| 515 | } |
| 516 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 517 | /* global init function (without PCUIF connection) */ |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 518 | friend function f_init(uint8_t trx_nr := 0) |
| 519 | runs on test_CT |
| 520 | { |
| 521 | var TrxParsItem trx_pars := mp_trx_pars[trx_nr]; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 522 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 523 | |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 524 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653. |
| 525 | * TODO: also generate this list dynamically from module parameters. */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 526 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 527 | g_AllChanTypes := { |
| 528 | /* TS 1..4: TCH/F */ |
| 529 | valueof(ts_RslChanNr_Bm(1)), |
| 530 | /* TS 5: TCH/H */ |
| 531 | valueof(ts_RslChanNr_Lm(5,1)), |
| 532 | /* TS 0: SDCCH/4 */ |
| 533 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 534 | /* TS 6: SDCCH/8 */ |
| 535 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 536 | }; |
| 537 | } else { |
| 538 | g_AllChanTypes := { |
| 539 | /* TS 1..4: TCH/F */ |
| 540 | valueof(ts_RslChanNr_Bm(1)), |
| 541 | /* TS 0: SDCCH/4 */ |
| 542 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 543 | /* TS 6: SDCCH/8 */ |
| 544 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 545 | }; |
| 546 | } |
Vadim Yanitskiy | 7e70709 | 2020-11-16 17:08:03 +0700 | [diff] [blame] | 547 | |
| 548 | g_AllChannels := { }; |
| 549 | |
| 550 | /* Generate list of all logical channels from module parameters */ |
| 551 | for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) { |
| 552 | select (trx_pars.ts[tn].config) { |
| 553 | case (GSM_PCHAN_CCCH_SDCCH4) { |
| 554 | g_AllChannels := g_AllChannels & |
| 555 | { valueof(ts_RslChanNr_SDCCH4(tn, 0)), |
| 556 | valueof(ts_RslChanNr_SDCCH4(tn, 1)), |
| 557 | valueof(ts_RslChanNr_SDCCH4(tn, 2)), |
| 558 | valueof(ts_RslChanNr_SDCCH4(tn, 3)) }; |
| 559 | } |
| 560 | case (GSM_PCHAN_SDCCH8) { |
| 561 | g_AllChannels := g_AllChannels & |
| 562 | { valueof(ts_RslChanNr_SDCCH8(tn, 0)), |
| 563 | valueof(ts_RslChanNr_SDCCH8(tn, 1)), |
| 564 | valueof(ts_RslChanNr_SDCCH8(tn, 2)), |
| 565 | valueof(ts_RslChanNr_SDCCH8(tn, 3)), |
| 566 | valueof(ts_RslChanNr_SDCCH8(tn, 4)), |
| 567 | valueof(ts_RslChanNr_SDCCH8(tn, 5)), |
| 568 | valueof(ts_RslChanNr_SDCCH8(tn, 6)), |
| 569 | valueof(ts_RslChanNr_SDCCH8(tn, 7)) }; |
| 570 | } |
| 571 | case (GSM_PCHAN_TCHH_TCHF_PDCH) { |
| 572 | g_AllChannels := g_AllChannels & |
| 573 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 574 | valueof(ts_RslChanNr_Lm(tn, 1)), |
| 575 | valueof(ts_RslChanNr_Bm(tn)) }; |
| 576 | } |
| 577 | case (GSM_PCHAN_TCHH) { |
| 578 | g_AllChannels := g_AllChannels & |
| 579 | { valueof(ts_RslChanNr_Lm(tn, 0)), |
| 580 | valueof(ts_RslChanNr_Lm(tn, 1)) }; |
| 581 | } |
| 582 | case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) { |
| 583 | g_AllChannels := g_AllChannels & |
| 584 | { valueof(ts_RslChanNr_Bm(tn)) }; |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 589 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 590 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 591 | f_init_vty(id); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 592 | f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 593 | |
| 594 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 595 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 596 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 597 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 598 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 599 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 600 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 601 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 602 | |
| 603 | /* Init TRXC interface to FakeTRX */ |
| 604 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 605 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 606 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 607 | /* 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] | 608 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256)); |
| 609 | 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] | 610 | /* 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] | 611 | 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] | 612 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 613 | |
| 614 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 615 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 616 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 617 | } |
| 618 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 619 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 620 | friend function f_init_l1ctl() runs on test_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 621 | map(self:L1CTL, system:L1CTL); |
| 622 | f_connect_reset(L1CTL); |
| 623 | } |
| 624 | |
Vadim Yanitskiy | 7387813 | 2021-05-05 02:22:45 +0200 | [diff] [blame] | 625 | friend type function void_fn(charstring id) runs on ConnHdlr; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 626 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 627 | private type record length(8) of FreqHopGroups FreqHopConfig; |
| 628 | |
| 629 | private type record of FreqHopGroup FreqHopGroups; |
| 630 | private type record FreqHopGroup { |
| 631 | uint6_t hsn, |
| 632 | FreqHopGroupItems trx_maio |
| 633 | }; |
| 634 | |
| 635 | private type record of FreqHopGroupItem FreqHopGroupItems; |
| 636 | private type record FreqHopGroupItem { |
| 637 | uint8_t trx_nr, |
| 638 | uint6_t maio |
| 639 | }; |
| 640 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 641 | friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn, |
| 642 | uint8_t trx_nr := 0) |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 643 | { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 644 | var FreqHopGroups groups := mp_fh_config[tn]; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 645 | var integer i, j; |
| 646 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 647 | fhp.enabled := false; |
| 648 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 649 | for (i := 0; i < lengthof(groups); i := i + 1) { |
| 650 | var FreqHopGroup g := groups[i]; |
| 651 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 652 | var FreqHopGroupItem gi := g.trx_maio[j]; |
| 653 | if (gi.trx_nr == trx_nr) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 654 | fhp.maio_hsn.maio := gi.maio; |
| 655 | fhp.maio_hsn.hsn := g.hsn; |
| 656 | fhp.enabled := true; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 657 | break; |
| 658 | } |
| 659 | } |
| 660 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 661 | if (fhp.enabled) { |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 662 | /* Prepare the Mobile Allocation bitmask (length & padding) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 663 | fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */ |
| 664 | fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B); |
| 665 | fhp.ma := { }; /* to be composed below */ |
Vadim Yanitskiy | 4fa7425 | 2020-08-03 15:51:58 +0700 | [diff] [blame] | 666 | |
| 667 | /* Compose the actual Mobile Allocation and the bitmask */ |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 668 | for (j := 0; j < lengthof(g.trx_maio); j := j + 1) { |
| 669 | var FreqHopGroupItem gi := g.trx_maio[j]; |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 670 | var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn; |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 671 | fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 672 | fhp.ma_map.ma[gi.trx_nr] := '1'B; |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 673 | } |
| 674 | |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 675 | log("Freq. hopping parameters: ", fhp); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 676 | break; /* We're done */ |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 681 | /* create a new test component */ |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 682 | friend function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 683 | boolean pcu_comp := false, |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 684 | boolean trxc_comp := false, |
| 685 | boolean l1ctl := true) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 686 | runs on test_CT return ConnHdlr { |
| 687 | var charstring id := testcasename(); |
| 688 | var ConnHdlr vc_conn; |
| 689 | |
| 690 | vc_conn := ConnHdlr.create(id); |
| 691 | /* connect to RSL Emulation main component */ |
| 692 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 693 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 694 | |
| 695 | /* The ConnHdlr component may want to talk to some ports directly, |
| 696 | * so we disconnect it from the test_CT and connect it to the component. |
| 697 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 698 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 699 | unmap(self:PCU, system:PCU); |
| 700 | map(vc_conn:PCU, system:PCU); |
| 701 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 702 | if (trxc_comp) { |
| 703 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 704 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 705 | } |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 706 | if (l1ctl) { |
| 707 | map(vc_conn:L1CTL, system:L1CTL); |
| 708 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 709 | |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 710 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 711 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 712 | f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 713 | } |
| 714 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 715 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 716 | return vc_conn; |
| 717 | } |
| 718 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 719 | private altstep as_Tguard() runs on ConnHdlr { |
| 720 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 721 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 722 | } |
| 723 | } |
| 724 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 725 | 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] | 726 | var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn)); |
Vadim Yanitskiy | 1acc7bb | 2020-11-14 04:24:57 +0700 | [diff] [blame] | 727 | f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 728 | } |
| 729 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 730 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 731 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 732 | 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] | 733 | } |
| 734 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 735 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 736 | var TrxcMessage ret; |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 737 | 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] | 738 | } |
| 739 | |
| 740 | /* first function started in ConnHdlr component */ |
| 741 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 742 | runs on ConnHdlr { |
| 743 | g_pars := pars; |
| 744 | g_chan_nr := pars.chan_nr; |
| 745 | |
Vadim Yanitskiy | 918e2b2 | 2021-05-28 04:57:50 +0200 | [diff] [blame] | 746 | if (L1CTL.checkstate("Mapped")) { |
| 747 | f_connect_reset(L1CTL); |
| 748 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 749 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 750 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 751 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 752 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 753 | |
| 754 | g_Tguard.start(pars.t_guard); |
| 755 | activate(as_Tguard()); |
| 756 | |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 757 | f_rslem_register(pars.trx_nr, pars.chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 758 | |
| 759 | /* call the user-supplied test case function */ |
| 760 | fn.apply(id); |
| 761 | } |
| 762 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 763 | private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, |
| 764 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 765 | runs on ConnHdlr return RSL_Message { |
| 766 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 767 | timer T := 3.0; |
| 768 | RSL.send(tx); |
| 769 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 770 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 771 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 772 | T.stop; |
| 773 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 774 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 775 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 776 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 777 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 778 | [not ignore_other] as_l1_sacch(); |
| 779 | [not ignore_other] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 780 | [not ignore_other] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 781 | [not ignore_other] as_l1_tch_loop(); |
Pau Espin Pedrol | a6d488d | 2022-10-04 11:20:38 +0200 | [diff] [blame] | 782 | [not ignore_other] RSL.receive(RSL_Message:?) -> value rx { |
| 783 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Rx unexpected RSL port message: ", rx)); |
| 784 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 785 | [not ignore_other] RSL.receive { |
Pau Espin Pedrol | a6d488d | 2022-10-04 11:20:38 +0200 | [diff] [blame] | 786 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx unexpected RSL port message"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 787 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 788 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 789 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 790 | return rx; |
| 791 | } |
| 792 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 793 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 794 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 795 | runs on ConnHdlr { |
| 796 | 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] | 797 | } |
| 798 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 799 | /* Send the given measurement results to the IUT over the Um interface */ |
| 800 | friend function f_send_meas_rep(template (value) MeasurementResults meas_res) |
| 801 | runs on ConnHdlr { |
| 802 | var template (value) SacchL1Header l1h; |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 803 | |
| 804 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta); |
| 805 | f_send_meas_rep_l1h(meas_res, l1h); |
| 806 | } |
| 807 | |
| 808 | /* Send the given measurement results and L1H to the IUT over the Um interface */ |
| 809 | friend function f_send_meas_rep_l1h(template (value) MeasurementResults meas_res, |
| 810 | template (value) SacchL1Header l1h) |
| 811 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 812 | var octetstring l2; |
| 813 | |
| 814 | /* RR Measurement Report to be sent */ |
| 815 | var GsmRrL3Message meas_rep := { |
| 816 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 817 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 818 | }; |
| 819 | |
| 820 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 821 | 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] | 822 | |
| 823 | log(%definitionId, "(): Tx SACCH L1 header: ", l1h); |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 824 | |
| 825 | /* Send RR Measurement Report over the Um interface */ |
| 826 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
| 827 | } |
| 828 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 829 | /* Send the given measurement results to the IUT over the Um interface, |
| 830 | * wait for the IUT to receive then and forward over the A-bis/RSL interface. */ |
| 831 | friend function f_transceive_meas_rep(template (value) MeasurementResults meas_res) |
| 832 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 833 | var octetstring l3; |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 834 | timer T; |
| 835 | |
| 836 | /* RR Measurement Report to be sent */ |
| 837 | var GsmRrL3Message meas_rep := { |
| 838 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 839 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 840 | }; |
| 841 | |
| 842 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 843 | l3 := f_pad_oct(enc_GsmRrL3Message(meas_rep), 18, '00'O); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 844 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 845 | f_send_meas_rep(meas_res); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 846 | |
| 847 | /* Expect MEASurement RESult on the A-bis/RSL interface */ |
| 848 | T.start(2.0); |
| 849 | alt { |
| 850 | [] RSL.receive(tr_RSL_MEAS_RES_OSMO(g_chan_nr, l3_info := l3)) { |
| 851 | setverdict(pass); |
| 852 | } |
| 853 | [] RSL.receive { repeat; } |
| 854 | [] T.timeout { |
| 855 | setverdict(fail, "Timeout waiting for RSL MEASurement RESult"); |
| 856 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 857 | } |
| 858 | } |
| 859 | } |
| 860 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 861 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 862 | boolean encr_enable := false, |
| 863 | RSL_IE_List more_ies := {}, |
| 864 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 865 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 866 | 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] | 867 | if (encr_enable) { |
| 868 | /* append encryption related IEs, if requested */ |
| 869 | var RSL_IE_EncryptionInfo encr_info; |
| 870 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 871 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 872 | encr_info})) }; |
| 873 | } |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 874 | if (mode.coding_alg_rate == RSL_CMOD_SP_GSM3) { |
| 875 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_MR_CONFIG, |
| 876 | RSL_IE_Body:{multirate_cfg := g_pars.mr_conf})) }; |
| 877 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 878 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 879 | 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] | 880 | } |
| 881 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 882 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 883 | 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] | 884 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 885 | } |
| 886 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 887 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 888 | template RSL_IE_ChannelMode chan_mode, |
| 889 | template (omit) TestSpecUnion spec := omit, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 890 | uint8_t trx_nr := 0, float t_guard := 20.0) := { |
| 891 | trx_nr := trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 892 | chan_nr := valueof(chan_nr), |
| 893 | chan_mode := valueof(chan_mode), |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 894 | mr_conf := omit, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 895 | t_guard := t_guard, |
| 896 | l1_pars := { |
| 897 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 898 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 899 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 900 | meas_ul := { |
| 901 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 902 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 903 | rxqual := 0 |
| 904 | }, |
| 905 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 906 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 907 | rxqual := 0 |
| 908 | } |
| 909 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 910 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 911 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 912 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 913 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 914 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 915 | }, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 916 | spec := spec, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 917 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 918 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 919 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 920 | fhp := { |
| 921 | enabled := false, |
| 922 | maio_hsn := ts_HsnMaio(0, 0), |
| 923 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 924 | ma := { } |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 925 | }, |
| 926 | loc_osmux_cid := trx_nr, |
| 927 | rem_osmux_cid := omit |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 928 | } |
| 929 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 930 | /* This altstep triggers on receipt of a L1CTL DATA.ind matching the given |
| 931 | * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */ |
| 932 | private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg, |
| 933 | template (present) octetstring tr_data := ?, |
| 934 | template (present) RslChannelNr chan_nr := ?, |
| 935 | template (present) RslLinkId link_id := ?) |
| 936 | runs on ConnHdlr { |
| 937 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg; |
| 938 | } |
| 939 | |
| 940 | /* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt |
| 941 | * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */ |
| 942 | private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?, |
| 943 | template (present) RslLinkId link_id := ?, |
| 944 | template (present) LapdmSapi sapi := ?, |
| 945 | boolean do_repeat := true) |
| 946 | runs on ConnHdlr { |
| 947 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O); |
| 948 | var L1ctlDlMessage dl_msg; |
| 949 | |
| 950 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) { |
| 951 | if (do_repeat) { |
| 952 | repeat; |
| 953 | } |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | /* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload |
| 958 | * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */ |
| 959 | private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame, |
| 960 | template (present) LapdmFrameAB tr_frame := ?, |
| 961 | template (present) RslLinkId link_id := ?) |
| 962 | runs on ConnHdlr { |
| 963 | var L1ctlDlMessage dl_msg; |
| 964 | |
| 965 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) { |
| 966 | frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload); |
| 967 | } |
| 968 | } |
| 969 | |
Vadim Yanitskiy | a144e3c | 2022-03-14 23:56:40 +0300 | [diff] [blame] | 970 | /* This altstep triggers on receipt of a Downlink SACCH containing a L2 payload |
| 971 | * that matches the given LAPDm frame, as well as the given SACCH L1 header. */ |
| 972 | private altstep as_dl_sacch_lapdm_ab(out SacchL1Header l1h, out LapdmFrameAB frame, |
| 973 | template (present) LapdmFrameAB tr_frame := ?, |
| 974 | template (present) SacchL1Header tr_l1h := ?, |
| 975 | template (present) GsmSapi sapi := ?) |
| 976 | runs on ConnHdlr { |
| 977 | var L1ctlDlMessage dl_msg; |
| 978 | template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi); |
| 979 | template (present) L1ctlDataReq tr_data := { |
| 980 | l1header := tr_l1h, |
| 981 | l2_payload := decmatch tr_frame |
| 982 | }; |
| 983 | |
| 984 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_data, g_chan_nr, link_id) { |
| 985 | var octetstring data := dl_msg.payload.data_ind.payload; |
| 986 | l1h := dec_SacchL1Header(substr(data, 0, 2)); |
| 987 | frame := dec_LapdmFrameAB(substr(data, 2, lengthof(data) - 2)); |
| 988 | } |
| 989 | } |
| 990 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 991 | /* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt |
| 992 | * of a LAPDm AB frame with a L3 payload matching the given template. The L3 |
| 993 | * payload is treated as PDU_ML3_NW_MS. */ |
| 994 | private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu, |
| 995 | template (present) PDU_ML3_NW_MS tr_pdu := ?, |
| 996 | template (present) GsmSapi sapi := 0) |
| 997 | runs on ConnHdlr { |
| 998 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu); |
| 999 | template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi); |
| 1000 | var LapdmFrameAB lapdm_frame; |
| 1001 | |
| 1002 | [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) { |
| 1003 | pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload); |
| 1004 | } |
| 1005 | } |
| 1006 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1007 | /*********************************************************************** |
| 1008 | * Channel Activation / Deactivation |
| 1009 | ***********************************************************************/ |
| 1010 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1011 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1012 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1013 | for (var integer i := 0; i < 500; i := i+1) { |
| 1014 | f_rsl_chan_act(g_pars.chan_mode); |
| 1015 | f_rsl_chan_deact(); |
| 1016 | } |
| 1017 | setverdict(pass); |
| 1018 | } |
| 1019 | testcase TC_chan_act_stress() runs on test_CT { |
| 1020 | var ConnHdlr vc_conn; |
| 1021 | 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] | 1022 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1023 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 1024 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1025 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1026 | } |
| 1027 | |
| 1028 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1029 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1030 | f_rsl_chan_act(g_pars.chan_mode); |
| 1031 | /* attempt to activate the same lchan again -> expect reject */ |
| 1032 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1033 | alt { |
| 1034 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1035 | 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] | 1036 | } |
| 1037 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1038 | setverdict(pass); |
| 1039 | } |
| 1040 | } |
| 1041 | f_rsl_chan_deact(); |
| 1042 | } |
| 1043 | testcase TC_chan_act_react() runs on test_CT { |
| 1044 | var ConnHdlr vc_conn; |
| 1045 | 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] | 1046 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1047 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 1048 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1049 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1053 | 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] | 1054 | timer T := 3.0; |
| 1055 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 1056 | T.start; |
| 1057 | alt { |
| 1058 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 1059 | setverdict(pass); |
| 1060 | } |
| 1061 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1062 | 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] | 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 1067 | 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] | 1068 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1069 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 1070 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1071 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1075 | 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] | 1076 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1077 | alt { |
| 1078 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1079 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1080 | } |
| 1081 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1082 | setverdict(pass); |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | private type record WrongChanNrCase { |
| 1087 | RslChannelNr chan_nr, |
| 1088 | charstring description |
| 1089 | } |
| 1090 | private type record of WrongChanNrCase WrongChanNrCases; |
| 1091 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 1092 | chan_nr := chan_nr, |
| 1093 | description := desc |
| 1094 | } |
| 1095 | |
| 1096 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 1097 | var ConnHdlr vc_conn; |
| 1098 | var ConnHdlrPars pars; |
| 1099 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1100 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1101 | |
| 1102 | var WrongChanNrCases wrong := { |
| 1103 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 1104 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 1105 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 1106 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 1107 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 1108 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 1109 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 1110 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 1111 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 1112 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 1113 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 1114 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 1115 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 1116 | }; |
| 1117 | |
| 1118 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 1119 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 1120 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 1121 | vc_conn.done; |
| 1122 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1123 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1124 | } |
| 1125 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1126 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1127 | 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] | 1128 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1129 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1130 | |
| 1131 | /* test on each of the channels we have */ |
| 1132 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1133 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 1134 | |
| 1135 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 1136 | vc_conn := f_start_handler(fn, pars); |
| 1137 | vc_conn.done; |
| 1138 | } |
| 1139 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1140 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1141 | } |
| 1142 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1143 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1144 | * SACCH handling |
| 1145 | ***********************************************************************/ |
| 1146 | |
| 1147 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 1148 | timer T_sacch := 3.0; |
| 1149 | T_sacch.start; |
| 1150 | alt { |
| 1151 | [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] | 1152 | 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] | 1153 | } |
| 1154 | [not exp] T_sacch.timeout { |
| 1155 | setverdict(pass); |
| 1156 | } |
| 1157 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 1158 | setverdict(pass); |
| 1159 | } |
| 1160 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1161 | 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] | 1162 | } |
| 1163 | [] L1CTL.receive { repeat; } |
| 1164 | [] RSL.receive { repeat; } |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 1169 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 1170 | f_l1_tune(L1CTL); |
| 1171 | RSL.clear; |
| 1172 | |
| 1173 | /* activate the logical channel */ |
| 1174 | f_est_dchan(); |
| 1175 | L1CTL.clear; |
| 1176 | |
| 1177 | /* check that SACCH actually are received as expected */ |
| 1178 | f_exp_sacch(true); |
| 1179 | |
| 1180 | /* deactivate SACCH on the logical channel */ |
| 1181 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 1182 | f_sleep(1.0); |
| 1183 | L1CTL.clear; |
| 1184 | |
| 1185 | /* check that no SACCH are received anymore */ |
| 1186 | f_exp_sacch(false); |
| 1187 | |
| 1188 | /* release the channel */ |
| 1189 | f_rsl_chan_deact(); |
| 1190 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1191 | } |
| 1192 | testcase TC_deact_sacch() runs on test_CT { |
| 1193 | var ConnHdlr vc_conn; |
| 1194 | var ConnHdlrPars pars; |
| 1195 | f_init(); |
| 1196 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1197 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1198 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1199 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1200 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1201 | vc_conn.done; |
| 1202 | } |
| 1203 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1204 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1205 | } |
| 1206 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1207 | /* verify that given SACCH payload is present */ |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1208 | private function f_sacch_present(template octetstring l3_exp, |
| 1209 | boolean do_fail := true) |
| 1210 | runs on ConnHdlr { |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1211 | var L1ctlDlMessage dl; |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1212 | timer T_sacch := 3.0; |
| 1213 | L1CTL.clear; |
| 1214 | T_sacch.start; |
| 1215 | alt { |
| 1216 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1217 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1218 | if (match(l3, l3_exp)) { |
| 1219 | setverdict(pass); |
| 1220 | } else { |
| 1221 | repeat; |
| 1222 | } |
| 1223 | } |
| 1224 | [] L1CTL.receive { repeat; } |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1225 | [not do_fail] T_sacch.timeout { |
| 1226 | log("Timeout waiting for SACCH ", l3_exp); |
| 1227 | } |
| 1228 | [do_fail] T_sacch.timeout { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1229 | setverdict(fail, "Timeout waiting for SACCH ", l3_exp); |
| 1230 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1231 | } |
| 1232 | } |
| 1233 | } |
| 1234 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1235 | /* verify that given SACCH payload is not present */ |
| 1236 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1237 | var L1ctlDlMessage dl; |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1238 | timer T_sacch := 3.0; |
| 1239 | L1CTL.clear; |
| 1240 | T_sacch.start; |
| 1241 | alt { |
| 1242 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1243 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1244 | if (match(l3, l3_exp)) { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1245 | setverdict(fail, "Received unexpected SACCH ", dl); |
| 1246 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1247 | } else { |
| 1248 | repeat; |
| 1249 | } |
| 1250 | } |
| 1251 | [] L1CTL.receive { repeat; } |
| 1252 | [] T_sacch.timeout { |
| 1253 | setverdict(pass); |
| 1254 | } |
| 1255 | } |
| 1256 | } |
| 1257 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1258 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1259 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1260 | /* Set a known default SACCH filling for SI5 */ |
| 1261 | var octetstring si5 := f_rnd_octstring(19); |
| 1262 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1263 | |
| 1264 | f_l1_tune(L1CTL); |
| 1265 | RSL.clear; |
| 1266 | |
| 1267 | /* activate the logical channel */ |
| 1268 | f_est_dchan(); |
| 1269 | |
| 1270 | /* check that the specified SI5 value is actually sent */ |
| 1271 | f_sacch_present(si5); |
| 1272 | |
| 1273 | /* release the channel */ |
| 1274 | RSL.clear; |
| 1275 | f_rsl_chan_deact(); |
| 1276 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1277 | } |
| 1278 | testcase TC_sacch_filling() runs on test_CT { |
| 1279 | var ConnHdlr vc_conn; |
| 1280 | var ConnHdlrPars pars; |
| 1281 | f_init(); |
| 1282 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1283 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1284 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1285 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1286 | vc_conn.done; |
| 1287 | } |
| 1288 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1289 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1290 | } |
| 1291 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1292 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1293 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1294 | /* Set a known default SACCH filling for SI5 */ |
| 1295 | var octetstring si5 := f_rnd_octstring(19); |
| 1296 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1297 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1298 | |
| 1299 | f_l1_tune(L1CTL); |
| 1300 | RSL.clear; |
| 1301 | |
| 1302 | log("Activating channel, expecting standard SI5"); |
| 1303 | /* activate the logical channel */ |
| 1304 | f_est_dchan(); |
| 1305 | /* check that the specified SI5 value is actually sent */ |
| 1306 | f_sacch_present(si5); |
| 1307 | |
| 1308 | /* set channel-specific different SI5 */ |
| 1309 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1310 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1311 | /* check that the specified lchan-specific value is now used */ |
| 1312 | f_sacch_present(si5_diff); |
| 1313 | |
| 1314 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1315 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1316 | f_rsl_chan_deact(); |
| 1317 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1318 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1319 | f_sacch_present(si5); |
| 1320 | |
| 1321 | /* release the channel */ |
| 1322 | RSL.clear; |
| 1323 | f_rsl_chan_deact(); |
| 1324 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1325 | } |
| 1326 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1327 | var ConnHdlr vc_conn; |
| 1328 | var ConnHdlrPars pars; |
| 1329 | f_init(); |
| 1330 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1331 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1332 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1333 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1334 | vc_conn.done; |
| 1335 | } |
| 1336 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1337 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1338 | } |
| 1339 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1340 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1341 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1342 | var octetstring si5 := f_rnd_octstring(19); |
| 1343 | var octetstring si5bis := f_rnd_octstring(19); |
| 1344 | var octetstring si5ter := f_rnd_octstring(19); |
| 1345 | var octetstring si6 := f_rnd_octstring(19); |
| 1346 | |
| 1347 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1348 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1349 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1350 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1351 | |
| 1352 | f_l1_tune(L1CTL); |
| 1353 | RSL.clear; |
| 1354 | |
| 1355 | /* activate the logical channel */ |
| 1356 | f_est_dchan(); |
| 1357 | L1CTL.clear; |
| 1358 | |
| 1359 | /* check that SACCH actually are received as expected */ |
| 1360 | f_sacch_present(si5); |
| 1361 | f_sacch_present(si5bis); |
| 1362 | f_sacch_present(si5ter); |
| 1363 | f_sacch_present(si6); |
| 1364 | |
| 1365 | /* release the channel */ |
| 1366 | f_rsl_chan_deact(); |
| 1367 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1368 | } |
| 1369 | testcase TC_sacch_multi() runs on test_CT { |
| 1370 | var ConnHdlr vc_conn; |
| 1371 | var ConnHdlrPars pars; |
| 1372 | f_init(); |
| 1373 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1374 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1375 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1376 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1377 | vc_conn.done; |
| 1378 | } |
| 1379 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1381 | } |
| 1382 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1383 | /* Test if SACH information is modified as expected */ |
| 1384 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1385 | var octetstring si5 := f_rnd_octstring(19); |
| 1386 | var octetstring si6 := f_rnd_octstring(19); |
| 1387 | |
| 1388 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1389 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1390 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1391 | |
| 1392 | f_l1_tune(L1CTL); |
| 1393 | RSL.clear; |
| 1394 | |
| 1395 | /* activate the logical channel */ |
| 1396 | f_est_dchan(); |
| 1397 | L1CTL.clear; |
| 1398 | |
| 1399 | /* check that SACCH actually are received as expected */ |
| 1400 | f_sacch_present(si5); |
| 1401 | f_sacch_present(si6); |
| 1402 | |
| 1403 | /* disable SI6 */ |
| 1404 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1405 | |
| 1406 | /* check that SI5 is still transmitted */ |
| 1407 | f_sacch_present(si5); |
| 1408 | /* check if SI6 is now gone */ |
| 1409 | f_sacch_missing(si6); |
| 1410 | |
| 1411 | /* release the channel */ |
| 1412 | f_rsl_chan_deact(); |
| 1413 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1414 | } |
| 1415 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1416 | var ConnHdlr vc_conn; |
| 1417 | var ConnHdlrPars pars; |
| 1418 | f_init(); |
| 1419 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1420 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1421 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1422 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1423 | vc_conn.done; |
| 1424 | } |
| 1425 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1426 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1427 | } |
| 1428 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1429 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1430 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1431 | var octetstring si5 := f_rnd_octstring(19); |
| 1432 | var octetstring si6 := f_rnd_octstring(19); |
| 1433 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1434 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1435 | |
| 1436 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1437 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1438 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1439 | |
| 1440 | f_l1_tune(L1CTL); |
| 1441 | RSL.clear; |
| 1442 | |
| 1443 | /* activate channel with different SACCH filling */ |
| 1444 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1445 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1446 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1447 | })); |
| 1448 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1449 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1450 | f_est_dchan(more_ies := addl_ies); |
| 1451 | |
| 1452 | /* check that SACCH actually are received as expected */ |
| 1453 | f_sacch_present(si5_specific); |
| 1454 | f_sacch_present(si6_specific); |
| 1455 | |
| 1456 | /* release the channel */ |
| 1457 | f_rsl_chan_deact(); |
| 1458 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1459 | } |
| 1460 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1461 | var ConnHdlr vc_conn; |
| 1462 | var ConnHdlrPars pars; |
| 1463 | f_init(); |
| 1464 | |
| 1465 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1466 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1467 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1468 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1469 | vc_conn.done; |
| 1470 | } |
| 1471 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1472 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1473 | } |
| 1474 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1475 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1476 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1477 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1478 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1479 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1480 | |
| 1481 | f_l1_tune(L1CTL); |
| 1482 | RSL.clear; |
| 1483 | |
| 1484 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1485 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1486 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1487 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1488 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1489 | var RSL_IE_List addl_ies := { |
| 1490 | ho_ref_ie |
| 1491 | }; |
| 1492 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1493 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1494 | 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] | 1495 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1496 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1497 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1498 | |
| 1499 | /* Verify that no DL SACCH is being received */ |
| 1500 | f_sacch_missing(?); |
| 1501 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1502 | /* Send handover Access Burst and expect SACCH to start */ |
| 1503 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1504 | |
| 1505 | f_sacch_present(si5); |
| 1506 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1507 | f_rsl_chan_deact(); |
| 1508 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 289056c | 2022-12-25 02:07:49 +0700 | [diff] [blame] | 1509 | f_L1CTL_RESET(L1CTL); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1510 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1511 | /* Tune back to CCCH/BCCH */ |
| 1512 | f_l1_tune(L1CTL); |
| 1513 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1514 | |
| 1515 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1516 | |
| 1517 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1518 | addl_ies := { |
| 1519 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1520 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1521 | }; |
| 1522 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1523 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1524 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1525 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1526 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1527 | /* 4.1.3 "If the MS Power IE is present the BTS *may* start transmission |
| 1528 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1529 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1530 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1531 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1532 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1533 | |
| 1534 | f_sacch_present(si5); |
| 1535 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1536 | f_rsl_chan_deact(); |
| 1537 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1538 | } |
| 1539 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1540 | var ConnHdlr vc_conn; |
| 1541 | var ConnHdlrPars pars; |
| 1542 | f_init(); |
| 1543 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1544 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1545 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1546 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1547 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1548 | vc_conn.done; |
| 1549 | } |
| 1550 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1551 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1552 | } |
| 1553 | |
| 1554 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1555 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1556 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1557 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1558 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1559 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1560 | var RSL_IE_List addl_ies; |
| 1561 | |
| 1562 | f_l1_tune(L1CTL); |
| 1563 | RSL.clear; |
| 1564 | |
| 1565 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1566 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1567 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1568 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1569 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1570 | addl_ies := { |
| 1571 | ho_ref_ie |
| 1572 | }; |
| 1573 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1574 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1575 | 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] | 1576 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1577 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1578 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1579 | |
| 1580 | /* Verify that no DL SACCH is being received */ |
| 1581 | f_sacch_missing(?); |
| 1582 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1583 | /* Send handover Access Burst and expect SACCH to start */ |
| 1584 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1585 | |
| 1586 | f_sacch_present(si5); |
| 1587 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1588 | f_rsl_chan_deact(); |
| 1589 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 289056c | 2022-12-25 02:07:49 +0700 | [diff] [blame] | 1590 | f_L1CTL_RESET(L1CTL); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1591 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1592 | /* Tune back to CCCH/BCCH */ |
| 1593 | f_l1_tune(L1CTL); |
| 1594 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1595 | |
| 1596 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1597 | |
| 1598 | /* Activate channel on BTS side */ |
| 1599 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1600 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1601 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1602 | }; |
| 1603 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1604 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1605 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1606 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1607 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1608 | /* 4.1.4 "If only the MS Power IE is present the BTS *may* start transmission |
| 1609 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1610 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1611 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1612 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 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); |
Vadim Yanitskiy | 289056c | 2022-12-25 02:07:49 +0700 | [diff] [blame] | 1619 | f_L1CTL_RESET(L1CTL); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1620 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1621 | /* Tune back to CCCH/BCCH */ |
| 1622 | f_l1_tune(L1CTL); |
| 1623 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1624 | |
| 1625 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1626 | |
| 1627 | /* Activate channel on BTS side */ |
| 1628 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1629 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1630 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 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 no DL SACCH is being received */ |
| 1638 | f_sacch_missing(?); |
| 1639 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1640 | /* Send handover Access Burst and expect SACCH to start */ |
| 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); |
Vadim Yanitskiy | 289056c | 2022-12-25 02:07:49 +0700 | [diff] [blame] | 1647 | f_L1CTL_RESET(L1CTL); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1648 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1649 | /* Tune back to CCCH/BCCH */ |
| 1650 | f_l1_tune(L1CTL); |
| 1651 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1652 | |
| 1653 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1654 | |
| 1655 | /* Activate channel on BTS side */ |
| 1656 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1657 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1658 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1659 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1660 | }; |
| 1661 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1662 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1663 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1664 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1665 | |
| 1666 | /* Verify that DL SACCH is being received */ |
| 1667 | f_sacch_present(si5); |
| 1668 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1669 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1670 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1671 | |
| 1672 | f_sacch_present(si5); |
| 1673 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1674 | f_rsl_chan_deact(); |
| 1675 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1676 | } |
| 1677 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1678 | var ConnHdlr vc_conn; |
| 1679 | var ConnHdlrPars pars; |
| 1680 | f_init(); |
| 1681 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1682 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1683 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1684 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1685 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1686 | vc_conn.done; |
| 1687 | } |
| 1688 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1689 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1690 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1691 | |
| 1692 | |
| 1693 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1694 | * RACH Handling |
| 1695 | ***********************************************************************/ |
| 1696 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1697 | /* 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] | 1698 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1699 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1700 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1701 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1702 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1703 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1704 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1705 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1706 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1707 | if (emerg == true) { |
| 1708 | ra := f_rnd_ra_emerg(); |
| 1709 | } else { |
| 1710 | ra := f_rnd_ra_cs(); |
| 1711 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1712 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1713 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1714 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1715 | } |
| 1716 | fn_last := fn; |
| 1717 | |
| 1718 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1719 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1720 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1721 | [] 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] | 1722 | T.stop; |
| 1723 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1724 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1725 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1726 | } |
| 1727 | [] RSL_CCHAN.receive { repeat; } |
| 1728 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1729 | test_failed := true; |
| 1730 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1731 | } |
| 1732 | } |
| 1733 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1734 | if (test_failed) { |
| 1735 | 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] | 1736 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1737 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1738 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1739 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1740 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1741 | /* Normal variant */ |
| 1742 | testcase TC_rach_content() runs on test_CT { |
| 1743 | f_TC_rach_content(emerg := false); |
| 1744 | } |
| 1745 | |
| 1746 | /* Emergency call variant */ |
| 1747 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1748 | f_TC_rach_content(emerg := true); |
| 1749 | } |
| 1750 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1751 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1752 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1753 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1754 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1755 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1756 | f_l1_tune(L1CTL); |
| 1757 | |
| 1758 | var GsmFrameNumber fn_last := 0; |
| 1759 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1760 | var OCT1 ra := f_rnd_ra_cs(); |
| 1761 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1762 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1763 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1764 | } |
| 1765 | fn_last := fn; |
| 1766 | } |
| 1767 | var integer rsl_chrqd := 0; |
| 1768 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1769 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1770 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1771 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1772 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1773 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1774 | repeat; |
| 1775 | } |
| 1776 | [] RSL_CCHAN.receive { repeat; } |
| 1777 | [] T.timeout { } |
| 1778 | } |
| 1779 | if (rsl_chrqd == 1000) { |
| 1780 | setverdict(pass); |
| 1781 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1782 | 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] | 1783 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1784 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1785 | } |
| 1786 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1787 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1788 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1789 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1790 | } |
| 1791 | |
| 1792 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1793 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1794 | |
| 1795 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1796 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1797 | var ASP_RSL_Unitdata rx_ud; |
| 1798 | |
| 1799 | f_init_vty_bsc(); |
| 1800 | /* send load indications even at 0% load */ |
| 1801 | f_vty_load_ind_thresh(0); |
| 1802 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1803 | f_sleep(2.0); |
| 1804 | |
| 1805 | f_init(); |
| 1806 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1807 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1808 | alt { |
| 1809 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1810 | [] RSL_CCHAN.receive { repeat } |
| 1811 | } |
| 1812 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1813 | timer T := 5.0; |
| 1814 | T.start; |
| 1815 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1816 | [] 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] | 1817 | setverdict(pass); |
| 1818 | repeat; |
| 1819 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1820 | [] 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] | 1821 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1822 | repeat; |
| 1823 | } |
| 1824 | [] RSL_CCHAN.receive { |
| 1825 | repeat; |
| 1826 | } |
| 1827 | [] T.timeout { } |
| 1828 | } |
| 1829 | |
| 1830 | f_vty_load_ind_thresh(10); |
| 1831 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1832 | } |
| 1833 | |
| 1834 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1835 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1836 | var ASP_RSL_Unitdata rx_ud; |
| 1837 | |
| 1838 | f_init_vty_bsc(); |
| 1839 | f_init(); |
| 1840 | |
| 1841 | timer T := 5.0; |
| 1842 | T.start; |
| 1843 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1844 | [] 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] | 1845 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1846 | repeat; |
| 1847 | } |
| 1848 | [] RSL_CCHAN.receive { |
| 1849 | repeat; |
| 1850 | } |
| 1851 | [] T.timeout { |
| 1852 | setverdict(pass); |
| 1853 | } |
| 1854 | } |
| 1855 | |
| 1856 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1857 | } |
| 1858 | |
| 1859 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1860 | testcase TC_rach_load_count() runs on test_CT { |
| 1861 | var ASP_RSL_Unitdata rx_ud; |
| 1862 | var integer load_access_count := 0; |
| 1863 | |
| 1864 | f_init_vty_bsc(); |
| 1865 | /* send load indications even at 0% load */ |
| 1866 | f_vty_load_ind_thresh(0); |
| 1867 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1868 | f_sleep(2.0); |
| 1869 | f_init(); |
| 1870 | |
| 1871 | f_init_l1ctl(); |
| 1872 | f_sleep(1.0); |
| 1873 | f_l1_tune(L1CTL); |
| 1874 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1875 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1876 | alt { |
| 1877 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1878 | [] RSL_CCHAN.receive { repeat } |
| 1879 | } |
| 1880 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1881 | var GsmFrameNumber fn_last := 0; |
| 1882 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1883 | var OCT1 ra := f_rnd_ra_cs(); |
| 1884 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1885 | if (fn == fn_last) { |
| 1886 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1887 | } |
| 1888 | fn_last := fn; |
| 1889 | } |
| 1890 | |
| 1891 | timer T := 5.0; |
| 1892 | T.start; |
| 1893 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1894 | [] 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] | 1895 | -> value rx_ud { |
| 1896 | var RSL_IE_Body ie; |
| 1897 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1898 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1899 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1900 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1901 | } |
| 1902 | repeat; |
| 1903 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1904 | [] 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] | 1905 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1906 | repeat; |
| 1907 | } |
| 1908 | [] RSL_CCHAN.receive { |
| 1909 | repeat; |
| 1910 | } |
| 1911 | [] T.timeout { } |
| 1912 | } |
| 1913 | if (load_access_count == 1000) { |
| 1914 | setverdict(pass); |
| 1915 | } else { |
| 1916 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1917 | } |
| 1918 | |
| 1919 | f_vty_load_ind_thresh(10); |
| 1920 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1921 | } |
| 1922 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1923 | 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] | 1924 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1925 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 1926 | 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] | 1927 | f_sleep(0.5); |
| 1928 | |
| 1929 | /* Transmit RACH request + wait for confirmation */ |
| 1930 | var OCT1 ra := f_rnd_ra_cs(); |
| 1931 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1932 | |
| 1933 | /* Check for expected result */ |
| 1934 | timer T := 1.5; |
| 1935 | T.start; |
| 1936 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1937 | [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] | 1938 | setverdict(pass); |
| 1939 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1940 | [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] | 1941 | 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] | 1942 | } |
| 1943 | [] RSL_CCHAN.receive { repeat; } |
| 1944 | [not expect_pass] T.timeout { |
| 1945 | setverdict(pass); |
| 1946 | } |
| 1947 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1948 | 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] | 1949 | } |
| 1950 | } |
| 1951 | } |
| 1952 | |
| 1953 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1954 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1955 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1956 | f_init_l1ctl(); |
| 1957 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1958 | f_sleep(1.0); |
| 1959 | |
| 1960 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1961 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1962 | /* We allow early arrival up to 2 symbols */ |
| 1963 | f_rach_toffs(-1*256, true); |
| 1964 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1965 | f_rach_toffs(-10*256, false); |
| 1966 | |
| 1967 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1968 | f_rach_toffs(0, true); |
| 1969 | f_rach_toffs(32*256, true); |
| 1970 | f_rach_toffs(63*256, true); |
| 1971 | |
| 1972 | /* more than 63 bits is not legal / permitted */ |
| 1973 | f_rach_toffs(64*256, false); |
| 1974 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1976 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1977 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1978 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1979 | var GsmFrameNumber fn; |
| 1980 | var RSL_Message rm; |
| 1981 | |
| 1982 | f_l1_tune(L1CTL); |
| 1983 | RSL.clear; |
| 1984 | |
| 1985 | /* Generate a random Handover Reference */ |
| 1986 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1987 | |
| 1988 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1989 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1990 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1991 | |
| 1992 | /* Activate a channel on the BTS side (no encryption) */ |
| 1993 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1994 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1995 | |
| 1996 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1997 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1998 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1999 | |
| 2000 | /* Send handover Access Burst */ |
| 2001 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 2002 | |
| 2003 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 2004 | |
| 2005 | /* Wait for handover detection */ |
| 2006 | timer T := 3.0; |
| 2007 | T.start; |
| 2008 | alt { |
| 2009 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 2010 | log("Handover RACH has been detected: ", rm); |
| 2011 | setverdict(pass); |
| 2012 | } |
| 2013 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 2014 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2015 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 2016 | } |
| 2017 | [] RSL.receive { repeat; } |
| 2018 | [] T.timeout { |
| 2019 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2020 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 2021 | } |
| 2022 | } |
| 2023 | |
| 2024 | /* Release the channel */ |
| 2025 | f_rsl_chan_deact(); |
| 2026 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2027 | } |
| 2028 | |
| 2029 | /* Test handover RACH detection */ |
| 2030 | testcase TC_ho_rach() runs on test_CT { |
| 2031 | var ConnHdlrPars pars; |
| 2032 | var ConnHdlr vc_conn; |
| 2033 | |
| 2034 | f_init(); |
| 2035 | |
| 2036 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 2037 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 2038 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 2039 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 2040 | vc_conn.done; |
| 2041 | } |
| 2042 | |
| 2043 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2044 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2045 | } |
| 2046 | |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 2047 | /* Test sending of the RR Physical Information message on DCCH */ |
| 2048 | private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr { |
| 2049 | var PDU_ML3_NW_MS dcch_pdu; |
| 2050 | var integer count := 0; |
| 2051 | var L1ctlDlMessage dl; |
| 2052 | timer T; |
| 2053 | |
| 2054 | f_l1_tune(L1CTL); |
| 2055 | RSL.clear; |
| 2056 | |
| 2057 | /* Generate a random Handover Reference */ |
| 2058 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 2059 | |
| 2060 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 2061 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 2062 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 2063 | |
| 2064 | /* Activate a channel on the BTS side (no encryption) */ |
| 2065 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 2066 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 2067 | |
| 2068 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 2069 | * waiting for Immediate Assignment and sending of an Access Burst. */ |
| 2070 | f_l1ctl_est_dchan(L1CTL, g_pars); /* FIXME: disable Uplink Tx */ |
| 2071 | |
| 2072 | /* Expect nothing to be transmitted on Downlink DCCH. Nothing in this |
| 2073 | * context means any L2 frames, not only the RR Physical Information. */ |
| 2074 | T.start(2.0); |
| 2075 | L1CTL.clear; |
| 2076 | alt { |
| 2077 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value dl { |
| 2078 | setverdict(fail, "Rx unexpected Downlink DCCH (before handover RACH): ", dl); |
| 2079 | T.stop; |
| 2080 | } |
| 2081 | [] L1CTL.receive { repeat; } |
| 2082 | [] T.timeout { setverdict(pass); } |
| 2083 | } |
| 2084 | |
| 2085 | /* Send handover Access Burst */ |
| 2086 | log("Sending handover Access Burst"); |
| 2087 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 2088 | |
| 2089 | /* Expect RR Physical Information being sent on Downlink DCCH Ny1 times */ |
| 2090 | T.start(int2float(mp_ho_t3105_ms * mp_ho_ny1) / 1000.0 + 1.0); |
| 2091 | L1CTL.clear; |
| 2092 | alt { |
| 2093 | [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */ |
| 2094 | [] as_dl_dcch_pdu(dcch_pdu, tr_RRM_PhysicalInfo) { |
| 2095 | log("Rx RR Physical Information: ", dcch_pdu); |
| 2096 | /* Wait until the count reaches Ny1 */ |
| 2097 | count := count + 1; |
| 2098 | if (count < mp_ho_ny1) |
| 2099 | { repeat; } |
| 2100 | setverdict(pass); |
| 2101 | } |
| 2102 | [] as_dl_dcch_pdu(dcch_pdu, ?) { |
| 2103 | setverdict(fail, "Rx unexpected DCCH PDU: ", dcch_pdu); |
| 2104 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2105 | } |
| 2106 | [] L1CTL.receive { repeat; } |
| 2107 | [] T.timeout { |
| 2108 | setverdict(fail, "Timeout waiting for RR Physical Information"); |
| 2109 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2110 | } |
| 2111 | } |
| 2112 | |
| 2113 | /* Release the channel */ |
| 2114 | f_rsl_chan_deact(); |
| 2115 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2116 | } |
| 2117 | testcase TC_ho_physical_info() runs on test_CT { |
| 2118 | var ConnHdlrPars pars; |
| 2119 | var ConnHdlr vc_conn; |
| 2120 | |
| 2121 | f_init(); |
| 2122 | |
| 2123 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 2124 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 2125 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
| 2126 | vc_conn := f_start_handler(refers(f_TC_ho_physical_info), pars); |
| 2127 | vc_conn.done; |
| 2128 | } |
| 2129 | |
| 2130 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2131 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2132 | } |
| 2133 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2134 | /*********************************************************************** |
| 2135 | * Measurement Processing / Reporting |
| 2136 | ***********************************************************************/ |
| 2137 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2138 | private template (value) LapdmAddressField |
| 2139 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 2140 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2141 | spare := '0'B, |
| 2142 | lpd := 0, |
| 2143 | sapi := sapi, |
| 2144 | c_r := c_r, |
| 2145 | ea := true |
| 2146 | } |
| 2147 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2148 | private template (value) LapdmFrameAB |
| 2149 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 2150 | template (value) GsmRrL3Message l3, |
| 2151 | template (value) boolean c_r := false, |
| 2152 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2153 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2154 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2155 | len := 0, /* overwritten */ |
| 2156 | m := false, |
| 2157 | el := 1, |
Vadim Yanitskiy | 16e2991 | 2022-03-12 13:26:21 +0300 | [diff] [blame] | 2158 | payload := enc_GsmRrL3Message(valueof(l3)), |
| 2159 | padding := ''O |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2160 | } |
| 2161 | |
| 2162 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2163 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2164 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2165 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2166 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2167 | [] 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] | 2168 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2169 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2170 | 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] | 2171 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 2172 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 2173 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 2174 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2175 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 2176 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2177 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 2178 | 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] | 2179 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 2180 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 2181 | 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] | 2182 | |
| 2183 | log("Sending Measurement Report: ", l1h, l2); |
| 2184 | 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] | 2185 | repeat; |
| 2186 | } |
| 2187 | } |
| 2188 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2189 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 2190 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 2191 | boolean do_apply := true) |
| 2192 | runs on ConnHdlr |
| 2193 | { |
| 2194 | var L1ctlDlMessage l1_dl; |
| 2195 | |
| 2196 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2197 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 2198 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 2199 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 2200 | |
| 2201 | if (do_apply) { |
| 2202 | /* Update TA and MS power to follow what BTS requests */ |
| 2203 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 2204 | } |
| 2205 | } |
| 2206 | } |
| 2207 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2208 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2209 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2210 | [] 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] | 2211 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 2212 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 2213 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2214 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2215 | repeat; |
| 2216 | } |
| 2217 | } |
| 2218 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2219 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 2220 | var L1ctlDlMessage l1_dl; |
| 2221 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 2222 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2223 | |
| 2224 | /* occasionaly inject FACCH frames into the uplink */ |
| 2225 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 2226 | var octetstring pl := '010301'O; |
| 2227 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2228 | f_pad_oct(pl, 23, '2B'O))); |
| 2229 | } else { |
| 2230 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 2231 | l1_dl.payload.traffic_ind.data)); |
| 2232 | } |
| 2233 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2234 | repeat; |
| 2235 | } |
| 2236 | } |
| 2237 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2238 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2239 | uint6_t rxlev, |
| 2240 | uint3_t rxqual |
| 2241 | } |
| 2242 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2243 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2244 | MeasElem full, |
| 2245 | MeasElem sub |
| 2246 | } |
| 2247 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2248 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2249 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2250 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2251 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2252 | MeasElemFS meas_ul, |
| 2253 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2254 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2255 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2256 | uint8_t ms_actual_ta, |
| 2257 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2258 | } |
| 2259 | |
| 2260 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 2261 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 2262 | return 63 + (toffs256s/256); |
| 2263 | } |
| 2264 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2265 | private function f_max(integer a, integer b) return integer { |
| 2266 | if (a > b) { |
| 2267 | return a; |
| 2268 | } else { |
| 2269 | return b; |
| 2270 | } |
| 2271 | } |
| 2272 | |
| 2273 | private function f_min(integer a, integer b) return integer { |
| 2274 | if (a < b) { |
| 2275 | return a; |
| 2276 | } else { |
| 2277 | return b; |
| 2278 | } |
| 2279 | } |
| 2280 | |
| 2281 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 2282 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 2283 | val := val - tolerance; |
| 2284 | return f_max(val, min); |
| 2285 | } |
| 2286 | |
| 2287 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 2288 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 2289 | val := val + tolerance; |
| 2290 | return f_min(val, max); |
| 2291 | } |
| 2292 | |
| 2293 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 2294 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 2295 | return template integer { |
| 2296 | var template integer ret; |
| 2297 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 2298 | return ret; |
| 2299 | } |
| 2300 | |
| 2301 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2302 | /* build a template for matching measurement results against */ |
| 2303 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 2304 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2305 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2306 | len := 3, |
| 2307 | rfu := '0'B, |
| 2308 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2309 | 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] | 2310 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2311 | 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] | 2312 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2313 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2314 | 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] | 2315 | supp_meas_info := omit |
| 2316 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2317 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2318 | ul_meas.len := (3+8); |
| 2319 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2320 | 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] | 2321 | toa256_min := ?, |
| 2322 | toa256_max := ?, |
| 2323 | toa256_std_dev := ? |
| 2324 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2325 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2326 | var template RSL_IE_BS_Power bs_power := { |
| 2327 | reserved := 0, |
| 2328 | epc := false, |
| 2329 | fpc := false, |
| 2330 | power_level := l1p.bs_power_level |
| 2331 | }; |
| 2332 | var template RSL_IE_L1Info l1_info := { |
| 2333 | ms_power_lvl := l1p.ms_power_level, |
| 2334 | fpc := false, |
| 2335 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2336 | 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] | 2337 | }; |
| 2338 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2339 | 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] | 2340 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2341 | ?, t_toffs); |
| 2342 | } |
| 2343 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2344 | /* build a template for matching measurement results that do not contain any |
| 2345 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2346 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2347 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2348 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2349 | len := 3, |
| 2350 | rfu := '0'B, |
| 2351 | dtx_d := l1p.dtx_enabled, |
| 2352 | rxlev_f_u := ?, |
| 2353 | reserved1 := '00'B, |
| 2354 | rxlev_s_u := ?, |
| 2355 | reserved2 := '00'B, |
| 2356 | rxq_f_u := ?, |
| 2357 | rxq_s_u := ?, |
| 2358 | supp_meas_info := omit |
| 2359 | }; |
| 2360 | if (l1p.toa256_enabled) { |
| 2361 | ul_meas.len := (3+8); |
| 2362 | ul_meas.supp_meas_info := { |
| 2363 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2364 | toa256_min := ?, |
| 2365 | toa256_max := ?, |
| 2366 | toa256_std_dev := ? |
| 2367 | } |
| 2368 | } |
| 2369 | var template RSL_IE_BS_Power bs_power := { |
| 2370 | reserved := 0, |
| 2371 | epc := false, |
| 2372 | fpc := false, |
| 2373 | power_level := l1p.bs_power_level |
| 2374 | }; |
| 2375 | |
| 2376 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2377 | } |
| 2378 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2379 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2380 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2381 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2382 | var boolean chan_est := false; |
| 2383 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2384 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2385 | |
| 2386 | /* Receive osmocom specific measurement reports. This is the normal |
| 2387 | * case. Here we verify that the measurement reports we sent are |
| 2388 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2389 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2390 | /* increment counter of next to-be-expected meas rep */ |
| 2391 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2392 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2393 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2394 | |
| 2395 | /* The following two cases may only happen in the beginning |
| 2396 | * of the channel establishment phase. Once we have received |
| 2397 | * the "our" measurement report the first time, the channel |
| 2398 | * is established and empty or hardcoded TRXCON reports must |
| 2399 | * not occur anymore. */ |
| 2400 | chan_est := true; |
| 2401 | |
| 2402 | repeat; |
| 2403 | } |
| 2404 | |
| 2405 | /* When the BTS has established the channel, the MS might need slightly |
| 2406 | * more time to establish the channel and actually start sending. The |
| 2407 | * result is then a measurement report that just lacks the measurement |
| 2408 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2409 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2410 | /* increment counter of next to-be-expected meas rep */ |
| 2411 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2412 | /* Re-start the timer expecting the next MEAS RES */ |
| 2413 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2414 | repeat; |
| 2415 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2416 | |
| 2417 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2418 | * measurements if the TTCN3 side does not supply measurement input in |
| 2419 | * time. In those cases TRXCON will either use a cached measurement |
| 2420 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2421 | * report the templates above will not match. We tolerate this |
| 2422 | * behavior, but only once. */ |
| 2423 | [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] | 2424 | /* increment counter of next to-be-expected meas rep */ |
| 2425 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2426 | if (g_first_meas_res) { |
| 2427 | g_first_meas_res := false; |
| 2428 | repeat; |
| 2429 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2430 | 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] | 2431 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2432 | } |
| 2433 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2434 | 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] | 2435 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2436 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2437 | 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] | 2438 | } |
| 2439 | } |
| 2440 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2441 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2442 | select (rsl_alg_id) { |
| 2443 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2444 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2445 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2446 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2447 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2448 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2449 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2450 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2451 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2452 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2453 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2454 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2455 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2456 | } |
| 2457 | } |
| 2458 | } |
| 2459 | |
| 2460 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2461 | select (rsl_alg_id) { |
| 2462 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2463 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2464 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2465 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2466 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2467 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2468 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2469 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2470 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2471 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2472 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2473 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2474 | } |
| 2475 | } |
| 2476 | } |
| 2477 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2478 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2479 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2480 | var GsmFrameNumber fn; |
| 2481 | timer T := 8.0; |
| 2482 | |
| 2483 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2484 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2485 | |
| 2486 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2487 | /* Send the actual RACH */ |
| 2488 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2489 | |
| 2490 | T.start; |
| 2491 | alt { |
| 2492 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2493 | [] T.timeout { |
| 2494 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2495 | } |
| 2496 | } |
| 2497 | T.stop |
| 2498 | return fn; |
| 2499 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2500 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2501 | /* Tune to a dedicated channel: L1CTL only */ |
| 2502 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2503 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2504 | var TrxParsItem trx_pars := mp_trx_pars[pars.trx_nr]; |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2505 | 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] | 2506 | trx_pars.arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2507 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2508 | 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] | 2509 | pars.fhp.maio_hsn.hsn, |
| 2510 | pars.fhp.maio_hsn.maio, |
| 2511 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2512 | } |
| 2513 | } |
| 2514 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2515 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2516 | 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] | 2517 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2518 | |
| 2519 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2520 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2521 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2522 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2523 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2524 | 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] | 2525 | } else { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2526 | var TrxParsItem trx_pars := mp_trx_pars[g_pars.trx_nr]; |
| 2527 | 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] | 2528 | } |
| 2529 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2530 | /* enable dedicated mode */ |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 2531 | f_l1ctl_est_dchan(L1CTL, g_pars); |
| 2532 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2533 | /* enable encryption, if requested */ |
| 2534 | if (encr_enable) { |
| 2535 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2536 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2537 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2538 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2539 | /* Send TCH Mode Request to the L1 if needed */ |
| 2540 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2541 | var L1ctlTchMode tch_mode; |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2542 | var uint8_t amr_start_codec := 0; |
| 2543 | var BIT8 amr_codecs_bitmask := '00000000'B; |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2544 | |
| 2545 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2546 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2547 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2548 | case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; } |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2549 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; |
Vadim Yanitskiy | f14e696 | 2022-09-14 15:18:06 +0700 | [diff] [blame] | 2550 | amr_codecs_bitmask := g_pars.mr_conf.codec_modes; |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2551 | } |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2552 | case else { |
| 2553 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2554 | " is not supported by the L1, falling back to signalling"); |
| 2555 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2556 | } |
| 2557 | } |
| 2558 | |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2559 | f_L1CTL_TCH_MODE(L1CTL, |
| 2560 | ts_L1CTL_TCH_MODE_REQ(tch_mode, |
| 2561 | amr_start_codec := amr_start_codec, |
| 2562 | amr_codecs_bitmask := amr_codecs_bitmask)); |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2563 | } |
| 2564 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2565 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2566 | } |
| 2567 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 2568 | private function get_start_amr_ft() runs on ConnHdlr return integer { |
| 2569 | var integer start_nth; |
| 2570 | if (g_pars.mr_conf.icmi) { |
| 2571 | start_nth := 0; /* FIXME: implement 3GPP TS 45.009 3.4.3 */ |
| 2572 | } else { |
| 2573 | start_nth := g_pars.mr_conf.start_mode; |
| 2574 | } |
| 2575 | |
| 2576 | var integer n := 0; |
| 2577 | for (var integer i:= 7; i >= 0; i := i - 1) { |
Vadim Yanitskiy | f14e696 | 2022-09-14 15:18:06 +0700 | [diff] [blame] | 2578 | if (g_pars.mr_conf.codec_modes[i] == '1'B) { |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 2579 | if (n == start_nth) { |
| 2580 | return 7 - i; |
| 2581 | } |
| 2582 | n := n + 1; |
| 2583 | } |
| 2584 | } |
| 2585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2586 | log2str("mr_conf is wrong! ", g_pars.mr_conf)); |
| 2587 | return 0; |
| 2588 | } |
| 2589 | |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2590 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2591 | friend function f_rtpem_activate(inout octetstring payload, |
| 2592 | RtpemConfig cfg := c_RtpemDefaultCfg, |
| 2593 | RtpemMode mode := RTPEM_MODE_BIDIR) |
| 2594 | runs on ConnHdlr { |
| 2595 | /* Step 0: initialize, connect and start the emulation component */ |
| 2596 | vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM"); |
| 2597 | map(vc_RTPEM:RTP, system:RTP); |
| 2598 | map(vc_RTPEM:RTCP, system:RTCP); |
| 2599 | connect(vc_RTPEM:CTRL, self:RTPEM_CTRL); |
| 2600 | connect(vc_RTPEM:DATA, self:RTPEM_DATA); |
| 2601 | vc_RTPEM.start(RTP_Emulation.f_main()); |
| 2602 | |
| 2603 | /* Step 1: configure the RTP parameters */ |
| 2604 | var integer payload_len := 0; |
| 2605 | var octetstring hdr := ''O; |
| 2606 | |
| 2607 | select (g_pars.chan_mode) { |
| 2608 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */ |
| 2609 | { payload_len := 33; hdr := 'D0'O; } |
| 2610 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */ |
| 2611 | { payload_len := 15; hdr := '00'O; } |
| 2612 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */ |
| 2613 | { payload_len := 31; hdr := 'C0'O; } |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 2614 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3)) /* TCH/AFS */ |
| 2615 | { |
| 2616 | var integer amr_ft := get_start_amr_ft(); |
| 2617 | payload_len := f_amrft_payload_len(amr_ft) + 2; |
| 2618 | hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 2619 | } |
| 2620 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3)) /* TCH/AHS */ |
| 2621 | { |
| 2622 | var integer amr_ft := get_start_amr_ft(); |
| 2623 | payload_len := f_amrft_payload_len(amr_ft) + 2; |
| 2624 | hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 2625 | } |
| 2626 | case else { |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2627 | setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode); |
| 2628 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2629 | } |
| 2630 | } |
| 2631 | |
| 2632 | /* Pad the payload to conform the expected length */ |
| 2633 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2634 | cfg.tx_fixed_payload := payload; |
| 2635 | f_rtpem_configure(RTPEM_CTRL, cfg); |
| 2636 | |
| 2637 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2638 | var PortNumber rtpem_bind_port := mp_rtpem_bind_port; |
| 2639 | f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port); |
| 2640 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2641 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2642 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2643 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2644 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2645 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit), |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 2646 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?, omit), |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2647 | "IPA CRCX ACK"); |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2648 | 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] | 2649 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2650 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2651 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2652 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2653 | remote_ip := f_inet_addr(mp_rtpem_bind_ip), |
| 2654 | remote_port := rtpem_bind_port, |
| 2655 | rtp_pt2 := 0), |
| 2656 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?), |
| 2657 | "IPA MDCX ACK"); |
| 2658 | |
| 2659 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2660 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2661 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2662 | f_rtpem_connect(RTPEM_CTRL, bts_bind_ip, bts_bind_port); |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2663 | |
| 2664 | /* Step 5: set the given RTP emulation mode */ |
| 2665 | f_rtpem_mode(RTPEM_CTRL, mode); |
| 2666 | } |
| 2667 | |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 2668 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2669 | friend function f_osmuxem_activate(inout octetstring payload, |
| 2670 | OsmuxemConfig cfg := c_OsmuxemDefaultCfg, |
| 2671 | OsmuxemMode mode := OSMUXEM_MODE_BIDIR) |
| 2672 | runs on ConnHdlr { |
| 2673 | var RSL_IE_Body ie; |
| 2674 | var OsmuxTxHandle tx_hdl; |
| 2675 | var OsmuxRxHandle rx_hdl; |
| 2676 | /* Step 0: initialize, connect and start the emulation component */ |
| 2677 | vc_OsmuxEM := OSMUX_Emulation_CT.create(testcasename() & "-OsmuxEM"); |
| 2678 | map(vc_OsmuxEM:OSMUX, system:OSMUX); |
| 2679 | connect(vc_OsmuxEM:CTRL, self:OsmuxEM_CTRL); |
| 2680 | connect(vc_OsmuxEM:DATA, self:OsmuxEM_DATA); |
| 2681 | vc_OsmuxEM.start(OSMUX_Emulation.f_main()); |
| 2682 | |
| 2683 | /* Step 1: configure the RTP parameters */ |
| 2684 | var integer payload_len := 31; |
| 2685 | var octetstring hdr := ''O; |
| 2686 | |
| 2687 | /* Pad the payload to conform the expected length */ |
| 2688 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2689 | cfg.tx_fixed_payload := payload; |
| 2690 | f_osmuxem_configure(OsmuxEM_CTRL, cfg); |
| 2691 | |
| 2692 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2693 | var PortNumber osmuxem_bind_port := mp_osmuxem_bind_port; |
| 2694 | f_osmuxem_bind(OsmuxEM_CTRL, mp_osmuxem_bind_ip, osmuxem_bind_port); |
| 2695 | rx_hdl := c_OsmuxemDefaultRxHandle; |
| 2696 | rx_hdl.cid := g_pars.loc_osmux_cid; |
| 2697 | f_osmuxem_register_rxhandle(OsmuxEM_CTRL, rx_hdl); |
| 2698 | |
| 2699 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2700 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2701 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2702 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2703 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit, g_pars.loc_osmux_cid), |
| 2704 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?, ?), |
| 2705 | "IPA CRCX ACK"); |
| 2706 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 2707 | f_rsl_find_ie(crcx_ack, RSL_IE_OSMO_OSMUX_CID, ie); |
| 2708 | g_pars.rem_osmux_cid := ie.osmux_cid.cid; |
| 2709 | |
| 2710 | |
| 2711 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2712 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2713 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2714 | remote_ip := f_inet_addr(mp_osmuxem_bind_ip), |
| 2715 | remote_port := osmuxem_bind_port, |
| 2716 | rtp_pt2 := 0, |
| 2717 | osmux_cid := g_pars.loc_osmux_cid), |
| 2718 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?, g_pars.rem_osmux_cid), |
| 2719 | "IPA MDCX ACK"); |
| 2720 | |
| 2721 | tx_hdl := valueof(t_TxHandleAMR590(g_pars.rem_osmux_cid)); |
| 2722 | f_osmuxem_register_txhandle(OsmuxEM_CTRL, tx_hdl); |
| 2723 | |
| 2724 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2725 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2726 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2727 | f_osmuxem_connect(OsmuxEM_CTRL, bts_bind_ip, bts_bind_port); |
| 2728 | |
| 2729 | /* Step 5: set the given RTP emulation mode */ |
| 2730 | f_osmuxem_mode(OsmuxEM_CTRL, mode); |
| 2731 | } |
| 2732 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2733 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2734 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2735 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2736 | RSL.clear; |
| 2737 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2738 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2739 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2740 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2741 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2742 | |
| 2743 | f_est_dchan(); |
| 2744 | |
| 2745 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2746 | * RSL measurement reports on Abis side */ |
| 2747 | timer T := 8.0; |
| 2748 | T.start; |
| 2749 | alt { |
| 2750 | [] as_l1_sacch(); |
| 2751 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2752 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2753 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2754 | [] L1CTL.receive { repeat; } |
| 2755 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2756 | /* 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] | 2757 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2758 | setverdict(pass); |
| 2759 | } |
| 2760 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2761 | 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] | 2762 | } |
| 2763 | } |
| 2764 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2765 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2766 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2767 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2768 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2769 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2770 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2771 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2772 | timer Tup := 10.0; |
| 2773 | Tup.start; |
| 2774 | alt { |
| 2775 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2776 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2777 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2778 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2779 | if (rx_lvl != max_rx_lvl) { |
| 2780 | repeat; |
| 2781 | } |
| 2782 | Tup.stop; |
| 2783 | } |
| 2784 | [] L1CTL.receive { repeat; } |
| 2785 | [] Tup.timeout { |
| 2786 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2787 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2788 | } |
| 2789 | } |
| 2790 | return max_rx_lvl; |
| 2791 | } |
| 2792 | |
| 2793 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2794 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2795 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2796 | var integer initial_rx_lvl := -1; |
| 2797 | var integer last_rx_lvl := -1; |
| 2798 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2799 | |
| 2800 | timer T := 2.0; |
| 2801 | alt { |
| 2802 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2803 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2804 | log("Received rx_level=", rx_lvl); |
| 2805 | if (initial_rx_lvl == -1) { |
| 2806 | initial_rx_lvl := rx_lvl; |
| 2807 | last_rx_lvl := rx_lvl; |
| 2808 | |
| 2809 | /* Expect a somehow low value during first received messages */ |
| 2810 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2811 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2812 | log2str("Detected high initial tx power during ramp up: ", |
| 2813 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2814 | } |
| 2815 | } |
| 2816 | |
| 2817 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2818 | if (rx_lvl > max_rx_lvl) { |
| 2819 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2820 | log2str("Detected Tx power higher than full power: ", |
| 2821 | rx_lvl , " > ", max_rx_lvl)); |
| 2822 | } |
| 2823 | |
| 2824 | /* Make sure it never decreases, since we are rumping up */ |
| 2825 | if (last_rx_lvl > rx_lvl) { |
| 2826 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2827 | log2str("Detected Tx power decrease during ramp up: ", |
| 2828 | last_rx_lvl , " -> ", rx_lvl)); |
| 2829 | } |
| 2830 | |
| 2831 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2832 | /* We reached the maximum power, start timer and receive |
| 2833 | /* a few more to make sure we don't surpass it */ |
| 2834 | log("Reached full power, wating a bit more until success"); |
| 2835 | T.start; |
| 2836 | } |
| 2837 | |
| 2838 | last_rx_lvl := rx_lvl; |
| 2839 | repeat; |
| 2840 | } |
| 2841 | [] L1CTL.receive { repeat; } |
| 2842 | [] T.timeout { } |
| 2843 | } |
| 2844 | |
| 2845 | /* We didn't increase tx power during ramp up */ |
| 2846 | if (initial_rx_lvl < last_rx_lvl) { |
| 2847 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2848 | } else { |
| 2849 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2850 | log2str("No Tx power increase during whole ramp up: ", |
| 2851 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2852 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2853 | } |
| 2854 | |
| 2855 | /* verify BTS ramps power down to rx_level 0 */ |
| 2856 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2857 | var L1ctlDlMessage l1_dl; |
| 2858 | var integer last_rx_lvl := max_rx_lvl; |
| 2859 | |
| 2860 | timer Tdown := 5.0; |
| 2861 | Tdown.start; |
| 2862 | alt { |
| 2863 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2864 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2865 | log("Received rx_level=", rx_lvl); |
| 2866 | |
| 2867 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2868 | if (rx_lvl > max_rx_lvl) { |
| 2869 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2870 | log2str("Detected Tx power higher than full power: ", |
| 2871 | rx_lvl , " > ", max_rx_lvl)); |
| 2872 | } |
| 2873 | |
| 2874 | /* Make sure it never increases, since we are rumping down */ |
| 2875 | if (last_rx_lvl < rx_lvl) { |
| 2876 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2877 | log2str("Detected Tx power increase during ramp up: ", |
| 2878 | last_rx_lvl , " -> ", rx_lvl)); |
| 2879 | } |
| 2880 | |
| 2881 | last_rx_lvl := rx_lvl; |
| 2882 | if (last_rx_lvl != 0) { |
| 2883 | repeat; |
| 2884 | } |
| 2885 | /* we reached power level 0, we are done */ |
| 2886 | Tdown.stop; |
| 2887 | } |
| 2888 | [] L1CTL.receive { repeat; } |
| 2889 | [] Tdown.timeout { } |
| 2890 | } |
| 2891 | |
| 2892 | /* We didn't increase tx power during ramp down */ |
| 2893 | if (max_rx_lvl > last_rx_lvl) { |
| 2894 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2895 | } else { |
| 2896 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2897 | log2str("No Tx power decrease during whole ramp down: ", |
| 2898 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2899 | } |
| 2900 | } |
| 2901 | |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 2902 | /* verify BTS power down to rx_level 0 without ramping */ |
| 2903 | private function f_verify_power_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2904 | var L1ctlDlMessage l1_dl; |
| 2905 | var boolean first_data_ind := true; |
| 2906 | |
| 2907 | timer Tdown := 5.0; |
| 2908 | Tdown.start; |
| 2909 | alt { |
| 2910 | [first_data_ind == true] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2911 | first_data_ind := false; |
| 2912 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2913 | log("Received rx_level=", rx_lvl); |
| 2914 | |
| 2915 | /* The first data indication could still have the original power level */ |
| 2916 | if (rx_lvl != 0 and rx_lvl != max_rx_lvl) { |
| 2917 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2918 | log2str("Detected Tx power: ", |
| 2919 | rx_lvl , " should be 0 or ", max_rx_lvl)); |
| 2920 | } |
| 2921 | repeat; |
| 2922 | } |
| 2923 | [first_data_ind == false] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2924 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2925 | log("Received rx_level=", rx_lvl); |
| 2926 | |
| 2927 | /* Expect immediate power off so either rx_level == 0 or no report at all |
| 2928 | because TRX was shut down already */ |
| 2929 | if (rx_lvl != 0) { |
| 2930 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2931 | log2str("Detected Tx power: ", |
| 2932 | rx_lvl , " should be 0")); |
| 2933 | } |
| 2934 | |
| 2935 | repeat; |
| 2936 | } |
| 2937 | [] L1CTL.receive { repeat; } |
| 2938 | [] Tdown.timeout { } |
| 2939 | } |
| 2940 | } |
| 2941 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2942 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2943 | 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] | 2944 | f_l1_tune(L1CTL); |
| 2945 | RSL.clear; |
| 2946 | |
| 2947 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2948 | |
| 2949 | setverdict(pass); |
| 2950 | } |
| 2951 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2952 | var ConnHdlr vc_conn; |
| 2953 | var ConnHdlrPars pars; |
| 2954 | f_init(); |
| 2955 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2956 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2957 | pcu_comp := false, trxc_comp := true); |
| 2958 | vc_conn.done; |
| 2959 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2960 | } |
| 2961 | |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 2962 | /* Verify Tx power reduction without ramping down during BTS shutdown due to Abis link failure */ |
| 2963 | private function f_TC_tx_power_down_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2964 | f_connhdlr_init_vty_bsc(); |
| 2965 | |
| 2966 | f_l1_tune(L1CTL); |
| 2967 | RSL.clear; |
| 2968 | |
| 2969 | /* Wait until BTS is started and at full power */ |
| 2970 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2971 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2972 | |
| 2973 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 2974 | f_verify_power_down(max_rx_lvl); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2975 | |
| 2976 | setverdict(pass); |
| 2977 | } |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 2978 | testcase TC_tx_power_down_bcch() runs on test_CT { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2979 | var ConnHdlr vc_conn; |
| 2980 | var ConnHdlrPars pars; |
| 2981 | f_init(); |
| 2982 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 2983 | vc_conn := f_start_handler(refers(f_TC_tx_power_down_bcch), pars, |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2984 | pcu_comp := false, trxc_comp := true); |
| 2985 | vc_conn.done; |
| 2986 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2987 | } |
| 2988 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2989 | /* Verify Tx power: |
| 2990 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2991 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2992 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2993 | 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] | 2994 | var L1ctlDlMessage l1_dl; |
| 2995 | var integer last_rx_lvl; |
| 2996 | |
| 2997 | f_connhdlr_init_vty_bsc(); |
| 2998 | |
| 2999 | f_l1_tune(L1CTL); |
| 3000 | RSL.clear; |
| 3001 | |
| 3002 | /* Wait until BTS is started and at full power */ |
| 3003 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 3004 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 3005 | |
| 3006 | log("ADM STATE UNLOCKED->LOCKED"); |
| 3007 | f_vty_enter_cfg_trx(BSCVTY); |
| 3008 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 3009 | last_rx_lvl := max_rx_lvl; |
| 3010 | f_verify_ramp_down(max_rx_lvl); |
| 3011 | |
| 3012 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 3013 | * anymore because scheduler has stopped after ramping down */ |
| 3014 | f_sleep(2.0); |
| 3015 | L1CTL.clear; |
| 3016 | timer Tlocked := 2.0; |
| 3017 | Tlocked.start; |
| 3018 | alt { |
| 3019 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 3020 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3021 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 3022 | } |
| 3023 | [] L1CTL.receive { repeat; } |
| 3024 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 3025 | } |
| 3026 | |
| 3027 | log("ADM STATE LOCKED->UNLOCKED"); |
| 3028 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 3029 | f_verify_ramp_up(); |
| 3030 | setverdict(pass); |
| 3031 | } |
| 3032 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 3033 | var ConnHdlr vc_conn; |
| 3034 | var ConnHdlrPars pars; |
| 3035 | f_init(); |
| 3036 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 3037 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 3038 | pcu_comp := false, trxc_comp := true); |
| 3039 | vc_conn.done; |
| 3040 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3041 | } |
| 3042 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3043 | 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] | 3044 | timer T := 8.0; |
| 3045 | T.start; |
| 3046 | var RSL_Message rsl; |
| 3047 | alt { |
| 3048 | [] as_l1_sacch(); |
| 3049 | [] L1CTL.receive { repeat; } |
| 3050 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 3051 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 3052 | setverdict(pass) |
| 3053 | } else { |
| 3054 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 3055 | } |
| 3056 | } |
| 3057 | [] T.timeout { |
| 3058 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 3059 | } |
| 3060 | } |
| 3061 | } |
| 3062 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3063 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 3064 | * set _during_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3065 | 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] | 3066 | f_l1_tune(L1CTL); |
| 3067 | RSL.clear; |
| 3068 | |
| 3069 | if (mp_bts_trxc_port != -1) { |
| 3070 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 3071 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 3072 | } |
| 3073 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 3074 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3075 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 3076 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 3077 | |
| 3078 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3079 | |
| 3080 | f_check_meas_bs_power_level(pwr_var); |
| 3081 | |
| 3082 | f_rsl_chan_deact(); |
| 3083 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3084 | } |
| 3085 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3086 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 3087 | * set _after_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3088 | 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] | 3089 | f_l1_tune(L1CTL); |
| 3090 | RSL.clear; |
| 3091 | |
| 3092 | if (mp_bts_trxc_port != -1) { |
| 3093 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 3094 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 3095 | } |
| 3096 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 3097 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3098 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 3099 | |
| 3100 | f_est_dchan(); |
| 3101 | |
| 3102 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 3103 | |
| 3104 | f_check_meas_bs_power_level(pwr_var); |
| 3105 | |
| 3106 | f_rsl_chan_deact(); |
| 3107 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3108 | } |
| 3109 | |
| 3110 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 3111 | var ConnHdlr vc_conn; |
| 3112 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3113 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3114 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3115 | |
| 3116 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 3117 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 3118 | pcu_comp := false, trxc_comp := true); |
| 3119 | vc_conn.done; |
| 3120 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3121 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3122 | } |
| 3123 | |
| 3124 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 3125 | var ConnHdlr vc_conn; |
| 3126 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3127 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3128 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3129 | |
| 3130 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 3131 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 3132 | pcu_comp := false, trxc_comp := true); |
| 3133 | vc_conn.done; |
| 3134 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3135 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3136 | } |
| 3137 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3138 | /* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 3139 | * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds. |
| 3140 | * 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] | 3141 | 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] | 3142 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3143 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3144 | |
| 3145 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3146 | f_l1_tune(L1CTL); |
| 3147 | RSL.clear; |
| 3148 | |
| 3149 | var RSL_IE_List addl_ies; |
| 3150 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3151 | |
| 3152 | addl_ies := { |
| 3153 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3154 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3155 | }; |
| 3156 | |
| 3157 | /* establish with power parameters */ |
| 3158 | f_est_dchan(more_ies := addl_ies); |
| 3159 | |
| 3160 | /* set a high value to ensure L1 power control level increases */ |
| 3161 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 3162 | |
| 3163 | timer T2 := 6.0; |
| 3164 | T2.start; |
| 3165 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3166 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3167 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3168 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3169 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3170 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 3171 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3172 | T2.stop; |
| 3173 | } |
| 3174 | [] L1CTL.receive { repeat; } |
| 3175 | [] T2.timeout { |
| 3176 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3177 | "Power Level in L1 header has not increased sufficiently"); |
| 3178 | } |
| 3179 | } |
| 3180 | |
| 3181 | /* set a low value to ensure L1 power control level decreases */ |
| 3182 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 3183 | |
| 3184 | timer T4 := 6.0; |
| 3185 | T4.start; |
| 3186 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3187 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3188 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3189 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3190 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3191 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 3192 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3193 | T4.stop; |
| 3194 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 3195 | } |
| 3196 | [] L1CTL.receive { repeat; } |
| 3197 | [] T4.timeout { |
| 3198 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3199 | "Power Level in L1 header has not decreased sufficiently"); |
| 3200 | } |
| 3201 | } |
| 3202 | |
| 3203 | f_rsl_chan_deact(); |
| 3204 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3205 | |
| 3206 | } |
| 3207 | |
| 3208 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3209 | 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] | 3210 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3211 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3212 | |
| 3213 | /* set a low value to ensure power increases */ |
| 3214 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3215 | f_l1_tune(L1CTL); |
| 3216 | RSL.clear; |
| 3217 | |
| 3218 | var RSL_IE_List addl_ies; |
| 3219 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3220 | |
| 3221 | addl_ies := { |
| 3222 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3223 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3224 | }; |
| 3225 | |
| 3226 | /* establish with power parameters */ |
| 3227 | f_est_dchan(more_ies := addl_ies); |
| 3228 | |
| 3229 | timer T1 := 10.0; |
| 3230 | T1.start; |
| 3231 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3232 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3233 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3234 | repeat; |
| 3235 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3236 | [] L1CTL.receive { repeat; } |
| 3237 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3238 | if (not isbound(l1h)) { |
| 3239 | setverdict(fail, "No SACCH blocks were received"); |
| 3240 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3241 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 3242 | } |
| 3243 | } |
| 3244 | } |
| 3245 | |
| 3246 | f_rsl_chan_deact(); |
| 3247 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3248 | |
| 3249 | } |
| 3250 | |
| 3251 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3252 | 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] | 3253 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3254 | var uint5_t pwr_var := 15; |
| 3255 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 3256 | |
| 3257 | /* set a low value to ensure power increases */ |
| 3258 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3259 | f_l1_tune(L1CTL); |
| 3260 | RSL.clear; |
| 3261 | |
| 3262 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3263 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3264 | |
| 3265 | /* establish with fixed power level */ |
| 3266 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3267 | |
| 3268 | /* check our initial power level */ |
| 3269 | f_wait_for_l1_power_level(pwr_var); |
| 3270 | |
| 3271 | /* update power param to enable power loop |
| 3272 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 3273 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 3274 | |
Vadim Yanitskiy | 93ad814 | 2022-04-08 01:52:13 +0300 | [diff] [blame] | 3275 | /* By default, the MS power loop gets triggered every 4th SACCH block (1.92s). |
| 3276 | * We need 9 * 4 dB steps to get from 0 dBm to 33 dBm, so 9 * 1.92s total. |
| 3277 | * Add an extra offset to avoid race conditions: +1.92s. */ |
| 3278 | timer T1 := 9.0 * 1.92 + 1.92; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3279 | T1.start; |
| 3280 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3281 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3282 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3283 | repeat; |
| 3284 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3285 | [] L1CTL.receive { repeat; } |
| 3286 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3287 | if (not isbound(l1h)) { |
| 3288 | setverdict(fail, "No SACCH blocks were received"); |
| 3289 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3290 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 3291 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3292 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 3293 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3294 | } |
| 3295 | } |
| 3296 | } |
| 3297 | |
| 3298 | f_rsl_chan_deact(); |
| 3299 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3300 | |
| 3301 | } |
| 3302 | |
| 3303 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3304 | 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] | 3305 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3306 | |
| 3307 | /* set a high value to ensure power decreases */ |
| 3308 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3309 | f_l1_tune(L1CTL); |
| 3310 | RSL.clear; |
| 3311 | |
| 3312 | var uint5_t pwr_var := 5; |
| 3313 | var uint5_t pwr_target_val := 15; |
| 3314 | |
| 3315 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3316 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3317 | |
| 3318 | /* establish with fixed power level */ |
| 3319 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3320 | |
| 3321 | /* check our initial power level */ |
| 3322 | f_wait_for_l1_power_level(pwr_var); |
| 3323 | |
| 3324 | /* update power param to enable power loop |
| 3325 | 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] | 3326 | 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] | 3327 | |
| 3328 | /* wait, then check that our power level was increased */ |
| 3329 | timer T1 := 10.0; |
| 3330 | T1.start; |
| 3331 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3332 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3333 | [] L1CTL.receive { repeat; } |
| 3334 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3335 | if (not isbound(l1h)) { |
| 3336 | setverdict(fail, "No SACCH blocks were received"); |
| 3337 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 3338 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3339 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3340 | setverdict(fail, "Power level NOT increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3341 | } |
| 3342 | } |
| 3343 | } |
| 3344 | |
| 3345 | f_rsl_chan_deact(); |
| 3346 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3347 | |
| 3348 | } |
| 3349 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3350 | /* See if the power level remains constant when MS Power Parameters IE |
| 3351 | * is _absent_ in the CHANnel ACTIVation message. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3352 | 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] | 3353 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3354 | |
| 3355 | /* set a high value to ensure power decreases */ |
| 3356 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3357 | f_l1_tune(L1CTL); |
| 3358 | RSL.clear; |
| 3359 | |
| 3360 | var uint5_t pwr_var := 5; |
| 3361 | |
| 3362 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3363 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3364 | |
| 3365 | /* establish with fixed power level */ |
| 3366 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3367 | |
| 3368 | /* check our initial power level */ |
| 3369 | f_wait_for_l1_power_level(pwr_var); |
| 3370 | |
| 3371 | /* wait, then check that our power level did not change */ |
| 3372 | timer T1 := 10.0; |
| 3373 | T1.start; |
| 3374 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3375 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3376 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3377 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3378 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3379 | } |
| 3380 | repeat; |
| 3381 | } |
| 3382 | [] L1CTL.receive { repeat; } |
| 3383 | [] T1.timeout { setverdict(pass); } |
| 3384 | } |
| 3385 | |
| 3386 | f_rsl_chan_deact(); |
| 3387 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3388 | |
| 3389 | } |
| 3390 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3391 | /* See if the power level remains constant when MS Power Parameters IE |
| 3392 | * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3393 | 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] | 3394 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3395 | |
| 3396 | /* set a high value to ensure power decreases */ |
| 3397 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3398 | f_l1_tune(L1CTL); |
| 3399 | RSL.clear; |
| 3400 | |
| 3401 | var uint5_t pwr_var := 5; |
| 3402 | |
| 3403 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3404 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3405 | |
| 3406 | /* establish with fixed power level */ |
| 3407 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3408 | |
| 3409 | /* check our initial power level */ |
| 3410 | f_wait_for_l1_power_level(pwr_var); |
| 3411 | |
| 3412 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 3413 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3414 | |
| 3415 | /* wait, then check that our power level did not change */ |
| 3416 | timer T1 := 10.0; |
| 3417 | T1.start; |
| 3418 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3419 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3420 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3421 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3422 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3423 | } |
| 3424 | repeat; |
| 3425 | } |
| 3426 | [] L1CTL.receive { repeat; } |
| 3427 | [] T1.timeout { setverdict(pass); } |
| 3428 | } |
| 3429 | |
| 3430 | f_rsl_chan_deact(); |
| 3431 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3432 | |
| 3433 | } |
| 3434 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3435 | 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] | 3436 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3437 | timer T0 := 10.0; |
| 3438 | T0.start; |
| 3439 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3440 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3441 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3442 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3443 | "Power level in L1 header != signaled (RSL) power level."); |
| 3444 | } |
| 3445 | } |
| 3446 | [] L1CTL.receive { repeat; } |
| 3447 | [] T0.timeout { |
| 3448 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3449 | "Timeout waiting for initial power level"); |
| 3450 | } |
| 3451 | } |
| 3452 | T0.stop; |
| 3453 | } |
| 3454 | |
| 3455 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3456 | var IntegerRecord min_dbm_level; |
| 3457 | var IntegerRecord max_dbm_level; |
| 3458 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3459 | |
| 3460 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 3461 | if (min_dbm_level[i] == level) { |
| 3462 | return true; |
| 3463 | } |
| 3464 | } |
| 3465 | return false; |
| 3466 | } |
| 3467 | |
| 3468 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3469 | var IntegerRecord min_dbm_level; |
| 3470 | var IntegerRecord max_dbm_level; |
| 3471 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3472 | |
| 3473 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 3474 | if (max_dbm_level[i] == level) { |
| 3475 | return true; |
| 3476 | } |
| 3477 | } |
| 3478 | return false; |
| 3479 | } |
| 3480 | |
| 3481 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 3482 | var IntegerRecord min_dbm_level; |
| 3483 | var IntegerRecord max_dbm_level; |
| 3484 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3485 | return max_dbm_level[0]; |
| 3486 | } |
| 3487 | |
| 3488 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3489 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3490 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 3491 | // 45.005 4.1.1 |
| 3492 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 3493 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 3494 | 2, 1, 0}; |
| 3495 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 3496 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 3497 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 3498 | var IntegerRecord rv; |
| 3499 | |
| 3500 | select(band){ |
| 3501 | case (BtsBand_allGSM){ |
| 3502 | rv := gsm_power; |
| 3503 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 3504 | max_dbm_level := {2, 1, 0}; |
| 3505 | } |
| 3506 | case("DCS1800"){ |
| 3507 | rv := dcs_power; |
| 3508 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 3509 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 3510 | } |
| 3511 | case("PCS1900"){ |
| 3512 | rv := pcs_power; |
| 3513 | min_dbm_level := {15}; |
| 3514 | max_dbm_level := {30}; |
| 3515 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 3516 | case else { |
| 3517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3518 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3519 | } |
| 3520 | |
| 3521 | return rv; |
| 3522 | } |
| 3523 | |
| 3524 | 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] | 3525 | 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] | 3526 | } |
| 3527 | |
| 3528 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3529 | var ConnHdlr vc_conn; |
| 3530 | var ConnHdlrPars pars; |
| 3531 | f_init(); |
| 3532 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3533 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3534 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3535 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3536 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3537 | vc_conn.done; |
| 3538 | } |
| 3539 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3540 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3541 | } |
| 3542 | |
| 3543 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3544 | var ConnHdlr vc_conn; |
| 3545 | var ConnHdlrPars pars; |
| 3546 | f_init(); |
| 3547 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3548 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
Vadim Yanitskiy | c78aeb7 | 2022-07-30 17:56:39 +0700 | [diff] [blame] | 3549 | 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] | 3550 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3551 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3552 | vc_conn.done; |
| 3553 | } |
| 3554 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3555 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3556 | } |
| 3557 | |
| 3558 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3559 | var ConnHdlr vc_conn; |
| 3560 | var ConnHdlrPars pars; |
| 3561 | f_init(); |
| 3562 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3563 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3564 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3565 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3566 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3567 | vc_conn.done; |
| 3568 | } |
| 3569 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3570 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3571 | } |
| 3572 | |
| 3573 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3574 | var ConnHdlr vc_conn; |
| 3575 | var ConnHdlrPars pars; |
| 3576 | f_init(); |
| 3577 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3578 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3579 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3580 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3581 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3582 | vc_conn.done; |
| 3583 | } |
| 3584 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3585 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3586 | } |
| 3587 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3588 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3589 | var ConnHdlr vc_conn; |
| 3590 | var ConnHdlrPars pars; |
| 3591 | f_init(); |
| 3592 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3593 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3594 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3595 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3596 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3597 | vc_conn.done; |
| 3598 | } |
| 3599 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3600 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3601 | } |
| 3602 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3603 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3604 | var ConnHdlr vc_conn; |
| 3605 | var ConnHdlrPars pars; |
| 3606 | f_init(); |
| 3607 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3608 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3609 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3610 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3611 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3612 | vc_conn.done; |
| 3613 | } |
| 3614 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3615 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3616 | } |
| 3617 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3618 | 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] | 3619 | var template RSL_IE_ChannelMode ch_mode; |
| 3620 | var ConnHdlr vc_conn; |
| 3621 | var ConnHdlrPars pars; |
| 3622 | f_init(); |
| 3623 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3624 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3625 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3626 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3627 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3628 | pcu_comp := false, trxc_comp := true); |
| 3629 | vc_conn.done; |
| 3630 | } |
| 3631 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3632 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3633 | |
| 3634 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3635 | f_TC_meas_res_speech_tchf(false); |
| 3636 | } |
| 3637 | |
| 3638 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3639 | f_TC_meas_res_speech_tchf(true); |
| 3640 | } |
| 3641 | |
| 3642 | 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] | 3643 | var template RSL_IE_ChannelMode ch_mode; |
| 3644 | var ConnHdlr vc_conn; |
| 3645 | var ConnHdlrPars pars; |
| 3646 | f_init(); |
| 3647 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3648 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3649 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3650 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3651 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3652 | pcu_comp := false, trxc_comp := true); |
| 3653 | vc_conn.done; |
| 3654 | } |
| 3655 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3656 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3657 | |
| 3658 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3659 | f_TC_meas_res_speech_tchh(false) |
| 3660 | } |
| 3661 | |
| 3662 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3663 | f_TC_meas_res_speech_tchh(true) |
| 3664 | } |
| 3665 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3666 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3667 | var template RSL_IE_ChannelMode ch_mode; |
| 3668 | var ConnHdlr vc_conn; |
| 3669 | var ConnHdlrPars pars; |
| 3670 | f_init(); |
| 3671 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3672 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3673 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3674 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3675 | pars.l1_pars.toa256_enabled := true; |
| 3676 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3677 | pcu_comp := false, trxc_comp := true); |
| 3678 | vc_conn.done; |
| 3679 | } |
| 3680 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3681 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3682 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3683 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3684 | var ConnHdlr vc_conn; |
| 3685 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3686 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3687 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3688 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3689 | 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] | 3690 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3691 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3692 | vc_conn.done; |
| 3693 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3694 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3695 | } |
| 3696 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3697 | var ConnHdlr vc_conn; |
| 3698 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3699 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3700 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3701 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3702 | 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] | 3703 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3704 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3705 | vc_conn.done; |
| 3706 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3707 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3708 | } |
| 3709 | testcase TC_meas_res_sign_sdcch4() 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(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3713 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3714 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3715 | 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] | 3716 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3717 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3718 | vc_conn.done; |
| 3719 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3720 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3721 | } |
| 3722 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3723 | var ConnHdlr vc_conn; |
| 3724 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3725 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3726 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3727 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3728 | 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] | 3729 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3730 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3731 | vc_conn.done; |
| 3732 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3733 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3734 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3735 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3736 | var ConnHdlr vc_conn; |
| 3737 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3738 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3739 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3740 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3741 | 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] | 3742 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3743 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3744 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3745 | vc_conn.done; |
| 3746 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3747 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3748 | } |
| 3749 | |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 3750 | /* Make sure that we always get RSL MEASurement RESult messages regardless |
| 3751 | * of what is sent on SACCH: (RR) Measurement Report or SAPI=3 data (SMS). */ |
| 3752 | private function f_TC_meas_res_sapi3(charstring id) runs on ConnHdlr { |
| 3753 | timer Texec := 8.0; |
| 3754 | timer Timpf := 2.0; |
| 3755 | timer Tmr; |
| 3756 | |
| 3757 | f_l1_tune(L1CTL); |
| 3758 | RSL.clear; |
| 3759 | |
| 3760 | f_est_dchan(); |
| 3761 | L1CTL.clear; |
| 3762 | |
| 3763 | /* Establish the main SAPI=0 link on DCCH first */ |
| 3764 | f_tx_lapdm(ts_LAPDm_SABM(0, cr_MO_CMD, true, ''O), ts_RslLinkID_DCCH(0)); |
| 3765 | |
| 3766 | /* Give more time for the first RSL MEASurement RESult */ |
| 3767 | Tmr.start(0.480 * 2.0); |
| 3768 | Texec.start; /* EXECution timer */ |
| 3769 | Timpf.start; /* IMPFung timer */ |
| 3770 | |
| 3771 | alt { |
| 3772 | /* We expect RSL MEASurement RESult messages every ~480ms (plus some guard) */ |
| 3773 | [] RSL.receive(tr_RSL_MEAS_RES(g_pars.chan_nr)) { |
| 3774 | /* Reschedule the MEAS RES timer */ |
| 3775 | Tmr.start(0.480 + 0.120); |
| 3776 | repeat; |
| 3777 | } |
| 3778 | [] RSL.receive { repeat; } |
| 3779 | [] Tmr.timeout { |
| 3780 | setverdict(fail, "Timeout waiting for RSL MEAS RES"); |
| 3781 | } |
| 3782 | /* Inject some SAPI=3 traffic on SACCH every 2 seconds */ |
| 3783 | [] Timpf.timeout { |
| 3784 | f_tx_lapdm(ts_LAPDm_SABM(3, cr_MO_CMD, true, ''O), ts_RslLinkID_SACCH(3)); |
| 3785 | log("Injected SAPI=3 traffic on SACCH"); |
| 3786 | Timpf.start; |
| 3787 | repeat; |
| 3788 | } |
| 3789 | /* We're good if survived so far */ |
| 3790 | [] Texec.timeout { |
| 3791 | setverdict(pass); |
| 3792 | } |
| 3793 | } |
| 3794 | |
| 3795 | f_rsl_chan_deact(); |
| 3796 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3797 | f_rslem_unregister(0, g_chan_nr); |
| 3798 | } |
| 3799 | testcase TC_meas_res_speech_tchf_sapi3() runs on test_CT { |
| 3800 | var template RSL_IE_ChannelMode ch_mode; |
| 3801 | var template ConnHdlrPars pars; |
| 3802 | var ConnHdlr vc_conn; |
| 3803 | |
| 3804 | f_init(); |
| 3805 | |
| 3806 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3807 | pars := t_Pars(t_RslChanNr_Bm(1), ch_mode); |
| 3808 | |
| 3809 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3810 | vc_conn.done; |
| 3811 | |
| 3812 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3813 | } |
| 3814 | testcase TC_meas_res_speech_tchh_sapi3() runs on test_CT { |
| 3815 | var template RSL_IE_ChannelMode ch_mode; |
| 3816 | var template ConnHdlrPars pars; |
| 3817 | var ConnHdlr vc_conn; |
| 3818 | |
| 3819 | f_init(); |
| 3820 | |
| 3821 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3822 | pars := t_Pars(t_RslChanNr_Lm(5, 0), ch_mode); |
| 3823 | |
| 3824 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3825 | vc_conn.done; |
| 3826 | |
| 3827 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3828 | } |
| 3829 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3830 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3831 | * 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] | 3832 | 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] | 3833 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3834 | var RSL_IE_MS_Power ms_power; |
| 3835 | var RSL_Message rsl; |
| 3836 | var uint5_t power_level := 0; |
| 3837 | |
| 3838 | f_l1_tune(L1CTL); |
| 3839 | RSL.clear; |
| 3840 | |
| 3841 | f_est_dchan(); |
| 3842 | |
| 3843 | ms_power.reserved := 0; |
| 3844 | ms_power.fpc_epc := false; |
| 3845 | |
| 3846 | /* Send the first power control command. This will disable any BTS/TRX |
| 3847 | * internal power control and switch the MS (which is not in scope of |
| 3848 | * this test) to a constant power level. We start with a power level |
| 3849 | * of 0 */ |
| 3850 | ms_power.power_level := power_level; |
| 3851 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3852 | RSL.send(rsl); |
| 3853 | |
| 3854 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3855 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3856 | if (l1h.ms_power_lvl != power_level) { |
| 3857 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3858 | "match the signaled (RSL) power level := ", power_level); |
| 3859 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3860 | } |
| 3861 | |
| 3862 | /* Signal a new power level via RSL for the next turn. */ |
| 3863 | if (power_level < 31) { |
| 3864 | power_level := power_level + 1; |
| 3865 | ms_power.power_level := power_level; |
| 3866 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3867 | RSL.send(rsl); |
| 3868 | repeat; |
| 3869 | } |
| 3870 | |
| 3871 | } |
| 3872 | |
| 3873 | /* Ignore all other blocks */ |
| 3874 | [] L1CTL.receive { repeat; } |
| 3875 | |
| 3876 | } |
| 3877 | |
| 3878 | f_rsl_chan_deact(); |
| 3879 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3880 | |
| 3881 | setverdict(pass); |
| 3882 | } |
| 3883 | |
| 3884 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3885 | var ConnHdlr vc_conn; |
| 3886 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3887 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3888 | |
| 3889 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3890 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3891 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3892 | vc_conn.done; |
| 3893 | } |
| 3894 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3895 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3896 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3897 | /* 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] | 3898 | 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] | 3899 | 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] | 3900 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3901 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3902 | |
| 3903 | f_l1_tune(L1CTL); |
| 3904 | RSL.clear; |
| 3905 | |
| 3906 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3907 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3908 | |
| 3909 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3910 | |
| 3911 | |
| 3912 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3913 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3914 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3915 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 3916 | } |
| 3917 | |
| 3918 | } |
| 3919 | |
| 3920 | /* Ignore all other blocks */ |
| 3921 | [] L1CTL.receive { repeat; } |
| 3922 | |
| 3923 | } |
| 3924 | |
| 3925 | f_rsl_chan_deact(); |
| 3926 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3927 | |
| 3928 | setverdict(pass); |
| 3929 | } |
| 3930 | |
| 3931 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 3932 | var ConnHdlr vc_conn; |
| 3933 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3934 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3935 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3936 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3937 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3938 | vc_conn.done; |
| 3939 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3940 | } |
| 3941 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3942 | /* 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] | 3943 | 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] | 3944 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3945 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3946 | |
| 3947 | var RSL_IE_MS_Power ms_power; |
| 3948 | ms_power.reserved := 0; |
| 3949 | ms_power.fpc_epc := false; |
| 3950 | ms_power.power_level := ms_power_level; |
| 3951 | |
| 3952 | f_l1_tune(L1CTL); |
| 3953 | RSL.clear; |
| 3954 | |
| 3955 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3956 | |
| 3957 | timer T := 1.0; |
| 3958 | T.start; |
| 3959 | alt { |
| 3960 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3961 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3962 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3963 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3964 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3965 | } |
| 3966 | } |
| 3967 | /* Ignore all other blocks */ |
| 3968 | [] L1CTL.receive { repeat; } |
| 3969 | [] T.timeout { |
| 3970 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3971 | } |
| 3972 | } |
| 3973 | |
| 3974 | f_rsl_chan_deact(); |
| 3975 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3976 | setverdict(pass); |
| 3977 | } |
| 3978 | |
| 3979 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3980 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3981 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3982 | } |
| 3983 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3984 | /* 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] | 3985 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3986 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3987 | RSL.clear; |
| 3988 | |
| 3989 | f_est_dchan(); |
| 3990 | f_sleep(2.0); |
Vadim Yanitskiy | 289056c | 2022-12-25 02:07:49 +0700 | [diff] [blame] | 3991 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3992 | f_L1CTL_RESET(L1CTL); |
Vadim Yanitskiy | 6ff06a3 | 2022-11-01 00:01:38 +0700 | [diff] [blame] | 3993 | f_l1_tune(L1CTL); /* tune back to BCCH */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3994 | |
| 3995 | timer T := 40.0; |
| 3996 | T.start; |
| 3997 | alt { |
| 3998 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3999 | setverdict(pass) |
| 4000 | } |
| 4001 | [] RSL.receive { repeat }; |
| 4002 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4003 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 4004 | } |
| 4005 | } |
| 4006 | f_rsl_chan_deact(); |
| 4007 | } |
| 4008 | testcase TC_conn_fail_crit() runs on test_CT { |
| 4009 | var ConnHdlr vc_conn; |
| 4010 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4011 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 4012 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 4013 | pars.t_guard := 60.0; |
| 4014 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 4015 | vc_conn.done; |
| 4016 | } |
| 4017 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4018 | /*********************************************************************** |
| 4019 | * Paging |
| 4020 | ***********************************************************************/ |
| 4021 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4022 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4023 | if (tmsi == 'FFFFFFFF'O) { |
| 4024 | return true; |
| 4025 | } else { |
| 4026 | return false; |
| 4027 | } |
| 4028 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 4029 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4030 | private type record allowedFn { integer frame_nr } |
| 4031 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 4032 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 4033 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 4034 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 4035 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 4036 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 4037 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 4038 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 4039 | 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] | 4040 | { |
| 4041 | var integer frame_nr_51; |
| 4042 | frame_nr_51 := frame_nr mod 51 |
| 4043 | |
| 4044 | var allowedFn fn_check; |
| 4045 | fn_check.frame_nr := frame_nr_51; |
| 4046 | |
| 4047 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4048 | 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] | 4049 | return; |
| 4050 | } |
| 4051 | |
| 4052 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 4053 | return; |
| 4054 | } |
| 4055 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 4056 | return; |
| 4057 | } |
| 4058 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 4059 | return; |
| 4060 | } |
| 4061 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 4062 | return; |
| 4063 | } |
| 4064 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 4065 | return; |
| 4066 | } |
| 4067 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 4068 | return; |
| 4069 | } |
| 4070 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 4071 | return; |
| 4072 | } |
| 4073 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 4074 | return; |
| 4075 | } |
| 4076 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4077 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4078 | return; |
| 4079 | } |
| 4080 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4081 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 4082 | inout integer num_paging_rcv_ids, |
| 4083 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4084 | runs on test_CT { |
| 4085 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4086 | [] 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] | 4087 | repeat; |
| 4088 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4089 | [] 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] | 4090 | var octetstring without_plen := |
| 4091 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 4092 | 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] | 4093 | |
| 4094 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 4095 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 4096 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 4097 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 4098 | * TODO: does it make sense to count them? */ |
| 4099 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4100 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4101 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 4102 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4103 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4104 | } |
| 4105 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 4106 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4107 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 4108 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4109 | } |
| 4110 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 4111 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4112 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 4113 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4114 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4115 | } |
| 4116 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 4117 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4118 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 4119 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4120 | } |
| 4121 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 4122 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4123 | } |
| 4124 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 4125 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4126 | } |
| 4127 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 4128 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4129 | } |
| 4130 | } |
| 4131 | repeat; |
| 4132 | } |
| 4133 | } |
| 4134 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4135 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4136 | boolean combined_ccch, |
| 4137 | integer bs_ag_blks_res, |
| 4138 | float load_factor, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4139 | /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus) |
| 4140 | * paging command that is issued via RSL. */ |
| 4141 | integer ps_load_modulus, |
| 4142 | /* Wait until the paging queue inside the BTS is congested before starting to add |
| 4143 | * pagings via the PCU socket (0 = disabled) */ |
| 4144 | boolean ps_wait_cong, |
| 4145 | /* Maximum time to wait until the paging queue is drained at the end of the test. |
| 4146 | * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended |
| 4147 | * to set this value to 18s, however the draining process may take significantly |
| 4148 | * longer when the queue contains paging requests for PS as those are implemented |
| 4149 | * as immediate assignments and require an entire MAC block alone. */ |
| 4150 | float queue_drain_timeout, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4151 | boolean exp_load_ind, |
| 4152 | boolean exp_overload, |
| 4153 | boolean use_tmsi |
| 4154 | } |
| 4155 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4156 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4157 | integer num_paging_sent, |
| 4158 | integer num_paging_rcv_msgs, |
| 4159 | integer num_paging_rcv_ids, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4160 | integer num_overload, |
| 4161 | /* When free space inside the paging queue reaches more than 2 thirds |
| 4162 | * of its capacity cong_detected is set to true. */ |
| 4163 | boolean cong_detected |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4164 | } |
| 4165 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4166 | /* Helper function for paging related testing */ |
| 4167 | 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] | 4168 | /* Using the PCU socket affects the timing of the paging processing. We only |
| 4169 | * activate the PCU socket if we do paging load tests that include additional |
| 4170 | * paging load that is introduced through the PCU socket. */ |
| 4171 | if (cfg.ps_load_modulus > 0) { |
| 4172 | f_init_with_pcuif(); |
| 4173 | } else { |
| 4174 | f_init(); |
| 4175 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4176 | f_init_l1ctl(); |
| 4177 | f_l1_tune(L1CTL); |
| 4178 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4179 | var octetstring imm_ass := f_rnd_octstring(23); |
| 4180 | var ASP_RSL_Unitdata load_ind; |
| 4181 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4182 | var PagingTestState st := { |
| 4183 | num_paging_sent := 0, |
| 4184 | num_paging_rcv_msgs := 0, |
| 4185 | num_paging_rcv_ids := 0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4186 | num_overload := 0, |
| 4187 | cong_detected := false |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4188 | }; |
| 4189 | |
| 4190 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 4191 | var float max_pch_imsi_per_sec; |
| 4192 | if (cfg.use_tmsi) { |
| 4193 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 4194 | } else { |
| 4195 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 4196 | } |
| 4197 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 4198 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4199 | var float time_total := 20.0; |
| 4200 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 4201 | 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] | 4202 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4203 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 4204 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4205 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4206 | timer T_itv := 0.0; |
| 4207 | T_itv.start; |
| 4208 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4209 | alt { |
| 4210 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4211 | [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] | 4212 | st.num_overload := st.num_overload + 1; |
| 4213 | repeat; |
| 4214 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4215 | [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] | 4216 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4217 | } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4218 | [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] | 4219 | log("Rx LOAD_IND"); |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4220 | |
| 4221 | /* Detect paging congestion: The logic inside the BTS will diagnose the |
| 4222 | * paging queue as congested when the fill state is more than 66% (which |
| 4223 | * is two thirds fill state, or approx. 66 of 200 paging slots. When a |
| 4224 | * paging congestion is detected pagings that are issued through the PCU |
| 4225 | * socket (PS) are dropped in order to prefer the CS related pagings. */ |
| 4226 | if (load_ind.rsl.ies[1].body.paging_load < 66) { |
| 4227 | st.cong_detected := true; |
| 4228 | } |
| 4229 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4230 | /* FIXME: analyze/verify interval + contents */ |
| 4231 | repeat; |
| 4232 | } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4233 | /* ignore other RSL messages like RF RESource INDication */ |
| 4234 | [] RSL_CCHAN.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4235 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4236 | [] 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] | 4237 | [] L1CTL.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4238 | /* Only relevant when testing including with PCU sock connected */ |
| 4239 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4240 | [] T_itv.timeout { |
| 4241 | /* Send paging cmds based on elapsed time */ |
| 4242 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 4243 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4244 | var MobileIdentityV mi; |
| 4245 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4246 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4247 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4248 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4249 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4250 | 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] | 4251 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4252 | |
| 4253 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4254 | 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] | 4255 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4256 | /* Add additional pagings through the PCU socket interface. */ |
| 4257 | if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) { |
| 4258 | if (st.cong_detected == true or cfg.ps_wait_cong == false) { |
| 4259 | f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false); |
| 4260 | } |
| 4261 | } |
| 4262 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4263 | st.num_paging_sent := st.num_paging_sent + 1; |
| 4264 | } |
| 4265 | if (st.num_paging_sent < pkt_total) { |
| 4266 | /* Wait for interval to next PAGING COMMAND */ |
| 4267 | var float time_now := T_total.read; |
| 4268 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 4269 | if (next_sched > time_now) { |
| 4270 | T_itv.start(next_sched - time_now); |
| 4271 | } else { |
| 4272 | T_itv.start(0.0); |
| 4273 | } |
| 4274 | } else { |
| 4275 | /* We are done, no need to keep counting */ |
| 4276 | T_total.stop; |
| 4277 | } |
| 4278 | } |
| 4279 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4280 | } |
| 4281 | } |
| 4282 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4283 | timer T_wait := cfg.queue_drain_timeout |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4284 | T_wait.start; |
| 4285 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4286 | [] 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] | 4287 | [] L1CTL.receive { repeat; } |
| 4288 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4289 | [] 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] | 4290 | [] 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] | 4291 | /* ignore other RSL messages like RF RESource INDication */ |
| 4292 | [] RSL_CCHAN.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4293 | /* Only relevant when testing including with PCU sock connected */ |
| 4294 | [] PCU.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4295 | [] T_wait.timeout { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4296 | 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] | 4297 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4298 | } |
| 4299 | |
| 4300 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 4301 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 4302 | return st; |
| 4303 | } |
| 4304 | |
| 4305 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 4306 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4307 | * - that CCCH LOAD IND (PCH) are being generated |
| 4308 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4309 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4310 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4311 | var PagingTestCfg cfg := { |
| 4312 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4313 | 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] | 4314 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4315 | ps_load_modulus := 0, |
| 4316 | ps_wait_cong := false, |
| 4317 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4318 | exp_load_ind := true, |
| 4319 | exp_overload := false, |
| 4320 | use_tmsi := false |
| 4321 | }; |
| 4322 | var PagingTestState st := f_TC_paging(cfg); |
| 4323 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4324 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4325 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4326 | } else { |
| 4327 | setverdict(pass); |
| 4328 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4329 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4330 | } |
| 4331 | |
| 4332 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 4333 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4334 | * - that CCCH LOAD IND (PCH) are being generated |
| 4335 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4336 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4337 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4338 | var PagingTestCfg cfg := { |
| 4339 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4340 | 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] | 4341 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4342 | ps_load_modulus := 0, |
| 4343 | ps_wait_cong := false, |
| 4344 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4345 | exp_load_ind := true, |
| 4346 | exp_overload := false, |
| 4347 | use_tmsi := true |
| 4348 | }; |
| 4349 | var PagingTestState st := f_TC_paging(cfg); |
| 4350 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4351 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4352 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4353 | } else { |
| 4354 | setverdict(pass); |
| 4355 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4356 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 4360 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4361 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4362 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4363 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4364 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4365 | var PagingTestCfg cfg := { |
| 4366 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4367 | 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] | 4368 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4369 | ps_load_modulus := 0, |
| 4370 | ps_wait_cong := false, |
| 4371 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4372 | exp_load_ind := true, |
| 4373 | exp_overload := true, |
| 4374 | use_tmsi := false |
| 4375 | }; |
| 4376 | var PagingTestState st := f_TC_paging(cfg); |
| 4377 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4378 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4379 | 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] | 4380 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4381 | 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] | 4382 | } else { |
| 4383 | setverdict(pass); |
| 4384 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4385 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4386 | } |
| 4387 | |
| 4388 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 4389 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4390 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4391 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4392 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4393 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4394 | var PagingTestCfg cfg := { |
| 4395 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4396 | 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] | 4397 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4398 | ps_load_modulus := 0, |
| 4399 | ps_wait_cong := false, |
| 4400 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4401 | exp_load_ind := true, |
| 4402 | exp_overload := true, |
| 4403 | use_tmsi := true |
| 4404 | }; |
| 4405 | var PagingTestState st := f_TC_paging(cfg); |
| 4406 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 4407 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4408 | 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] | 4409 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4410 | 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] | 4411 | } else { |
| 4412 | setverdict(pass); |
| 4413 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4414 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4415 | } |
| 4416 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4417 | /* Same as above, but with additional paging load created by PS pagings that |
| 4418 | * are issued through the PCU socket. The additional load is introduced when |
| 4419 | * the paging queue is already two thirds full. Since the BTS implements a |
| 4420 | * prioritization logic that drops the pagings from the PCU under in those |
| 4421 | * congestive sitautions the behaviour on the PS side is expected to be |
| 4422 | * unaffected and match the behavior of TC_paging_imsi_200percent() */ |
| 4423 | testcase TC_paging_imsi_200percent_with_ps() runs on test_CT { |
| 4424 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 4425 | var PagingTestCfg cfg := { |
| 4426 | combined_ccch := true, |
| 4427 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
| 4428 | load_factor := 2.0, |
| 4429 | ps_load_modulus := 16, |
| 4430 | ps_wait_cong := true, |
| 4431 | queue_drain_timeout := 18.0, |
| 4432 | exp_load_ind := true, |
| 4433 | exp_overload := true, |
| 4434 | use_tmsi := false |
| 4435 | }; |
| 4436 | var PagingTestState st := f_TC_paging(cfg); |
| 4437 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4438 | * slots and will fully drain that buffer before returning */ |
| 4439 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
| 4440 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 4441 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
| 4442 | } else { |
| 4443 | setverdict(pass); |
| 4444 | } |
| 4445 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4446 | } |
| 4447 | |
| 4448 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4449 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4450 | /*********************************************************************** |
| 4451 | * Immediate Assignment / AGCH |
| 4452 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 4453 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4454 | len := 0, |
| 4455 | ma := ''B |
| 4456 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4457 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4458 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 4459 | return int2str(num_tx) & " sent, " |
| 4460 | & int2str(num_rx) & " received, " |
| 4461 | & int2str(num_del) & " deleted"; |
| 4462 | } |
| 4463 | |
| 4464 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 4465 | var L1ctlDlMessage l1_dl; |
| 4466 | timer T := 10.0; |
| 4467 | var integer num_tx := 0; |
| 4468 | var integer num_rx := 0; |
| 4469 | var integer num_del := 0; |
| 4470 | var charstring res_str; |
| 4471 | var float rx_ratio; |
| 4472 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4473 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4474 | f_init_l1ctl(); |
| 4475 | f_l1_tune(L1CTL); |
| 4476 | |
| 4477 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 4478 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 4479 | mp_trx_pars[0].arfcn, |
| 4480 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4481 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 4482 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4483 | 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] | 4484 | num_tx := num_tx+1; |
| 4485 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4486 | } |
| 4487 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4488 | T.start; |
| 4489 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4490 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4491 | num_del := num_del+1; |
| 4492 | repeat; |
| 4493 | } |
| 4494 | [] RSL_CCHAN.receive { |
| 4495 | repeat; |
| 4496 | } |
| 4497 | [] 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] | 4498 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 4499 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 4500 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4501 | //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] | 4502 | } else { |
| 4503 | num_rx := num_rx+1; |
| 4504 | } |
| 4505 | repeat; |
| 4506 | } |
| 4507 | [] L1CTL.receive { repeat; } |
| 4508 | [] T.timeout { } |
| 4509 | } |
| 4510 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 4511 | log("AGCH test: " & res_str); |
| 4512 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4513 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4514 | } |
| 4515 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 4516 | 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] | 4517 | 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] | 4518 | } else { |
| 4519 | setverdict(pass); |
| 4520 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4521 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4522 | } |
| 4523 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4524 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 4525 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 4526 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 4527 | } |
| 4528 | |
| 4529 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 4530 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 4531 | f_TC_imm_ass(200, 0.0, 0.05); |
| 4532 | } |
| 4533 | |
| 4534 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 4535 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 4536 | f_TC_imm_ass(150, 0.076, 1.00); |
| 4537 | } |
| 4538 | |
| 4539 | |
| 4540 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4541 | /*********************************************************************** |
| 4542 | * BCCH |
| 4543 | ***********************************************************************/ |
| 4544 | |
| 4545 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4546 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4547 | GsmFrameNumber frame_number, |
| 4548 | SystemInformation si |
| 4549 | } |
| 4550 | |
| 4551 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4552 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4553 | |
| 4554 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4555 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4556 | |
| 4557 | /* 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] | 4558 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 4559 | RrMessageType key, |
| 4560 | boolean bcch_ext := false) |
| 4561 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4562 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4563 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4564 | if (not bcch_ext and fn_mod51 == 2 or |
| 4565 | bcch_ext and fn_mod51 == 6) { |
| 4566 | if (arr[i].si.header.message_type == key) { |
| 4567 | return true; |
| 4568 | } |
| 4569 | } |
| 4570 | } |
| 4571 | return false; |
| 4572 | } |
| 4573 | |
| 4574 | /* 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] | 4575 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4576 | integer tc, RrMessageType key, |
| 4577 | boolean ext_bcch := false) |
| 4578 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4579 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4580 | 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] | 4581 | } |
| 4582 | } |
| 4583 | |
| 4584 | /* 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] | 4585 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4586 | RrMessageType key) |
| 4587 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4588 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 4589 | if (f_si_vecslot_contains(arr[tc], key) or |
| 4590 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 4591 | return true; |
| 4592 | } |
| 4593 | } |
| 4594 | return false; |
| 4595 | } |
| 4596 | |
| 4597 | /* 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] | 4598 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 4599 | RrMessageType key, |
| 4600 | boolean bcch_ext := false, |
| 4601 | integer n := 1, integer m := 4) |
| 4602 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4603 | var integer count := 0; |
| 4604 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 4605 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 4606 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4607 | } |
| 4608 | for (var integer i:= 0; i < m; i := i + 1) { |
| 4609 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4610 | if (not bcch_ext and fn_mod51 == 2 or |
| 4611 | bcch_ext and fn_mod51 == 6) { |
| 4612 | if (arr[i].si.header.message_type == key) { |
| 4613 | count := count + 1; |
| 4614 | } |
| 4615 | } |
| 4616 | } |
| 4617 | if (count >= n) { |
| 4618 | return true; |
| 4619 | } else { |
| 4620 | return false; |
| 4621 | } |
| 4622 | } |
| 4623 | |
| 4624 | /* 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] | 4625 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 4626 | integer tc, RrMessageType key, |
| 4627 | boolean ext_bcch := false, |
| 4628 | integer n, integer m) |
| 4629 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4630 | 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] | 4631 | 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] | 4632 | } |
| 4633 | } |
| 4634 | |
| 4635 | /* 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] | 4636 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 4637 | RrMessageType key, |
| 4638 | boolean bcch_ext := false) |
| 4639 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4640 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4641 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4642 | if (not bcch_ext and fn_mod51 == 2 or |
| 4643 | bcch_ext and fn_mod51 == 6) { |
| 4644 | if (arr[i].si.header.message_type != key) { |
| 4645 | return false; |
| 4646 | } |
| 4647 | } |
| 4648 | } |
| 4649 | return true; |
| 4650 | } |
| 4651 | |
| 4652 | /* 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] | 4653 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 4654 | integer tc, RrMessageType key, |
| 4655 | boolean ext_bcch := false) |
| 4656 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4657 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4658 | 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] | 4659 | } |
| 4660 | } |
| 4661 | |
| 4662 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4663 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4664 | boolean bcch_extended, |
| 4665 | boolean si1_present, |
| 4666 | boolean si2bis_present, |
| 4667 | boolean si2ter_present, |
| 4668 | boolean si2quater_present, |
| 4669 | boolean si7_present, |
| 4670 | boolean si8_present, |
| 4671 | boolean si9_present, |
| 4672 | boolean si13_present, |
| 4673 | boolean si13alt_present, |
| 4674 | boolean si15_present, |
| 4675 | boolean si16_present, |
| 4676 | boolean si17_present, |
| 4677 | boolean si2n_present, |
| 4678 | boolean si21_present, |
| 4679 | boolean si22_present |
| 4680 | } |
| 4681 | |
| 4682 | /* 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] | 4683 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 4684 | SystemInformationVectorPerTc si_per_tc) |
| 4685 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4686 | var integer i; |
| 4687 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 4688 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4689 | 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] | 4690 | } |
| 4691 | } |
| 4692 | if (cfg.si1_present) { |
| 4693 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 4694 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 4695 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 4696 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4697 | /* make sure *ALL* contain SI1 */ |
| 4698 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4699 | } |
| 4700 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4701 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4702 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4703 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4704 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4705 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4706 | |
| 4707 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4708 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4709 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4710 | * consecutive occurrences of TC = 4. */ |
| 4711 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4712 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4713 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4714 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4715 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4716 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4717 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4718 | } |
| 4719 | |
| 4720 | if (cfg.si7_present or cfg.si8_present) { |
| 4721 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4722 | * if System Information type 4 does not contain all information needed for cell |
| 4723 | * selection and reselection. */ |
| 4724 | if (not cfg.bcch_extended) { |
| 4725 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4726 | } |
| 4727 | if (cfg.si7_present) { |
| 4728 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4729 | } |
| 4730 | if (cfg.si8_present) { |
| 4731 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4732 | } |
| 4733 | } |
| 4734 | |
| 4735 | if (cfg.si2quater_present) { |
| 4736 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4737 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4738 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4739 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4740 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4741 | if (not (cfg.bcch_extended)) { |
| 4742 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4743 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4744 | } else { |
| 4745 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4746 | } |
| 4747 | } else { |
| 4748 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4749 | } |
| 4750 | } |
| 4751 | if (cfg.si9_present) { |
| 4752 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4753 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4754 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4755 | } |
| 4756 | if (cfg.si13_present) { |
| 4757 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4758 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4759 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4760 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4761 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4762 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4763 | if (not cfg.bcch_extended) { |
| 4764 | log("not-bccch-extended"); |
| 4765 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4766 | } else { |
| 4767 | log("bccch-extended"); |
| 4768 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4769 | } |
| 4770 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4771 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4772 | } |
| 4773 | } |
| 4774 | if (cfg.si16_present or cfg.si17_present) { |
| 4775 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4776 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4777 | if (cfg.si22_present) { |
| 4778 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4779 | } |
| 4780 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4781 | 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] | 4782 | } |
| 4783 | if (not cfg.bcch_extended) { |
| 4784 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4785 | } |
| 4786 | if (cfg.si16_present) { |
| 4787 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4788 | } |
| 4789 | if (cfg.si17_present) { |
| 4790 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4791 | } |
| 4792 | } |
| 4793 | |
| 4794 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4795 | * broadcast information. The frequency with which they are sent is determined by the |
| 4796 | * system operator. System Information type 9 identifies the scheduling of System |
| 4797 | * Information type 18 and 20 messages. */ |
| 4798 | |
| 4799 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4800 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4801 | * Information Type 9. */ |
| 4802 | |
| 4803 | if (cfg.si15_present) { |
| 4804 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4805 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4806 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4807 | * 4 consecutive occurrences of TC = 1. */ |
| 4808 | if (not cfg.bcch_extended) { |
| 4809 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4810 | } else { |
| 4811 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4812 | } |
| 4813 | } |
| 4814 | if (cfg.si13alt_present) { |
| 4815 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4816 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4817 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4818 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4819 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4820 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4821 | * of TC = 4. */ |
| 4822 | if (cfg.si13_present) { |
| 4823 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4824 | } |
| 4825 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4826 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4827 | } |
| 4828 | if (not cfg.bcch_extended) { |
| 4829 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4830 | } else { |
| 4831 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4832 | } |
| 4833 | } |
| 4834 | if (cfg.si2n_present) { |
| 4835 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4836 | * as determined by the system operator. In the case that the message is sent on the |
| 4837 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4838 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4839 | * consecutive occurrences of TC = 4. */ |
| 4840 | if (not cfg.bcch_extended) { |
| 4841 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4842 | } else { |
| 4843 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4844 | } |
| 4845 | } |
| 4846 | if (cfg.si21_present) { |
| 4847 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4848 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4849 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4850 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4851 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4852 | if (not cfg.bcch_extended) { |
| 4853 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4854 | } else { |
| 4855 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4856 | 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] | 4857 | 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] | 4858 | } |
| 4859 | } |
| 4860 | } |
| 4861 | if (cfg.si22_present) { |
| 4862 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4863 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4864 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4865 | * =2 and TC=6. */ |
| 4866 | if (cfg.si16_present or cfg.si17_present) { |
| 4867 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4868 | } |
| 4869 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4870 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4871 | 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] | 4872 | } |
| 4873 | if (not cfg.bcch_extended) { |
| 4874 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4875 | } else { |
| 4876 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4877 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4878 | } |
| 4879 | } |
| 4880 | } |
| 4881 | |
| 4882 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4883 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4884 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4885 | timer T := duration; |
| 4886 | var SystemInformationVectorPerTc si_per_tc; |
| 4887 | var L1ctlDlMessage l1_dl; |
| 4888 | |
| 4889 | /* initialize all per-TC vectors empty */ |
| 4890 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4891 | si_per_tc[i] := {}; |
| 4892 | } |
| 4893 | |
| 4894 | /* flush all previous L1 queued msgs */ |
| 4895 | pt.clear; |
| 4896 | |
| 4897 | T.start; |
| 4898 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4899 | [] 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] | 4900 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4901 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4902 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4903 | repeat; |
| 4904 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4905 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4906 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4907 | log("SI received at TC=", tc, ": ", sig.si); |
| 4908 | /* append to the per-TC bucket */ |
| 4909 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4910 | repeat; |
| 4911 | } |
| 4912 | [] pt.receive { repeat; } |
| 4913 | [] T.timeout { } |
| 4914 | } |
| 4915 | |
| 4916 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4917 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4918 | } |
| 4919 | log("si_per_tc=", si_per_tc); |
| 4920 | return si_per_tc; |
| 4921 | } |
| 4922 | |
| 4923 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4924 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4925 | 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] | 4926 | var SystemInformationVectorPerTc si_per_tc; |
| 4927 | f_init_l1ctl(); |
| 4928 | f_l1_tune(L1CTL); |
| 4929 | |
| 4930 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4931 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4932 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4933 | |
| 4934 | setverdict(pass); |
| 4935 | } |
| 4936 | |
| 4937 | testcase TC_si_sched_default() runs on test_CT { |
| 4938 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4939 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4940 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4941 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4942 | } |
| 4943 | |
| 4944 | testcase TC_si_sched_1() runs on test_CT { |
| 4945 | f_init(); |
| 4946 | si_cfg.si1_present := true; |
| 4947 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4948 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4949 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4950 | } |
| 4951 | |
| 4952 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4953 | f_init(); |
| 4954 | si_cfg.si2bis_present := true; |
| 4955 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4956 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4957 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4958 | } |
| 4959 | |
| 4960 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4961 | f_init(); |
| 4962 | si_cfg.si2ter_present := true; |
| 4963 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4964 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4965 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4966 | } |
| 4967 | |
| 4968 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4969 | f_init(); |
| 4970 | si_cfg.si2bis_present := true; |
| 4971 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4972 | si_cfg.si2ter_present := true; |
| 4973 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4974 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4975 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4976 | } |
| 4977 | |
| 4978 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4979 | f_init(); |
| 4980 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4981 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4982 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4983 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4984 | } |
| 4985 | |
| 4986 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4987 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4988 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4989 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4990 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4991 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4992 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4993 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4994 | } |
| 4995 | |
| 4996 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4997 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4998 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4999 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 5000 | si_cfg.si2bis_present := true; |
| 5001 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 5002 | si_cfg.si2ter_present := true; |
| 5003 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 5004 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 5005 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 5006 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 5007 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 5008 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5009 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 5010 | } |
| 5011 | |
| 5012 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5013 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5014 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5015 | /* FIXME: enable / disable individual BCCH info */ |
| 5016 | //ts_RSL_BCCH_INFO(si_type, info); |
| 5017 | /* expect no ERROR REPORT after either of them * |
| 5018 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5019 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5020 | } |
| 5021 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 5022 | /*********************************************************************** |
| 5023 | * Low-Level Protocol Errors / ERROR REPORT |
| 5024 | ***********************************************************************/ |
| 5025 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5026 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 5027 | timer T := 5.0; |
| 5028 | T.start; |
| 5029 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5030 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5031 | setverdict(pass); |
| 5032 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5033 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5034 | 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] | 5035 | } |
| 5036 | [] RSL_CCHAN.receive { |
| 5037 | repeat; |
| 5038 | } |
| 5039 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5040 | 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] | 5041 | } |
| 5042 | } |
| 5043 | } |
| 5044 | |
| 5045 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 5046 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5047 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5048 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5049 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5050 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5051 | |
| 5052 | f_exp_err_rep(RSL_ERR_PROTO); |
| 5053 | } |
| 5054 | |
| 5055 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 5056 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5057 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5058 | |
| 5059 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5060 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5061 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5062 | |
| 5063 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 5064 | } |
| 5065 | |
| 5066 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 5067 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5068 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5069 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5070 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5071 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5072 | |
| 5073 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 5074 | } |
| 5075 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5076 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 5077 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 5078 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 5079 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 5080 | RSL.send(rsl); |
| 5081 | f_rslem_unregister(0, g_chan_nr); |
| 5082 | } |
| 5083 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 5084 | var ConnHdlr vc_conn; |
| 5085 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5086 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5087 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5088 | |
| 5089 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 5090 | vc_conn.done; |
| 5091 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 5092 | |
| 5093 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5094 | } |
| 5095 | |
| 5096 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5097 | 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] | 5098 | var template (value) RSL_Message rsl_tx; |
| 5099 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 5100 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 5101 | RSL.send(rsl_tx); |
| 5102 | f_rslem_unregister(0, g_chan_nr); |
| 5103 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5104 | 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] | 5105 | var template (value) RSL_Message rsl_tx; |
| 5106 | /* we first have to activate the dedicated channel */ |
| 5107 | f_rsl_chan_act(g_pars.chan_mode); |
| 5108 | /* ... to then send an invalid RLL message */ |
| 5109 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 5110 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 5111 | RSL.send(rsl_tx); |
| 5112 | f_rslem_unregister(0, g_chan_nr); |
| 5113 | } |
| 5114 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 5115 | var ConnHdlr vc_conn; |
| 5116 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5117 | var template (value) RSL_Message rsl_tx; |
| 5118 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5119 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5120 | |
| 5121 | /* Common Channel with wrong message type */ |
| 5122 | RSL_CCHAN.clear; |
| 5123 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5124 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5125 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5126 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5127 | |
| 5128 | /* TRX Management */ |
| 5129 | RSL_CCHAN.clear; |
| 5130 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 5131 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5132 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5133 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5134 | |
| 5135 | /* Dedicated Channel */ |
| 5136 | RSL_CCHAN.clear; |
| 5137 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 5138 | vc_conn.done; |
| 5139 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5140 | |
| 5141 | /* RLL */ |
| 5142 | RSL_CCHAN.clear; |
| 5143 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 5144 | vc_conn.done; |
| 5145 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5146 | } |
| 5147 | |
| 5148 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5149 | 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] | 5150 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 5151 | f_rslem_unregister(0, g_chan_nr); |
| 5152 | } |
| 5153 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 5154 | var ConnHdlr vc_conn; |
| 5155 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5156 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5157 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5158 | |
| 5159 | RSL_CCHAN.clear; |
| 5160 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 5161 | vc_conn.done; |
| 5162 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 5163 | } |
| 5164 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 5165 | /*********************************************************************** |
| 5166 | * IPA CRCX/MDCX/DLCS media stream handling |
| 5167 | ***********************************************************************/ |
| 5168 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5169 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5170 | 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] | 5171 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5172 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5173 | } |
| 5174 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 5175 | 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] | 5176 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5177 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 5178 | vc_conn.done; |
| 5179 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5180 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5181 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5182 | 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] | 5183 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5184 | "IPA CRCX ACK"); |
| 5185 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 5186 | "IPA CRCX NACK"); |
| 5187 | } |
| 5188 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 5189 | 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] | 5190 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5191 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 5192 | vc_conn.done; |
| 5193 | } |
| 5194 | |
| 5195 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5196 | 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] | 5197 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5198 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5199 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5200 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5201 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5202 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5203 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5204 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5205 | "IPA MDCX ACK"); |
| 5206 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5207 | "IPA DLCX ACK"); |
| 5208 | } |
| 5209 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5210 | 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] | 5211 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5212 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 5213 | vc_conn.done; |
| 5214 | } |
| 5215 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5216 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5217 | 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] | 5218 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5219 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5220 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5221 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5222 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5223 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5224 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5225 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5226 | "IPA MDCX ACK"); |
| 5227 | /* Second MDCX */ |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5228 | remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5229 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 5230 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5231 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5232 | "IPA MDCX ACK"); |
| 5233 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5234 | "IPA DLCX ACK"); |
| 5235 | } |
| 5236 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5237 | 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] | 5238 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5239 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 5240 | vc_conn.done; |
| 5241 | } |
| 5242 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5243 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5244 | 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] | 5245 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 5246 | "IPA CRCX NACK"); |
| 5247 | } |
| 5248 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 5249 | var ConnHdlrPars pars; |
| 5250 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5251 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5252 | |
| 5253 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 5254 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5255 | vc_conn.done; |
| 5256 | |
| 5257 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 5258 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5259 | vc_conn.done; |
| 5260 | } |
| 5261 | |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 5262 | /* Make sure that CRCX ACK contains a valid listen address (see OS#5242) */ |
| 5263 | private function f_TC_ipa_crcx_ack_addr(charstring id) runs on ConnHdlr { |
| 5264 | var OCT4 bind_ip := f_inet_addr("192.168.1.1"); |
| 5265 | var PortNumber bind_port := 16811; |
| 5266 | var RSL_Message crcx_ack; |
| 5267 | |
| 5268 | crcx_ack := f_rsl_transceive_ret(ts_RSL_IPA_CRCX(g_chan_nr, bind_ip, bind_port), |
| 5269 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5270 | "IPA CRCX ACK"); |
| 5271 | var HostName bts_bind_ip := f_inet_ntoa(crcx_ack.ies[2].body.ipa_local_ip); |
| 5272 | if (match(bts_bind_ip, "0.0.0.0")) { |
| 5273 | setverdict(fail, "CRCX ACK indicates nonsense addr ", bts_bind_ip); |
| 5274 | } |
| 5275 | |
| 5276 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 5277 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, conn_id), |
| 5278 | tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5279 | "IPA DLCX ACK"); |
| 5280 | } |
| 5281 | testcase TC_ipa_crcx_ack_addr() runs on test_CT { |
| 5282 | var ConnHdlrPars pars; |
| 5283 | var ConnHdlr vc_conn; |
| 5284 | f_init(); |
| 5285 | |
| 5286 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 5287 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5288 | vc_conn.done; |
| 5289 | |
| 5290 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 5291 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5292 | vc_conn.done; |
| 5293 | } |
| 5294 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5295 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5296 | /*********************************************************************** |
| 5297 | * PCU Socket related tests |
| 5298 | ***********************************************************************/ |
| 5299 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5300 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5301 | 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] | 5302 | runs on test_CT { |
| 5303 | timer T := 3.0; |
| 5304 | |
| 5305 | /* we don't expect any RTS.req before PDCH are active */ |
| 5306 | T.start; |
| 5307 | alt { |
| 5308 | [] 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] | 5309 | 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] | 5310 | } |
| 5311 | [] PCU.receive { repeat; } |
| 5312 | [] T.timeout { } |
| 5313 | } |
| 5314 | |
| 5315 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5316 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 5317 | |
| 5318 | /* we now expect RTS.req for this timeslot (only) */ |
| 5319 | T.start; |
| 5320 | alt { |
| 5321 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 5322 | setverdict(pass); |
| 5323 | } |
| 5324 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5325 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5326 | 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] | 5327 | } |
| 5328 | [] 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] | 5329 | 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] | 5330 | } |
| 5331 | [] PCU.receive { repeat; } |
| 5332 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5333 | 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] | 5334 | } |
| 5335 | [not exp_success] T.timeout { |
| 5336 | setverdict(pass); |
| 5337 | } |
| 5338 | } |
| 5339 | } |
| 5340 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5341 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5342 | 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] | 5343 | runs on test_CT { |
| 5344 | timer T := 3.0; |
| 5345 | |
| 5346 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5347 | 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] | 5348 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 5349 | * when it will actually have been executed in the BTS */ |
| 5350 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5351 | PCU.clear; |
| 5352 | /* we now expect no RTS.req for this timeslot */ |
| 5353 | T.start; |
| 5354 | alt { |
| 5355 | [] 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] | 5356 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5357 | } |
| 5358 | [] PCU.receive { repeat; } |
| 5359 | [] T.timeout { |
| 5360 | setverdict(pass); |
| 5361 | } |
| 5362 | } |
| 5363 | } |
| 5364 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5365 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5366 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5367 | map(self:PCU, system:PCU); |
| 5368 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5369 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 5370 | } |
| 5371 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5372 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 5373 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5374 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5375 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5376 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5377 | } |
| 5378 | |
| 5379 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 5380 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5381 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5382 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5383 | f_TC_pcu_act_req(0, 0, 1, false); |
| 5384 | } |
| 5385 | |
| 5386 | /* PDCH activation via PCU socket on wrong BTS */ |
| 5387 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5388 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5389 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5390 | f_TC_pcu_act_req(23, 0, 7, false); |
| 5391 | } |
| 5392 | |
| 5393 | /* PDCH activation via PCU socket on wrong TRX */ |
| 5394 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5395 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5396 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5397 | f_TC_pcu_act_req(0, 23, 7, false); |
| 5398 | } |
| 5399 | |
| 5400 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 5401 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5402 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5403 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5404 | /* Activate PDCH */ |
| 5405 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5406 | f_sleep(1.0); |
| 5407 | /* and De-Activate again */ |
| 5408 | f_TC_pcu_deact_req(0, 0, 7); |
| 5409 | } |
| 5410 | |
| 5411 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 5412 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5413 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5414 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5415 | f_TC_pcu_deact_req(0, 0, 1); |
| 5416 | } |
| 5417 | |
| 5418 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5419 | 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] | 5420 | var PCUIF_send_data sd; |
| 5421 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5422 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5423 | |
| 5424 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5425 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5426 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5427 | T.start; |
| 5428 | alt { |
| 5429 | [] 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] | 5430 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5431 | setverdict(pass); |
| 5432 | } else { |
| 5433 | repeat; |
| 5434 | } |
| 5435 | } |
| 5436 | [] PCU.receive { repeat; } |
| 5437 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5438 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5439 | } |
| 5440 | } |
| 5441 | } |
| 5442 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5443 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 5444 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 5445 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 5446 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 5447 | } |
| 5448 | |
| 5449 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 5450 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 5451 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 5452 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 5453 | } |
| 5454 | |
| 5455 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 5456 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 5457 | const octetstring si13 := '01010203040506070909'O; |
| 5458 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 5459 | } |
| 5460 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5461 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 5462 | |
| 5463 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5464 | 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] | 5465 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 5466 | runs on test_CT |
| 5467 | { |
| 5468 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 5469 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 5470 | } |
| 5471 | |
| 5472 | /* 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] | 5473 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 5474 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5475 | runs on test_CT |
| 5476 | { |
| 5477 | var PCUIF_send_data sd; |
| 5478 | |
| 5479 | timer T := 3.0; |
| 5480 | T.start; |
| 5481 | alt { |
| 5482 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5483 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 5484 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 5485 | sd.data.u.rts_req.fn, sapi, data); |
| 5486 | } |
| 5487 | [] PCU.receive { repeat; } |
| 5488 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5489 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5490 | } |
| 5491 | } |
| 5492 | } |
| 5493 | |
| 5494 | /* Send DATA.req on invalid BTS */ |
| 5495 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5496 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5497 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5498 | |
| 5499 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5500 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5501 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5502 | f_TfiUsfArrSet(tua, 7, 0); |
| 5503 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5504 | f_sleep(1.0); |
| 5505 | |
| 5506 | 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] | 5507 | } |
| 5508 | |
| 5509 | /* Send DATA.req on invalid TRX */ |
| 5510 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5511 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5512 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5513 | |
| 5514 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5515 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5516 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5517 | f_TfiUsfArrSet(tua, 7, 0); |
| 5518 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5519 | f_sleep(1.0); |
| 5520 | |
| 5521 | 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] | 5522 | } |
| 5523 | |
| 5524 | /* Send DATA.req on invalid timeslot */ |
| 5525 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5526 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5527 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5528 | |
| 5529 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5530 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5531 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5532 | f_TfiUsfArrSet(tua, 7, 0); |
| 5533 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5534 | f_sleep(1.0); |
| 5535 | |
| 5536 | 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] | 5537 | } |
| 5538 | |
| 5539 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 5540 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5541 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5542 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5543 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5544 | f_virtphy_common(); |
| 5545 | |
| 5546 | f_TfiUsfArrSet(tua, 7, 0); |
| 5547 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5548 | f_sleep(1.0); |
| 5549 | |
| 5550 | 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] | 5551 | } |
| 5552 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5553 | 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] | 5554 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 5555 | boolean wait_rts := true) |
| 5556 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5557 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5558 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5559 | |
| 5560 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5561 | if (wait_rts) { |
| 5562 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 5563 | } else { |
| 5564 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 5565 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5566 | |
| 5567 | T.start; |
| 5568 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5569 | [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] | 5570 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 5571 | setverdict(pass); |
| 5572 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5573 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 5574 | setverdict(fail, "Received unexpected ", rx_dl); |
| 5575 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5576 | [] L1CTL.receive { |
| 5577 | repeat; |
| 5578 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5579 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5580 | setverdict(fail, "Timeout waiting for ", data); |
| 5581 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5582 | [not expect_data] T.timeout { |
| 5583 | setverdict(pass); |
| 5584 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5585 | } |
| 5586 | } |
| 5587 | |
| 5588 | private function f_disable_dynamic_ts() runs on test_CT |
| 5589 | { |
| 5590 | f_init_vty_bsc(); |
| 5591 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 5592 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 5593 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 5594 | 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] | 5595 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5596 | } |
| 5597 | |
| 5598 | private function f_virtphy_common() runs on test_CT { |
| 5599 | f_disable_dynamic_ts(); |
| 5600 | f_init_l1ctl(); |
| 5601 | f_l1_tune(L1CTL); |
| 5602 | } |
| 5603 | |
| 5604 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 5605 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5606 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5607 | |
| 5608 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5609 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5610 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5611 | f_TfiUsfArrSet(tua, 7, 0); |
| 5612 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5613 | f_sleep(1.0); |
| 5614 | |
| 5615 | 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] | 5616 | } |
| 5617 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5618 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5619 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5620 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5621 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5622 | |
| 5623 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5624 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5625 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5626 | f_TfiUsfArrSet(tua, 7, 0); |
| 5627 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5628 | f_sleep(1.0); |
| 5629 | |
| 5630 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5631 | } |
| 5632 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5633 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 5634 | runs on test_CT { |
| 5635 | var template PCUIF_Message pcu_rach_ind; |
| 5636 | var PCUIF_send_data sd; |
| 5637 | var GsmFrameNumber fn; |
| 5638 | timer T; |
| 5639 | |
| 5640 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 5641 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 5642 | chan_nr := ts_RslChanNr_PDCH(7), |
| 5643 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 5644 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5645 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 5646 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5647 | |
| 5648 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 5649 | T.start(52.0 * 4.615 / 1000.0); |
| 5650 | alt { |
| 5651 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 5652 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 5653 | setverdict(pass); |
| 5654 | T.stop; |
| 5655 | } |
| 5656 | [] PCU.receive { repeat; } |
| 5657 | [] T.timeout { |
| 5658 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 5659 | /* Keep going, that's not the end of the world */ |
| 5660 | } |
| 5661 | } |
| 5662 | } |
| 5663 | |
| 5664 | testcase TC_pcu_ptcch() runs on test_CT { |
| 5665 | var L1ctlDlMessage dl; |
| 5666 | var octetstring data; |
| 5667 | timer T; |
| 5668 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5669 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5670 | f_init_l1ctl(); |
| 5671 | f_l1_tune(L1CTL); |
| 5672 | |
| 5673 | /* Activate PDCH channel on TS7 */ |
| 5674 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5675 | |
| 5676 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5677 | 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] | 5678 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5679 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5680 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5681 | |
| 5682 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 5683 | for (var integer i := 0; i < 16; i := i + 1) { |
| 5684 | log("Sending an Access Burst towards the L1CTL interface"); |
| 5685 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 5686 | } |
| 5687 | |
| 5688 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 5689 | data := f_rnd_octstring(23); |
| 5690 | |
| 5691 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 5692 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 5693 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 5694 | |
| 5695 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 5696 | * let's give it more time in case if we miss the beginning. */ |
| 5697 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 5698 | alt { |
| 5699 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 5700 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5701 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5702 | frame := data)) -> value dl { |
| 5703 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 5704 | setverdict(pass); |
| 5705 | T.stop; |
| 5706 | } |
| 5707 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 5708 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5709 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5710 | l2_data := data)) -> value dl { |
| 5711 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 5712 | setverdict(pass); |
| 5713 | T.stop; |
| 5714 | } |
| 5715 | [] L1CTL.receive { repeat; } |
| 5716 | [] T.timeout { |
| 5717 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 5718 | } |
| 5719 | } |
| 5720 | } |
| 5721 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5722 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5723 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 5724 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5725 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5726 | f_init_l1ctl(); |
| 5727 | f_l1_tune(L1CTL); |
| 5728 | |
| 5729 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5730 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5731 | |
| 5732 | T.start; |
| 5733 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5734 | [] 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] | 5735 | setverdict(pass); |
| 5736 | } |
| 5737 | [] L1CTL.receive { repeat; } |
| 5738 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5739 | 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] | 5740 | } |
| 5741 | } |
| 5742 | } |
| 5743 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5744 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5745 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5746 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5747 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5748 | f_init_l1ctl(); |
| 5749 | f_l1_tune(L1CTL); |
| 5750 | |
| 5751 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5752 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5753 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5754 | |
| 5755 | T.start; |
| 5756 | alt { |
| 5757 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5758 | setverdict(pass); |
| 5759 | } |
| 5760 | [] L1CTL.receive { repeat; } |
| 5761 | [] T.timeout { |
| 5762 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5763 | } |
| 5764 | } |
| 5765 | } |
| 5766 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5767 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5768 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5769 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5770 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5771 | f_init_l1ctl(); |
| 5772 | f_l1_tune(L1CTL); |
| 5773 | |
| 5774 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5775 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5776 | |
| 5777 | timer T := 0.5; |
| 5778 | T.start; |
| 5779 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5780 | [] 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] | 5781 | /* TODO: verify paging group */ |
| 5782 | setverdict(pass); |
| 5783 | } |
| 5784 | [] L1CTL.receive { repeat; } |
| 5785 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5786 | 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] | 5787 | } |
| 5788 | } |
| 5789 | } |
| 5790 | |
| 5791 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5792 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5793 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5794 | f_init_l1ctl(); |
| 5795 | f_l1_tune(L1CTL); |
| 5796 | |
| 5797 | var GsmFrameNumber fn_last := 0; |
| 5798 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5799 | var OCT1 ra := f_rnd_ra_ps(); |
| 5800 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5801 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5802 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5803 | } |
| 5804 | fn_last := fn; |
| 5805 | |
| 5806 | timer T := 2.0; |
| 5807 | T.start; |
| 5808 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5809 | [] 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] | 5810 | T.stop; |
| 5811 | } |
| 5812 | [] 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] | 5813 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5814 | } |
| 5815 | [] PCU.receive { repeat; } |
| 5816 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5817 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5818 | } |
| 5819 | } |
| 5820 | } |
| 5821 | setverdict(pass); |
| 5822 | } |
| 5823 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5824 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5825 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5826 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5827 | var template PCUIF_Message pcu_rach_ind; |
| 5828 | var GsmFrameNumber fn_last := 0; |
| 5829 | var L1ctlRachSynchSeq synch_seq; |
| 5830 | var PCUIF_BurstType pcu_bt; |
| 5831 | var GsmFrameNumber fn; |
| 5832 | var BIT11 ra11; |
| 5833 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5834 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5835 | f_init_l1ctl(); |
| 5836 | f_l1_tune(L1CTL); |
| 5837 | |
| 5838 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5839 | /* We need to test both TS1 & TS2 */ |
| 5840 | if (i rem 2 == 0) { |
| 5841 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5842 | pcu_bt := BURST_TYPE_1; |
| 5843 | } else { |
| 5844 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5845 | pcu_bt := BURST_TYPE_2; |
| 5846 | } |
| 5847 | |
| 5848 | ra11 := f_rnd_ra11_ps(); |
| 5849 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5850 | if (fn == fn_last) { |
| 5851 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5852 | "Two RACH in same FN?!?"); |
| 5853 | } |
| 5854 | fn_last := fn; |
| 5855 | |
| 5856 | /* Compose the expected message */ |
| 5857 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5858 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5859 | ra := bit2int(ra11), |
| 5860 | is_11bit := 1, |
| 5861 | burst_type := pcu_bt, |
| 5862 | fn := fn); |
| 5863 | |
| 5864 | timer T := 2.0; |
| 5865 | T.start; |
| 5866 | alt { |
| 5867 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5868 | T.stop; |
| 5869 | } |
| 5870 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5871 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5872 | } |
| 5873 | [] PCU.receive { repeat; } |
| 5874 | [] T.timeout { |
| 5875 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5876 | } |
| 5877 | } |
| 5878 | } |
| 5879 | setverdict(pass); |
| 5880 | } |
| 5881 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5882 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5883 | runs on test_CT { |
| 5884 | var template PCUIF_send_data sdt; |
| 5885 | var PCUIF_send_data sd; |
| 5886 | var int16_t lqual_cb; |
| 5887 | timer T := 1.0; |
| 5888 | |
| 5889 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5890 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5891 | |
| 5892 | /* Send a random PDTCH frame over Um */ |
| 5893 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5894 | '0000'O & f_rnd_octstring(21))); |
| 5895 | |
| 5896 | T.start; |
| 5897 | alt { |
| 5898 | /* If expected link quality is above the threshold */ |
| 5899 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5900 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5901 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5902 | |
| 5903 | /* Make sure the actual link quality matches the expected value */ |
| 5904 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5905 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5906 | "expected value ", lqual_cb_exp)); |
| 5907 | } else { |
| 5908 | setverdict(pass); |
| 5909 | } |
| 5910 | } |
| 5911 | /* If expected link quality is below the threshold */ |
| 5912 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5913 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5914 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5915 | } |
| 5916 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5917 | [] PCU.receive { repeat; } |
| 5918 | [lqual_cb_exp < thresh] T.timeout { |
| 5919 | log("Rx nothing, as expected"); |
| 5920 | setverdict(pass); |
| 5921 | } |
| 5922 | [lqual_cb_exp >= thresh] T.timeout { |
| 5923 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5924 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5925 | } |
| 5926 | } |
| 5927 | } |
| 5928 | |
| 5929 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5930 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5931 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5932 | PCU.clear; |
| 5933 | |
| 5934 | f_init_l1ctl(); |
| 5935 | f_l1_tune(L1CTL); |
| 5936 | |
| 5937 | /* Activate a PDCH channel on TS7 */ |
| 5938 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5939 | |
| 5940 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5941 | 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] | 5942 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5943 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5944 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5945 | |
| 5946 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5947 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5948 | var TrxcMessage ret; |
| 5949 | |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 5950 | 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] | 5951 | |
| 5952 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5953 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5954 | } |
| 5955 | } |
| 5956 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5957 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5958 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5959 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5960 | |
| 5961 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5962 | var MobileIdentityLV mi_lv; |
| 5963 | var octetstring mi_lv_enc; |
| 5964 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5965 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5966 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5967 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5968 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5969 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5970 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5971 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5972 | |
| 5973 | /* Fancy encoding for PCUIF */ |
| 5974 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5975 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5976 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5977 | |
| 5978 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5979 | 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] | 5980 | T.start; |
| 5981 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5982 | [] 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] | 5983 | } |
| 5984 | [] 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] | 5985 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5986 | } |
| 5987 | [] PCU.receive { repeat; } |
| 5988 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5989 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5990 | } |
| 5991 | } |
| 5992 | } |
| 5993 | setverdict(pass); |
| 5994 | } |
| 5995 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5996 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5997 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5998 | var PCUIF_send_data pcu_sd; |
| 5999 | var integer num_time_ind := 0; |
| 6000 | var integer first_fn, last_fn; |
| 6001 | var float test_duration := 5.0; |
| 6002 | timer T; |
| 6003 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6004 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6005 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6006 | |
| 6007 | PCU.clear; |
| 6008 | T.start(test_duration); |
| 6009 | alt { |
| 6010 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 6011 | num_time_ind := num_time_ind + 1; |
| 6012 | if (not isbound(first_fn)) { |
| 6013 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 6014 | } |
| 6015 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 6016 | repeat; |
| 6017 | } |
| 6018 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 6019 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 6020 | repeat; |
| 6021 | } |
| 6022 | [] PCU.receive { |
| 6023 | repeat; |
| 6024 | } |
| 6025 | [] T.timeout {} |
| 6026 | } |
| 6027 | var integer fn_expired := last_fn - first_fn; |
| 6028 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 6029 | |
| 6030 | /* verify the number of frames expired matches our expectation */ |
| 6031 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 6032 | 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] | 6033 | 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] | 6034 | if (not match(fn_expired, t_fn_expected)) { |
| 6035 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 6036 | } |
| 6037 | |
| 6038 | /* There are three TIME.ind in every fn MOD 13 */ |
| 6039 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 6040 | /* Add some tolerance */ |
| 6041 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 6042 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 6043 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 6044 | } |
| 6045 | |
| 6046 | setverdict(pass); |
| 6047 | } |
| 6048 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6049 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 6050 | testcase TC_pcu_rts_req() runs on test_CT { |
| 6051 | var PCUIF_send_data pcu_sd; |
| 6052 | var integer first_fn, last_fn; |
| 6053 | var integer num_rts_pdtch := 0; |
| 6054 | var integer num_rts_ptcch := 0; |
| 6055 | var float test_duration := 5.0; |
| 6056 | timer T; |
| 6057 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6058 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6059 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6060 | |
| 6061 | PCU.clear; |
| 6062 | T.start(test_duration); |
| 6063 | alt { |
| 6064 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 6065 | -> value pcu_sd { |
| 6066 | num_rts_pdtch := num_rts_pdtch + 1; |
| 6067 | if (not isbound(first_fn)) { |
| 6068 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 6069 | } |
| 6070 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 6071 | repeat; |
| 6072 | } |
| 6073 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 6074 | -> value pcu_sd { |
| 6075 | num_rts_ptcch := num_rts_ptcch + 1; |
| 6076 | if (not isbound(first_fn)) { |
| 6077 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 6078 | } |
| 6079 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 6080 | repeat; |
| 6081 | } |
| 6082 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 6083 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 6084 | repeat; |
| 6085 | } |
| 6086 | [] PCU.receive { |
| 6087 | repeat; |
| 6088 | } |
| 6089 | [] T.timeout {} |
| 6090 | } |
| 6091 | var integer fn_expired := last_fn - first_fn; |
| 6092 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 6093 | ", num_rts_ptcch=", num_rts_ptcch); |
| 6094 | |
| 6095 | /* verify the number of frames expired matches our expectation */ |
| 6096 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 6097 | 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] | 6098 | 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] | 6099 | if (not match(fn_expired, t_fn_expected)) { |
| 6100 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 6101 | } |
| 6102 | |
| 6103 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 6104 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 6105 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 6106 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 6107 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 6108 | t_ptcch_exp); |
| 6109 | } |
| 6110 | |
| 6111 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 6112 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 6113 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 6114 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 6115 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 6116 | t_pdtch_exp); |
| 6117 | } |
| 6118 | |
| 6119 | setverdict(pass); |
| 6120 | } |
| 6121 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6122 | /* test for generating Abis side OML ALERT from the PCU */ |
| 6123 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 6124 | var PCUIF_send_data pcu_sd; |
| 6125 | var integer num_time_ind := 0; |
| 6126 | var integer first_fn, last_fn; |
| 6127 | var float test_duration := 5.0; |
| 6128 | timer T; |
| 6129 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6130 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6131 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6132 | |
| 6133 | /* re-connect CTRL port from BTS to BSC */ |
| 6134 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 6135 | 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] | 6136 | |
| 6137 | /* Send that OML Alert */ |
| 6138 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 6139 | |
| 6140 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 6141 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 6142 | setverdict(pass); |
| 6143 | } |
| 6144 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6145 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 6146 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 6147 | var PCUIF_Message first_info; |
| 6148 | var integer pcu_conn_id := -1; |
| 6149 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6150 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 6151 | var OCT4 tlli := '01020304'O; |
| 6152 | var OCT1 cause := '23'O; |
| 6153 | timer T := 5.0; |
| 6154 | |
| 6155 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6156 | |
| 6157 | f_l1_tune(L1CTL); |
| 6158 | RSL.clear; |
| 6159 | |
| 6160 | f_est_dchan(); |
| 6161 | L1CTL.clear; |
| 6162 | |
| 6163 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6164 | |
| 6165 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 6166 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 6167 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 6168 | |
| 6169 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 6170 | T.start; |
| 6171 | alt { |
| 6172 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 6173 | setverdict(pass); |
| 6174 | } |
| 6175 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 6176 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 6177 | } |
| 6178 | [] PCU.receive { |
| 6179 | repeat; |
| 6180 | } |
| 6181 | [] T.timeout { |
| 6182 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 6183 | } |
| 6184 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 6185 | |
| 6186 | /* release the channel */ |
| 6187 | f_rsl_chan_deact(); |
| 6188 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6189 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6190 | } |
| 6191 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 6192 | var ConnHdlrPars pars; |
| 6193 | var ConnHdlr vc_conn; |
| 6194 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6195 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6196 | |
| 6197 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 6198 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 6199 | vc_conn.done; |
| 6200 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6201 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6202 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 6203 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6204 | var boolean connected := false; |
| 6205 | var UD_connect_result cr; |
| 6206 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6207 | timer T := 5.0; |
| 6208 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6209 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 6210 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 6211 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6212 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6213 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6214 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6215 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6216 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 6217 | T.start; |
| 6218 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6219 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 6220 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 6221 | log("BTS has accept()ed connection"); |
| 6222 | connected := true; |
| 6223 | cid := cr.id; |
| 6224 | repeat; |
| 6225 | } |
| 6226 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 6227 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6228 | setverdict(pass); |
| 6229 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6230 | /* ignore other messages related to the first connection */ |
| 6231 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6232 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6233 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6234 | } |
| 6235 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6236 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6237 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6238 | } |
| 6239 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6240 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 6241 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 6242 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6243 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6244 | |
| 6245 | f_sleep(1.0); |
| 6246 | |
| 6247 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6248 | g_pcu_conn_id := -1; |
| 6249 | |
| 6250 | f_sleep(1.0); |
| 6251 | |
| 6252 | /* re-connect */ |
| 6253 | PCU.clear; |
| 6254 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6255 | setverdict(pass); |
| 6256 | |
| 6257 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6258 | } |
| 6259 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6260 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6261 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 6262 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6263 | var L1ctlDlMessage l1_dl; |
| 6264 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 6265 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6266 | timer T := 5.0; |
| 6267 | T.start; |
| 6268 | alt { |
| 6269 | [] 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] | 6270 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 6271 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6272 | repeat; |
| 6273 | } |
| 6274 | } |
| 6275 | [] pt.receive { |
| 6276 | repeat; |
| 6277 | } |
| 6278 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6279 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6280 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6281 | } |
| 6282 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6283 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6284 | } |
| 6285 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6286 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 6287 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 6288 | runs on test_CT return boolean { |
| 6289 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 6290 | |
| 6291 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6292 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6293 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6294 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6295 | } |
| 6296 | |
| 6297 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 6298 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6299 | } |
| 6300 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6301 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 6302 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 6303 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6304 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6305 | f_init_l1ctl(); |
| 6306 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6307 | f_sleep(2.0); |
| 6308 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6309 | |
| 6310 | if (f_si_has_gprs_indicator(si_type)) { |
| 6311 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6312 | } else { |
| 6313 | setverdict(pass); |
| 6314 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6315 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6316 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6317 | } |
| 6318 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6319 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 6320 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6321 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6322 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6323 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 6324 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6325 | } |
| 6326 | |
| 6327 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 6328 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 6329 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6330 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6331 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6332 | f_init_l1ctl(); |
| 6333 | f_l1_tune(L1CTL); |
| 6334 | |
| 6335 | f_sleep(2.0); |
| 6336 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6337 | |
| 6338 | if (not f_si_has_gprs_indicator(si_type)) { |
| 6339 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6340 | } else { |
| 6341 | setverdict(pass); |
| 6342 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6343 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6344 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6345 | } |
| 6346 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6347 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 6348 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 6349 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6350 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6351 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 6352 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 6353 | } |
| 6354 | |
| 6355 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 6356 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 6357 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6358 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6359 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6360 | f_init_l1ctl(); |
| 6361 | f_l1_tune(L1CTL); |
| 6362 | |
| 6363 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6364 | g_pcu_conn_id := -1; |
| 6365 | |
| 6366 | f_sleep(1.0); |
| 6367 | |
| 6368 | /* re-connect */ |
| 6369 | PCU.clear; |
| 6370 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6371 | |
| 6372 | f_sleep(2.0); |
| 6373 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6374 | |
| 6375 | if (f_si_has_gprs_indicator(si_type)) { |
| 6376 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6377 | } else { |
| 6378 | setverdict(pass); |
| 6379 | } |
| 6380 | |
| 6381 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6382 | } |
| 6383 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6384 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 6385 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6386 | } |
| 6387 | |
| 6388 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 6389 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6390 | } |
| 6391 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6392 | /* 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) */ |
| 6393 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 6394 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 6395 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6396 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6397 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 6398 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 6399 | * information */ |
| 6400 | timer T := 2.0; |
| 6401 | T.start; |
| 6402 | alt { |
| 6403 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 6404 | [] T.timeout {} |
| 6405 | } |
| 6406 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6407 | /* Verify cell_id */ |
| 6408 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 6409 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 6410 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 6411 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 6412 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 6413 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6414 | } |
| 6415 | |
| 6416 | /* Verify LAC */ |
| 6417 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 6418 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 6419 | if (lac_si3 != lac_pcu) { |
| 6420 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 6421 | } |
| 6422 | |
| 6423 | setverdict(pass); |
| 6424 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6425 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6426 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 6427 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 6428 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6429 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6430 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6431 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6432 | |
| 6433 | info_ind := g_pcu_last_info.u.info_ind; |
| 6434 | |
| 6435 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 6436 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6437 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6438 | /* Skip inactive timeslots */ |
| 6439 | continue; |
| 6440 | } |
| 6441 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6442 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 6443 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6444 | else |
| 6445 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6446 | |
| 6447 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6448 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6449 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6450 | hsn := fhp.maio_hsn.hsn, |
| 6451 | maio := fhp.maio_hsn.maio, |
| 6452 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 6453 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6454 | } else { |
| 6455 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 6456 | } |
| 6457 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6458 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6459 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 6460 | if (not match(ts, tr_ts)) { |
| 6461 | setverdict(fail, "Hopping parameters do not match: ", |
| 6462 | "received ", ts, " vs expected ", tr_ts); |
| 6463 | } else { |
| 6464 | setverdict(pass); |
| 6465 | } |
| 6466 | } |
| 6467 | } |
| 6468 | } |
| 6469 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6470 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6471 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 6472 | f_init_vty_bsc(); |
| 6473 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6474 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6475 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6476 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6477 | |
| 6478 | 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] | 6479 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6480 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6481 | 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] | 6482 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6483 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6484 | if (not match(remote_addr, tr_remote_addr)) { |
| 6485 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6486 | } |
| 6487 | |
| 6488 | setverdict(pass); |
| 6489 | } |
| 6490 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6491 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6492 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 6493 | f_init_vty_bsc(); |
| 6494 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 6495 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6496 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6497 | |
| 6498 | 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] | 6499 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6500 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 6501 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 6502 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6503 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6504 | if (not match(remote_addr, tr_remote_addr)) { |
| 6505 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6506 | } |
| 6507 | |
| 6508 | setverdict(pass); |
| 6509 | } |
| 6510 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6511 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 6512 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 6513 | f_init_vty_bsc(); |
| 6514 | |
| 6515 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 6516 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 6517 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6518 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 6519 | |
| 6520 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 6521 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 6522 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 6523 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 6524 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6525 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6526 | |
| 6527 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 6528 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 6529 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6530 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6531 | addr := { |
| 6532 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 6533 | f_inet6_addr("fd00::ca:ff:ee") |
| 6534 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6535 | }; |
| 6536 | |
| 6537 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 6538 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 6539 | if (not match(remote_addr, tr_remote_addr)) |
| 6540 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 6541 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 6542 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 6543 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 6544 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 6545 | |
| 6546 | setverdict(pass); |
| 6547 | } |
| 6548 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6549 | /* Verify periodic interference reports on PDCH */ |
| 6550 | testcase TC_pcu_interf_ind() runs on test_CT { |
| 6551 | var template PCUIF_Message tr_interf_ind; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6552 | var integer interf_ind_num := 0; |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6553 | var boolean first := true; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6554 | var PCUIF_send_data sd; |
| 6555 | timer T; |
| 6556 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6557 | /* Set the averaging/reporting period to 480ms */ |
| 6558 | f_init_vty_bsc(); |
| 6559 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 1" }); |
| 6560 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6561 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6562 | f_init_with_pcuif(); |
| 6563 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6564 | |
| 6565 | /* We need trxcon for NOPE indications */ |
| 6566 | f_init_l1ctl(); |
| 6567 | f_l1_tune(L1CTL); |
| 6568 | |
| 6569 | /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */ |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6570 | tr_interf_ind := tr_PCUIF_INTERF_IND( |
| 6571 | bts_nr := 0, |
| 6572 | trx_nr := 0, |
| 6573 | fn := ?, |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 6574 | interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) } |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6575 | ); |
| 6576 | |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6577 | T.start(0.480 * 1.5); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6578 | alt { |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6579 | /* The first interference report may contain unreliable values, so we ignore it */ |
| 6580 | [first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) { |
| 6581 | /* 4 SACCH periods => 4 reports (plus some guard time) */ |
| 6582 | T.start(0.480 * 4.0 + 0.480 / 2.0); |
| 6583 | first := false; |
| 6584 | repeat; |
| 6585 | } |
| 6586 | /* Subsequent interference reports shall match our expectations */ |
| 6587 | [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] | 6588 | /* Check TDMA frame number period */ |
| 6589 | if (sd.data.u.interf_ind.fn mod 104 != 0) { |
| 6590 | setverdict(fail, "Odd TDMA frame number := ", |
| 6591 | sd.data.u.interf_ind.fn); |
| 6592 | } |
| 6593 | interf_ind_num := interf_ind_num + 1; |
| 6594 | if (interf_ind_num < 4) |
| 6595 | { repeat; } |
| 6596 | } |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6597 | [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] | 6598 | setverdict(fail, "Received unexpected interference report: ", sd.data); |
| 6599 | } |
| 6600 | [] PCU.receive { repeat; } |
| 6601 | [] T.timeout { |
| 6602 | setverdict(fail, "Timeout waiting for interference reports"); |
| 6603 | } |
| 6604 | } |
| 6605 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6606 | /* Reset the averaging/reporting period back to default */ |
| 6607 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 6" }); |
| 6608 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6609 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6610 | } |
| 6611 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6612 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6613 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6614 | ***********************************************************************/ |
| 6615 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6616 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 6617 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6618 | runs on ConnHdlr { |
| 6619 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6620 | |
| 6621 | [] 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] | 6622 | 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] | 6623 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 6624 | repeat; |
| 6625 | } |
| 6626 | } |
| 6627 | } |
| 6628 | |
| 6629 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6630 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6631 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6632 | PCU.clear; |
| 6633 | f_rsl_chan_act(g_pars.chan_mode); |
| 6634 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6635 | timer T_wait := 2.0; |
| 6636 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6637 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6638 | [] 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] | 6639 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6640 | [] T_wait.timeout { |
| 6641 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6642 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6643 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6644 | } |
| 6645 | /* try to activate this PDCH from the PCU point of view */ |
| 6646 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6647 | /* FIXME: is there a response? */ |
| 6648 | } |
| 6649 | |
| 6650 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6651 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6652 | /* Send RSL CHAN REL (deactivate) */ |
| 6653 | PCU.clear; |
| 6654 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6655 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6656 | timer T_wait := 2.0; |
| 6657 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6658 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6659 | [] 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] | 6660 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6661 | [] T_wait.timeout { |
| 6662 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6663 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6664 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6665 | } |
| 6666 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6667 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6668 | alt { |
| 6669 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 6670 | setverdict(pass); |
| 6671 | } |
| 6672 | [] RSL.receive { repeat; } |
| 6673 | } |
| 6674 | } |
| 6675 | |
| 6676 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6677 | 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] | 6678 | var PCUIF_Message first_info; |
| 6679 | var integer ts_nr := g_chan_nr.tn; |
| 6680 | var integer trx_nr := 0; |
| 6681 | var integer bts_nr := 0; |
| 6682 | var integer pcu_conn_id := -1; |
| 6683 | |
| 6684 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6685 | |
| 6686 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6687 | f_sleep(3.0); |
| 6688 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6689 | setverdict(pass); |
| 6690 | } |
| 6691 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 6692 | var ConnHdlrPars pars; |
| 6693 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6694 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6695 | |
| 6696 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6697 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 6698 | vc_conn.done; |
| 6699 | } |
| 6700 | |
| 6701 | /* 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] | 6702 | 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] | 6703 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6704 | var integer pcu_conn_id := -1; |
| 6705 | |
| 6706 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6707 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 6708 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6709 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 6710 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6711 | setverdict(pass); |
| 6712 | } |
| 6713 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 6714 | var ConnHdlrPars pars; |
| 6715 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6716 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6717 | |
| 6718 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6719 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 6720 | vc_conn.done; |
| 6721 | } |
| 6722 | |
| 6723 | /* 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] | 6724 | 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] | 6725 | var PCUIF_Message first_info; |
| 6726 | var integer ts_nr := g_chan_nr.tn; |
| 6727 | var integer trx_nr := 0; |
| 6728 | var integer bts_nr := 0; |
| 6729 | var integer pcu_conn_id := -1; |
| 6730 | |
| 6731 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6732 | |
| 6733 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 6734 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 6735 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6736 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6737 | setverdict(pass); |
| 6738 | } |
| 6739 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 6740 | var ConnHdlrPars pars; |
| 6741 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6742 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6743 | |
| 6744 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6745 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 6746 | vc_conn.done; |
| 6747 | } |
| 6748 | |
| 6749 | /* 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] | 6750 | 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] | 6751 | var PCUIF_Message first_info; |
| 6752 | var integer ts_nr := g_chan_nr.tn; |
| 6753 | var integer trx_nr := 0; |
| 6754 | var integer bts_nr := 0; |
| 6755 | var integer pcu_conn_id := -1; |
| 6756 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 6757 | |
| 6758 | /* register for the TCH/F channel number */ |
| 6759 | f_rslem_register(0, chan_nr); |
| 6760 | |
| 6761 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6762 | |
| 6763 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 6764 | "RSL CHAN ACT"); |
| 6765 | setverdict(pass); |
| 6766 | } |
| 6767 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 6768 | var ConnHdlrPars pars; |
| 6769 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6770 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6771 | |
| 6772 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6773 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 6774 | vc_conn.done; |
| 6775 | } |
| 6776 | |
| 6777 | /* 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] | 6778 | 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] | 6779 | var PCUIF_Message first_info; |
| 6780 | var integer ts_nr := g_chan_nr.tn; |
| 6781 | var integer trx_nr := 0; |
| 6782 | var integer bts_nr := 0; |
| 6783 | var integer pcu_conn_id := -1; |
| 6784 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 6785 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 6786 | |
| 6787 | /* register for the TCH/H channel numbers */ |
| 6788 | f_rslem_register(0, chan_nr[0]); |
| 6789 | f_rslem_register(0, chan_nr[1]); |
| 6790 | |
| 6791 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6792 | |
| 6793 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6794 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6795 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6796 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6797 | setverdict(pass); |
| 6798 | } |
| 6799 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6800 | var ConnHdlrPars pars; |
| 6801 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6802 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6803 | |
| 6804 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6805 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6806 | vc_conn.done; |
| 6807 | } |
| 6808 | |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 6809 | /* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */ |
| 6810 | private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr { |
| 6811 | var PCUIF_Message first_info; |
| 6812 | var integer ts_nr := g_chan_nr.tn; |
| 6813 | var integer trx_nr := 0; |
| 6814 | var integer bts_nr := 0; |
| 6815 | var integer pcu_conn_id := -1; |
| 6816 | var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)), |
| 6817 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)), |
| 6818 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)), |
| 6819 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)), |
| 6820 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)), |
| 6821 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)), |
| 6822 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)), |
| 6823 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) }; |
| 6824 | |
| 6825 | /* register for the TCH/H channel numbers */ |
| 6826 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6827 | f_rslem_register(0, chan_nr[i]); |
| 6828 | } |
| 6829 | |
| 6830 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6831 | |
| 6832 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6833 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode), |
| 6834 | tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]"); |
| 6835 | } |
| 6836 | setverdict(pass); |
| 6837 | } |
| 6838 | testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT { |
| 6839 | var ConnHdlrPars pars; |
| 6840 | var ConnHdlr vc_conn; |
| 6841 | f_init(); |
| 6842 | |
| 6843 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6844 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true); |
| 6845 | vc_conn.done; |
| 6846 | } |
| 6847 | |
Vadim Yanitskiy | 64043d8 | 2021-10-03 15:00:20 +0600 | [diff] [blame] | 6848 | /* Reproduce a race condition described in OS#5245 */ |
| 6849 | private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr { |
| 6850 | f_rsl_chan_act(g_pars.chan_mode); |
| 6851 | f_sleep(1.0); |
| 6852 | f_rsl_chan_deact(); |
| 6853 | setverdict(pass); |
| 6854 | } |
| 6855 | testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT { |
| 6856 | var ConnHdlrPars pars[2]; |
| 6857 | var ConnHdlr vc_conn[2]; |
| 6858 | var TrxcMessage rsp; |
| 6859 | |
| 6860 | f_init(); |
| 6861 | |
| 6862 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6863 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6864 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6865 | |
| 6866 | /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second |
| 6867 | * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */ |
| 6868 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6869 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */ |
| 6870 | pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN)); |
| 6871 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6872 | pars[i], l1ctl := false); |
| 6873 | } |
| 6874 | |
| 6875 | /* Wait for all components to finish */ |
| 6876 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6877 | vc_conn[i].done; |
| 6878 | } |
| 6879 | |
| 6880 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6881 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6882 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6883 | } |
| 6884 | testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT { |
| 6885 | var ConnHdlrPars pars[8]; |
| 6886 | var ConnHdlr vc_conn[8]; |
| 6887 | var TrxcMessage rsp; |
| 6888 | |
| 6889 | f_init(); |
| 6890 | |
| 6891 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6892 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6893 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6894 | |
| 6895 | /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent |
| 6896 | * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */ |
| 6897 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6898 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */ |
| 6899 | pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN)); |
| 6900 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6901 | pars[i], l1ctl := false); |
| 6902 | } |
| 6903 | |
| 6904 | /* Wait for all components to finish */ |
| 6905 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6906 | vc_conn[i].done; |
| 6907 | } |
| 6908 | |
| 6909 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6910 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6911 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6912 | } |
| 6913 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6914 | /*********************************************************************** |
| 6915 | * IPA Style Dynamic Timeslot Support |
| 6916 | ***********************************************************************/ |
| 6917 | |
| 6918 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6919 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6920 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6921 | PCU.clear; |
| 6922 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6923 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6924 | timer T_wait := 2.0; |
| 6925 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6926 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6927 | [] 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] | 6928 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6929 | [] T_wait.timeout { |
| 6930 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6931 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6932 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6933 | } |
| 6934 | /* try to activate this PDCH from the PCU point of view */ |
| 6935 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6936 | /* FIXME: is there a response? */ |
| 6937 | |
| 6938 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6939 | } |
| 6940 | |
| 6941 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6942 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6943 | /* Send RSL CHAN REL (deactivate) */ |
| 6944 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6945 | PCU.clear; |
| 6946 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6947 | timer T_wait := 2.0; |
| 6948 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6949 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6950 | [] 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] | 6951 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6952 | [] T_wait.timeout { |
| 6953 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6954 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6955 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6956 | } |
| 6957 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6958 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6959 | alt { |
| 6960 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6961 | setverdict(pass); |
| 6962 | } |
| 6963 | [] RSL.receive { repeat; } |
| 6964 | } |
| 6965 | } |
| 6966 | |
| 6967 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6968 | 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] | 6969 | var PCUIF_Message first_info; |
| 6970 | var integer ts_nr := g_chan_nr.tn; |
| 6971 | var integer trx_nr := 0; |
| 6972 | var integer bts_nr := 0; |
| 6973 | var integer pcu_conn_id := -1; |
| 6974 | |
| 6975 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6976 | |
| 6977 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6978 | f_sleep(3.0); |
| 6979 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6980 | |
| 6981 | setverdict(pass); |
| 6982 | |
| 6983 | } |
| 6984 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6985 | var ConnHdlrPars pars; |
| 6986 | var ConnHdlr vc_conn; |
| 6987 | f_init(); |
| 6988 | |
| 6989 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6990 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6991 | vc_conn.done; |
| 6992 | } |
| 6993 | |
| 6994 | /* 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] | 6995 | 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] | 6996 | var PCUIF_Message first_info; |
| 6997 | var integer ts_nr := g_chan_nr.tn; |
| 6998 | var integer trx_nr := 0; |
| 6999 | var integer bts_nr := 0; |
| 7000 | var integer pcu_conn_id := -1; |
| 7001 | |
| 7002 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 7003 | |
| 7004 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 7005 | "RSL CHAN ACT"); |
| 7006 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 7007 | "RF CHAN REL", true); |
| 7008 | setverdict(pass); |
| 7009 | } |
| 7010 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 7011 | var ConnHdlrPars pars; |
| 7012 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7013 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7014 | |
| 7015 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 7016 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 7017 | vc_conn.done; |
| 7018 | } |
| 7019 | |
| 7020 | /* 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] | 7021 | 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] | 7022 | var PCUIF_Message first_info; |
| 7023 | var integer ts_nr := g_chan_nr.tn; |
| 7024 | var integer trx_nr := 0; |
| 7025 | var integer bts_nr := 0; |
| 7026 | var integer pcu_conn_id := -1; |
| 7027 | |
| 7028 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 7029 | |
| 7030 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 7031 | "RSL CHAN ACT"); |
| 7032 | |
| 7033 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 7034 | alt { |
| 7035 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 7036 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7038 | } |
| 7039 | [] RSL.receive { repeat; } |
| 7040 | } |
| 7041 | |
| 7042 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 7043 | "RF CHAN REL", true); |
| 7044 | setverdict(pass); |
| 7045 | } |
| 7046 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 7047 | var ConnHdlrPars pars; |
| 7048 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7049 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7050 | |
| 7051 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 7052 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 7053 | vc_conn.done; |
| 7054 | } |
| 7055 | |
| 7056 | /* 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] | 7057 | 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] | 7058 | var PCUIF_Message first_info; |
| 7059 | var integer ts_nr := g_chan_nr.tn; |
| 7060 | var integer trx_nr := 0; |
| 7061 | var integer bts_nr := 0; |
| 7062 | var integer pcu_conn_id := -1; |
| 7063 | |
| 7064 | /* register for the TCH/F channel number */ |
| 7065 | f_rslem_register(0, g_chan_nr); |
| 7066 | |
| 7067 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 7068 | |
| 7069 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 7070 | |
| 7071 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 7072 | "RSL CHAN ACT"); |
| 7073 | |
| 7074 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 7075 | |
| 7076 | setverdict(pass); |
| 7077 | } |
| 7078 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 7079 | var ConnHdlrPars pars; |
| 7080 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7081 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7082 | |
| 7083 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 7084 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 7085 | vc_conn.done; |
| 7086 | } |
| 7087 | |
| 7088 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7089 | /*********************************************************************** |
| 7090 | * LAPDm / RLL related |
| 7091 | ***********************************************************************/ |
| 7092 | |
| 7093 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 7094 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 7095 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7096 | var template (value) SacchL1Header l1h; |
| 7097 | |
| 7098 | /* 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] | 7099 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7100 | /* Compose dummy L1 header */ |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 7101 | 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] | 7102 | 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] | 7103 | } else { |
| 7104 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7105 | 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] | 7106 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7107 | } |
| 7108 | |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7109 | friend type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7110 | uint3_t sapi, |
| 7111 | RslLinkId link_id, |
| 7112 | octetstring l3, |
| 7113 | boolean exp |
| 7114 | } |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7115 | friend type record of RllTestCase RllTestCases; |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7116 | friend template RllTestCase t_EITC(template (present) uint3_t sapi, |
| 7117 | template (present) RslLinkId id, |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7118 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7119 | sapi := sapi, |
| 7120 | link_id := id, |
| 7121 | l3 := l3, |
| 7122 | exp := exp |
| 7123 | } |
| 7124 | |
| 7125 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 7126 | * variety of logical channels */ |
| 7127 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 7128 | var ConnHdlrPars pars; |
| 7129 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7130 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7131 | |
| 7132 | /* test on each of the channels we have */ |
| 7133 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 7134 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7135 | |
| 7136 | /* test each of the test cases on the current channel */ |
| 7137 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 7138 | pars.spec.rll := tcs[j]; |
| 7139 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 7140 | vc_conn := f_start_handler(fn, pars); |
| 7141 | vc_conn.done; |
| 7142 | } |
| 7143 | } |
| 7144 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7145 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7146 | } |
| 7147 | |
| 7148 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 7149 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 7150 | var RllTestCase tc := g_pars.spec.rll; |
| 7151 | timer T := 3.0; |
| 7152 | |
| 7153 | f_l1_tune(L1CTL); |
| 7154 | RSL.clear; |
| 7155 | |
| 7156 | /* activate the logical channel */ |
| 7157 | f_est_dchan(); |
| 7158 | L1CTL.clear; |
| 7159 | |
| 7160 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 7161 | T.start; |
| 7162 | alt { |
| 7163 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7164 | if (tc.exp) { |
| 7165 | setverdict(pass); |
| 7166 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7167 | 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] | 7168 | } |
| 7169 | } |
| 7170 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 7171 | if (tc.exp) { |
| 7172 | setverdict(pass); |
| 7173 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7174 | 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] | 7175 | } |
| 7176 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7177 | /* We also expect to receive the measurements */ |
| 7178 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7179 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7180 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7181 | } |
| 7182 | [not tc.exp] T.timeout { |
| 7183 | setverdict(pass); |
| 7184 | } |
| 7185 | } |
| 7186 | |
| 7187 | f_rsl_chan_deact(); |
| 7188 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7189 | f_rslem_unregister(0, g_chan_nr); |
| 7190 | } |
| 7191 | testcase TC_rll_est_ind() runs on test_CT { |
| 7192 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7193 | /* SAPI0 establishment (contention resolution) */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7194 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7195 | /* normal SAPI0 establishment */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7196 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7197 | /* SAPI 3 doesn't support contention resolution */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7198 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)), |
| 7199 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7200 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7201 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7202 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7203 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7204 | }; |
| 7205 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 7206 | } |
| 7207 | |
| 7208 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 7209 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 7210 | var RllTestCase tc := g_pars.spec.rll; |
| 7211 | var L1ctlDlMessage dl; |
| 7212 | timer T := 3.0; |
| 7213 | |
| 7214 | f_l1_tune(L1CTL); |
| 7215 | RSL.clear; |
| 7216 | |
| 7217 | /* activate the logical channel */ |
| 7218 | f_est_dchan(); |
| 7219 | L1CTL.clear; |
| 7220 | |
| 7221 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 7222 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 7223 | T.start; |
| 7224 | alt { |
Vadim Yanitskiy | 0310f63 | 2021-06-01 01:22:24 +0200 | [diff] [blame] | 7225 | [] 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] | 7226 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7227 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7228 | } |
| 7229 | } |
| 7230 | |
| 7231 | f_rsl_chan_deact(); |
| 7232 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7233 | f_rslem_unregister(0, g_chan_nr); |
| 7234 | } |
| 7235 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 7236 | var RllTestCases tcs := { |
| 7237 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7238 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7239 | }; |
| 7240 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7241 | } |
| 7242 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 7243 | var RllTestCases tcs := { |
| 7244 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7245 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7246 | } |
| 7247 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7248 | } |
| 7249 | |
| 7250 | /* altstep to receive a LAPDm frame matching the given template */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7251 | friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7252 | var L1ctlDlMessage dl; |
| 7253 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 7254 | var LapdmFrame lapdm; |
| 7255 | var octetstring l2 := dl.payload.data_ind.payload; |
| 7256 | if (dl.dl_info.link_id.c == SACCH) { |
| 7257 | /* remove L1 header */ |
| 7258 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 7259 | } |
| 7260 | if (ischosen(exp.ab)) { |
| 7261 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 7262 | } else if (ischosen(exp.b4)) { |
| 7263 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 7264 | } else if (ischosen(exp.bbis)) { |
| 7265 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 7266 | } |
| 7267 | log("Rx LAPDm ", lapdm); |
| 7268 | if (match(lapdm, exp)) { |
| 7269 | setverdict(pass); |
| 7270 | } else { |
| 7271 | repeat; |
| 7272 | } |
| 7273 | } |
| 7274 | [] L1CTL.receive { repeat; } |
| 7275 | } |
| 7276 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 7277 | timer T := t; |
| 7278 | T.start; |
| 7279 | alt { |
| 7280 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7281 | 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] | 7282 | } |
| 7283 | [] as_l1_exp_lapdm(exp); |
| 7284 | } |
| 7285 | } |
| 7286 | |
| 7287 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 7288 | 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] | 7289 | timer T := 2.0; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7290 | /* send SABM from MS -> BTS */ |
| 7291 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 7292 | /* expect RLL EST IND on Abis */ |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7293 | T.start; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7294 | alt { |
| 7295 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 7296 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 7297 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7298 | 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] | 7299 | } |
| 7300 | [] RSL.receive { repeat; } |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7301 | [] T.timeout { |
| 7302 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RLL EST IND"); |
| 7303 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7304 | } |
| 7305 | /* expect UA from BTS -> MS */ |
| 7306 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 7307 | } |
| 7308 | |
| 7309 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 7310 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 7311 | var RllTestCase tc := g_pars.spec.rll; |
| 7312 | |
| 7313 | f_l1_tune(L1CTL); |
| 7314 | RSL.clear; |
| 7315 | |
| 7316 | /* activate the logical channel */ |
| 7317 | f_est_dchan(); |
| 7318 | L1CTL.clear; |
| 7319 | |
| 7320 | /* first establish the link-layer */ |
| 7321 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7322 | |
| 7323 | /* then send the DISC */ |
| 7324 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 7325 | /* ... and expect the REL IND on the RSL side */ |
| 7326 | alt { |
| 7327 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 7328 | setverdict(pass); |
| 7329 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7330 | /* We also expect to receive the measurements */ |
| 7331 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7332 | } |
| 7333 | |
| 7334 | /* release the channel */ |
| 7335 | f_rsl_chan_deact(); |
| 7336 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7337 | f_rslem_unregister(0, g_chan_nr); |
| 7338 | } |
| 7339 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 7340 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7341 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7342 | }; |
| 7343 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7344 | } |
| 7345 | |
| 7346 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 7347 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7348 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7349 | }; |
| 7350 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7351 | } |
| 7352 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 7353 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7354 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7355 | }; |
| 7356 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7357 | } |
| 7358 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 7359 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7360 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7361 | }; |
| 7362 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7363 | } |
| 7364 | |
| 7365 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 7366 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 7367 | var RllTestCase tc := g_pars.spec.rll; |
| 7368 | f_l1_tune(L1CTL); |
| 7369 | RSL.clear; |
| 7370 | |
| 7371 | /* activate the logical channel */ |
| 7372 | f_est_dchan(); |
| 7373 | L1CTL.clear; |
| 7374 | |
| 7375 | /* first establish the link-layer */ |
| 7376 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7377 | |
| 7378 | /* then send the REL REQ via RSL */ |
| 7379 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 7380 | /* ... and expect the DISC on the Um side */ |
| 7381 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 7382 | [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) { |
Oliver Smith | 23e192e | 2023-02-13 15:00:46 +0100 | [diff] [blame] | 7383 | /* FIXME: send a UA in response to the DISC */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7384 | } |
| 7385 | } |
| 7386 | |
| 7387 | /* release the channel */ |
| 7388 | f_rsl_chan_deact(); |
| 7389 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7390 | f_rslem_unregister(0, g_chan_nr); |
| 7391 | } |
| 7392 | testcase TC_rll_rel_req() runs on test_CT { |
| 7393 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7394 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
| 7395 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)), |
| 7396 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
| 7397 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7398 | }; |
| 7399 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 7400 | } |
| 7401 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7402 | /* 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] | 7403 | testcase TC_rll_data_req() runs on test_CT { |
| 7404 | } |
| 7405 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7406 | /* 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] | 7407 | testcase TC_rll_data_ind() runs on test_CT { |
| 7408 | } |
| 7409 | |
| 7410 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 7411 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 7412 | var RllTestCase tc := g_pars.spec.rll; |
| 7413 | |
| 7414 | f_l1_tune(L1CTL); |
| 7415 | RSL.clear; |
| 7416 | |
| 7417 | f_est_dchan(); |
| 7418 | L1CTL.clear; |
| 7419 | |
| 7420 | /* Send UNITDATA REQ on RSL side */ |
| 7421 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 7422 | /* Expect it to arrive on the other side */ |
| 7423 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7424 | 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] | 7425 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7426 | 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] | 7427 | } |
| 7428 | |
| 7429 | /* release the channel */ |
| 7430 | f_rsl_chan_deact(); |
| 7431 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7432 | f_rslem_unregister(0, g_chan_nr); |
| 7433 | } |
| 7434 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 7435 | var octetstring l3 := f_rnd_octstring(15); |
| 7436 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7437 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7438 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7439 | }; |
| 7440 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7441 | } |
| 7442 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 7443 | var octetstring l3 := f_rnd_octstring(19); |
| 7444 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7445 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7446 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7447 | }; |
| 7448 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7449 | } |
| 7450 | |
| 7451 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 7452 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 7453 | var RllTestCase tc := g_pars.spec.rll; |
| 7454 | |
| 7455 | f_l1_tune(L1CTL); |
| 7456 | RSL.clear; |
| 7457 | |
| 7458 | f_est_dchan(); |
| 7459 | L1CTL.clear; |
| 7460 | |
| 7461 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7462 | 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] | 7463 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 7464 | alt { |
| 7465 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7466 | setverdict(pass); |
| 7467 | } |
| 7468 | [] RSL.receive { repeat; } |
| 7469 | } |
| 7470 | |
| 7471 | /* release the channel */ |
| 7472 | f_rsl_chan_deact(); |
| 7473 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7474 | f_rslem_unregister(0, g_chan_nr); |
| 7475 | } |
| 7476 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 7477 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7478 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7479 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7480 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7481 | }; |
| 7482 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7483 | } |
| 7484 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 7485 | var octetstring l3 := f_rnd_octstring(18); |
| 7486 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7487 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7488 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7489 | }; |
| 7490 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7491 | } |
| 7492 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7493 | /*********************************************************************** |
| 7494 | * Encryption Related |
| 7495 | ***********************************************************************/ |
| 7496 | |
| 7497 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 7498 | 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] | 7499 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 7500 | if (link_id.c == SACCH) { |
| 7501 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7502 | } else { |
| 7503 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7504 | } |
| 7505 | } |
| 7506 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7507 | /* Expect (or not expect) other kinds of messages */ |
| 7508 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 7509 | [exp_any] RSL.receive { repeat; } |
| 7510 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7511 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7512 | } |
| 7513 | } |
| 7514 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7515 | /* 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] | 7516 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7517 | RslLinkId link_id, |
| 7518 | octetstring l3, |
| 7519 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7520 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7521 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7522 | timer T := 3.0; |
| 7523 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 7524 | T.start; |
| 7525 | /* Expect RLL UNITDATA IND on RSL side */ |
| 7526 | alt { |
| 7527 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 7528 | setverdict(pass); |
| 7529 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7530 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7531 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7532 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7533 | 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] | 7534 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7535 | } |
| 7536 | } |
| 7537 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7538 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 7539 | private function f_data_mo( |
| 7540 | RslLinkId link_id, |
| 7541 | boolean p, uint3_t nr, uint3_t ns, |
| 7542 | octetstring l3, |
| 7543 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7544 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7545 | ) runs on ConnHdlr { |
| 7546 | timer T := 3.0; |
| 7547 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 7548 | T.start; |
| 7549 | /* Expect RLL DATA IND on RSL side */ |
| 7550 | alt { |
| 7551 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 7552 | setverdict(pass); |
| 7553 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7554 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7555 | [] as_rsl_any_ind(exp_any); |
| 7556 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7557 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7558 | } |
| 7559 | } |
| 7560 | } |
| 7561 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7562 | /* 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] | 7563 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7564 | f_l1_tune(L1CTL); |
| 7565 | f_est_dchan(true); |
| 7566 | |
| 7567 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7568 | var L1ctlDlMessage dl; |
| 7569 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 7570 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7571 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7572 | |
| 7573 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7574 | f_unitdata_mt(link_id, l3); |
| 7575 | |
| 7576 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7577 | f_unitdata_mo(link_id, l3); |
| 7578 | |
| 7579 | /* release the channel */ |
| 7580 | f_rsl_chan_deact(); |
| 7581 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7582 | f_rslem_unregister(0, g_chan_nr); |
| 7583 | } |
| 7584 | testcase TC_chan_act_a51() runs on test_CT { |
| 7585 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7586 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7587 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7588 | } |
| 7589 | testcase TC_chan_act_a52() runs on test_CT { |
| 7590 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7591 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7592 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7593 | } |
| 7594 | testcase TC_chan_act_a53() runs on test_CT { |
| 7595 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7596 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7597 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7598 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7599 | testcase TC_chan_act_a54() runs on test_CT { |
| 7600 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7601 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7602 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7603 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7604 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7605 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 7606 | 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] | 7607 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7608 | f_l1_tune(L1CTL); |
| 7609 | f_est_dchan(true); |
| 7610 | |
| 7611 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7612 | var L1ctlDlMessage dl; |
| 7613 | |
| 7614 | var octetstring l3 := f_rnd_octstring(20); |
| 7615 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7616 | |
| 7617 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7618 | f_unitdata_mt(link_id, l3); |
| 7619 | |
| 7620 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7621 | f_unitdata_mo(link_id, l3); |
| 7622 | |
| 7623 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7624 | 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] | 7625 | |
| 7626 | /* modify key to break proper encryption */ |
| 7627 | g_pars.encr.key := f_rnd_octstring(8); |
| 7628 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 7629 | rsl.ies := rsl.ies & { ei }; |
| 7630 | RSL.send(rsl); |
| 7631 | |
| 7632 | timer T0 := 1.0; |
| 7633 | T0.start; |
| 7634 | /* Expect RSL MODIFY ACK */ |
| 7635 | alt { |
| 7636 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 7637 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 7638 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 7639 | } |
| 7640 | [] T0.timeout { |
| 7641 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 7642 | } |
| 7643 | } |
| 7644 | |
| 7645 | var octetstring l3msg := f_rnd_octstring(15); |
| 7646 | timer T1 := 3.0; |
| 7647 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 7648 | due to broken encryption */ |
| 7649 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 7650 | T1.start; |
| 7651 | alt { |
| 7652 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 7653 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 7654 | } |
| 7655 | [] T1.timeout { |
| 7656 | setverdict(pass); |
| 7657 | } |
| 7658 | } |
| 7659 | |
| 7660 | /* release the channel */ |
| 7661 | f_rsl_chan_deact(); |
| 7662 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7663 | f_rslem_unregister(0, g_chan_nr); |
| 7664 | } |
| 7665 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 7666 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7667 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7668 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 7669 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7670 | |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7671 | /* Verify RF RESource INDication messages (periodically sent over the RSL) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 7672 | 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] | 7673 | runs on test_CT { |
| 7674 | const IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
| 7675 | var ASP_RSL_Unitdata ud; |
| 7676 | timer T; |
| 7677 | |
| 7678 | /* Intave is 6 SACCH periods by default */ |
| 7679 | var float Tval := int2float(6 * 480) / 1000.0 + 0.5; |
| 7680 | |
| 7681 | T.start(Tval); |
| 7682 | alt { |
| 7683 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) { |
| 7684 | setverdict(pass); |
| 7685 | } |
| 7686 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud { |
| 7687 | setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl); |
| 7688 | } |
| 7689 | [] RSL_CCHAN.receive { repeat; } |
| 7690 | [] T.timeout { |
| 7691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 7692 | "Timeout waiting for RF RESource INDication"); |
| 7693 | } |
| 7694 | } |
| 7695 | } |
| 7696 | testcase TC_rsl_rf_resource_ind() runs on test_CT { |
| 7697 | var RSL_ResourceInfo info := { }; |
| 7698 | |
| 7699 | f_init(trx_nr := 0); |
| 7700 | |
| 7701 | f_init_l1ctl(); |
| 7702 | f_l1_tune(L1CTL); |
| 7703 | |
| 7704 | /* g_AllChannels contains all logical channels */ |
| 7705 | for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) { |
| 7706 | var RslChannelNr chan_nr := g_AllChannels[i]; |
| 7707 | |
| 7708 | /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */ |
| 7709 | if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH) |
| 7710 | { continue; } |
| 7711 | |
| 7712 | info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) }; |
| 7713 | } |
| 7714 | |
| 7715 | /* Align to the first interference report */ |
| 7716 | f_TC_rsl_rf_resource_ind(?); |
| 7717 | |
| 7718 | /* Test 4 consecutive messages */ |
| 7719 | for (var integer i := 0; i < 4; i := i + 1) { |
| 7720 | f_TC_rsl_rf_resource_ind(info); |
| 7721 | } |
| 7722 | |
| 7723 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7724 | } |
| 7725 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7726 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7727 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7728 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 7729 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 7730 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 7731 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7732 | |
| 7733 | f_l1_tune(L1CTL); |
| 7734 | |
| 7735 | /* first establish a dedicated channel in the clear */ |
| 7736 | f_est_dchan(false); |
| 7737 | |
| 7738 | /* Establish ABM */ |
| 7739 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 7740 | |
| 7741 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 7742 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 7743 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 7744 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 7745 | |
| 7746 | /* configure L1 to apply ciphering */ |
| 7747 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 7748 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 7749 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7750 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 7751 | 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] | 7752 | |
| 7753 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 7754 | * and hence enable encryption also on the downlink */ |
| 7755 | |
| 7756 | /* expect bi-directional communication work in encrypted mode */ |
| 7757 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 7758 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 7759 | |
| 7760 | /* release the channel */ |
| 7761 | f_rsl_chan_deact(); |
| 7762 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7763 | f_rslem_unregister(0, g_chan_nr); |
| 7764 | } |
| 7765 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 7766 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7767 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7768 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7769 | } |
| 7770 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 7771 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7772 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7773 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7774 | } |
| 7775 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 7776 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7777 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7778 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7779 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7780 | testcase TC_encr_cmd_a54() runs on test_CT { |
| 7781 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7782 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7783 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7784 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7785 | |
| 7786 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 7787 | var LapdmFrame lf; |
| 7788 | var octetstring reenc; |
| 7789 | |
| 7790 | /* decode the LAPDm frame */ |
| 7791 | if (ischosen(exp_match.ab)) { |
| 7792 | lf.ab := dec_LapdmFrameAB(enc); |
| 7793 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7794 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7795 | } |
| 7796 | |
| 7797 | /* check if decoder result matches expectation */ |
| 7798 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7799 | 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] | 7800 | } else { |
| 7801 | log(name, ": matched"); |
| 7802 | setverdict(pass); |
| 7803 | } |
| 7804 | |
| 7805 | /* test if re-encoded frame equals original input */ |
| 7806 | reenc := enc_LapdmFrame(lf); |
| 7807 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7808 | 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] | 7809 | } else { |
| 7810 | setverdict(pass); |
| 7811 | } |
| 7812 | } |
| 7813 | |
| 7814 | testcase TC_lapdm_selftest() runs on test_CT { |
| 7815 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 7816 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 7817 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 7818 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 7819 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 7820 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 7821 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 7822 | } |
| 7823 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7824 | /*********************************************************************** |
| 7825 | * DTX Related (see GSM 05.08, section 8.3) |
| 7826 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7827 | 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] | 7828 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7829 | var GsmFrameNumber first_fn; |
| 7830 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7831 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7832 | 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] | 7833 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 7834 | 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] | 7835 | const integer frame_dtx_tchf_mod := 104; |
| 7836 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 7837 | * which operates in terms of blocks rather than frames. */ |
| 7838 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 7839 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7840 | timer T := 5.0; |
| 7841 | |
| 7842 | f_l1_tune(L1CTL); |
| 7843 | RSL.clear; |
| 7844 | L1CTL.clear; |
| 7845 | |
| 7846 | /* activate TCHF signalling channel */ |
| 7847 | f_est_dchan(false); |
| 7848 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7849 | /* A template for matching dummy LAPDm func=UA frames */ |
| 7850 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 7851 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 7852 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 7853 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7854 | T.start; |
| 7855 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7856 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7857 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7858 | |
| 7859 | if (is_first_frame) { |
| 7860 | is_first_frame := false; |
| 7861 | first_fn := dl.dl_info.frame_nr; |
| 7862 | } |
| 7863 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7864 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7865 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7866 | T.stop; |
| 7867 | f_rsl_chan_deact(); |
| 7868 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7869 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7870 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 7871 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7872 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7873 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7874 | setverdict(fail, "Not enough fill frames received: ", |
| 7875 | nfill_frames, " out of ", expected_fill_frames); |
| 7876 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7877 | } else { |
| 7878 | setverdict(pass); |
| 7879 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7880 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7881 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 7882 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 7883 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 7884 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 7885 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 7886 | 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] | 7887 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7888 | repeat; |
| 7889 | } |
| 7890 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7891 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 7892 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 7893 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7894 | f_rsl_chan_deact(); |
| 7895 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7896 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7897 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7898 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7899 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7900 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7901 | |
| 7902 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7903 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 7904 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7905 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 7906 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 7907 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7908 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 7909 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7910 | case else { |
| 7911 | /* This shall not happen, just to be sure */ |
| 7912 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7913 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7914 | } |
| 7915 | |
| 7916 | f_rsl_chan_deact(); |
| 7917 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7918 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7919 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7920 | setverdict(pass); |
| 7921 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7922 | setverdict(fail, "Not enough fill frames received: ", |
| 7923 | nfill_frames, " out of ", expected_fill_frames); |
| 7924 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7925 | } |
| 7926 | } else { |
| 7927 | repeat; |
| 7928 | } |
| 7929 | } |
| 7930 | } |
| 7931 | [] L1CTL.receive { repeat; } |
| 7932 | [] T.timeout { |
| 7933 | f_rsl_chan_deact(); |
| 7934 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7935 | 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] | 7936 | } |
| 7937 | } |
| 7938 | } |
| 7939 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7940 | 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] | 7941 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7942 | var ConnHdlr vc_conn; |
| 7943 | var ConnHdlrPars pars; |
| 7944 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7945 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7946 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7947 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7948 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7949 | if (dtxd) { |
| 7950 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 7951 | break; |
| 7952 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7953 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7954 | 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] | 7955 | vc_conn.done; |
| 7956 | } |
| 7957 | } |
| 7958 | |
| 7959 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7960 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7961 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7962 | f_tch_sign_l2_fill_frame(false); |
| 7963 | } |
| 7964 | |
| 7965 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7966 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7967 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7968 | f_tch_sign_l2_fill_frame(true); |
| 7969 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7970 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7971 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7972 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7973 | } |
| 7974 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7975 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7976 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7977 | } |
| 7978 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7979 | |
| 7980 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7981 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7982 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7983 | runs on ConnHdlr return octetstring; |
| 7984 | |
| 7985 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7986 | runs on ConnHdlr { |
| 7987 | var L1ctlDlMessage l1_dl; |
| 7988 | var SacchL1Header l1h; |
| 7989 | var octetstring l2; |
| 7990 | |
| 7991 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7992 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7993 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7994 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7995 | |
| 7996 | /* Pass it to the user specified call-back function */ |
| 7997 | l2 := cb.apply(l1h, num_blocks); |
| 7998 | /* Send a Measurement Report generated by the call-back */ |
| 7999 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 8000 | l1_dl.dl_info.link_id, |
| 8001 | l1h, l2)); |
| 8002 | |
| 8003 | /* Shall we keep going? */ |
| 8004 | num_blocks := num_blocks - 1; |
| 8005 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 8006 | if (num_blocks > 0) { repeat; } |
| 8007 | } |
| 8008 | [] L1CTL.receive { repeat; } |
| 8009 | } |
| 8010 | |
| 8011 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 8012 | runs on ConnHdlr return octetstring { |
| 8013 | /* Command the L1 to apply received parameters */ |
| 8014 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 8015 | |
| 8016 | /* Dummy measurement report (the results are invalid) */ |
| 8017 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 8018 | } |
| 8019 | |
| 8020 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 8021 | runs on ConnHdlr return octetstring { |
| 8022 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 8023 | setverdict(fail, "Unexpected MS Power level change: ", |
| 8024 | g_pars.l1_pars.ms_power_level, " -> ", |
| 8025 | l1h.ms_power_lvl); |
| 8026 | } |
| 8027 | |
| 8028 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 8029 | } |
| 8030 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8031 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 8032 | runs on ConnHdlr return octetstring { |
| 8033 | /* UL RSSI oscillation driven by SACCH block number */ |
| 8034 | if (num_blocks rem 2 == 0) { |
| 8035 | f_trxc_fake_rssi(-100); |
| 8036 | } else { |
| 8037 | f_trxc_fake_rssi(-50); |
| 8038 | } |
| 8039 | |
| 8040 | /* Make sure that MS power level remains constant */ |
| 8041 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 8042 | } |
| 8043 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8044 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 8045 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 8046 | runs on ConnHdlr { |
| 8047 | var integer num_blocks := 8; |
| 8048 | timer T := int2float(num_blocks); |
| 8049 | |
| 8050 | f_l1_tune(L1CTL); |
| 8051 | RSL.clear; |
| 8052 | |
| 8053 | /* These IEs are needed for autonomous MS power control */ |
| 8054 | var template (value) RSL_IE_List ies := { |
| 8055 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8056 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 8057 | }), |
| 8058 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 8059 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 8060 | }) |
| 8061 | }; |
| 8062 | |
| 8063 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 8064 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 8065 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8066 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 8067 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8068 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8069 | /* Establish a dedicated channel */ |
| 8070 | f_est_dchan(more_ies := valueof(ies)); |
| 8071 | |
| 8072 | L1CTL.clear; |
| 8073 | T.start; |
| 8074 | alt { |
| 8075 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 8076 | [] T.timeout { |
| 8077 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 8078 | num_blocks, " were not handled"); |
| 8079 | } |
| 8080 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 8081 | |
| 8082 | /* Release the channel */ |
| 8083 | f_rsl_chan_deact(); |
| 8084 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8085 | } |
| 8086 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 8087 | var ConnHdlr vc_conn; |
| 8088 | var ConnHdlrPars pars; |
| 8089 | |
| 8090 | f_init(); |
| 8091 | |
| 8092 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 8093 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 8094 | |
| 8095 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 8096 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 8097 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 8098 | |
| 8099 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 8100 | pars, trxc_comp := true); |
| 8101 | vc_conn.done; |
| 8102 | } |
| 8103 | |
| 8104 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 8105 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8106 | } |
| 8107 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8108 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 8109 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 8110 | runs on ConnHdlr { |
| 8111 | var integer num_blocks := 16; |
| 8112 | timer T := int2float(num_blocks); |
| 8113 | |
| 8114 | f_l1_tune(L1CTL); |
| 8115 | RSL.clear; |
| 8116 | |
| 8117 | /* These IEs are needed for autonomous MS power control */ |
| 8118 | var template (value) RSL_IE_List ies := { |
| 8119 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8120 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 8121 | }), |
| 8122 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 8123 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 8124 | }) |
| 8125 | }; |
| 8126 | |
| 8127 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 8128 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 8129 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8130 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 8131 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8132 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8133 | /* Establish a dedicated channel */ |
| 8134 | f_est_dchan(more_ies := valueof(ies)); |
| 8135 | |
| 8136 | L1CTL.clear; |
| 8137 | T.start; |
| 8138 | alt { |
| 8139 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 8140 | [] T.timeout { |
| 8141 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 8142 | num_blocks, " were not handled"); |
| 8143 | } |
| 8144 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 8145 | |
| 8146 | /* Release the channel */ |
| 8147 | f_rsl_chan_deact(); |
| 8148 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8149 | } |
| 8150 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 8151 | var ConnHdlr vc_conn; |
| 8152 | var ConnHdlrPars pars; |
| 8153 | |
| 8154 | f_init(); |
| 8155 | |
| 8156 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 8157 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 8158 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 8159 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 8160 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 8161 | |
| 8162 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 8163 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 8164 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 8165 | |
| 8166 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 8167 | pars, trxc_comp := true); |
| 8168 | vc_conn.done; |
| 8169 | } |
| 8170 | |
| 8171 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 8172 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8173 | } |
| 8174 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8175 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 8176 | var template L1ctlDlMessage tr_bad_frame; |
| 8177 | var L1ctlDlMessage l1_dl; |
| 8178 | timer T := 8.0; |
| 8179 | |
| 8180 | f_l1_tune(L1CTL); |
| 8181 | RSL.clear; |
| 8182 | |
| 8183 | f_est_dchan(); |
| 8184 | |
| 8185 | /* There may be a few errors right after the channel activation */ |
| 8186 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 8187 | L1CTL.clear; |
| 8188 | |
| 8189 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 8190 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 8191 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 8192 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 8193 | tr_bad_frame.payload := ?; |
| 8194 | |
| 8195 | T.start; |
| 8196 | alt { |
| 8197 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 8198 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 8199 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 8200 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 8201 | } |
| 8202 | [] as_l1_sacch(); |
| 8203 | [] L1CTL.receive { repeat; } |
| 8204 | [] T.timeout { |
| 8205 | /* We're done, break the loop */ |
| 8206 | setverdict(pass); |
| 8207 | } |
| 8208 | } |
| 8209 | |
| 8210 | f_rsl_chan_deact(); |
| 8211 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8212 | } |
| 8213 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 8214 | var ConnHdlr vc_conn; |
| 8215 | var ConnHdlrPars pars; |
| 8216 | |
| 8217 | f_init(); |
| 8218 | |
| 8219 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8220 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8221 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8222 | vc_conn.done; |
| 8223 | } |
| 8224 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 8225 | var ConnHdlr vc_conn; |
| 8226 | var ConnHdlrPars pars; |
| 8227 | |
| 8228 | f_init(); |
| 8229 | |
| 8230 | /* TS5, TCH/H, V1 (HR codec) */ |
| 8231 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8232 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8233 | vc_conn.done; |
| 8234 | } |
| 8235 | |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8236 | /* Verify handling of Downlink and Uplink speech frames */ |
| 8237 | private function f_TC_speech_rtp(charstring id) runs on ConnHdlr { |
| 8238 | var L1ctlDlMessage l1_dl; |
| 8239 | var PDU_RTP rtp_pdu; |
| 8240 | var octetstring pl; |
| 8241 | timer Td, Tu; |
| 8242 | |
| 8243 | f_l1_tune(L1CTL); |
| 8244 | f_est_dchan(); |
| 8245 | |
| 8246 | /* Activate the RTP emulation */ |
| 8247 | pl := f_rnd_octstring(6); |
| 8248 | f_rtpem_activate(pl); |
| 8249 | |
| 8250 | /* Give the scheduler some time to fill up the buffers */ |
| 8251 | f_sleep(2.0); |
| 8252 | L1CTL.clear; |
| 8253 | RSL.clear; |
| 8254 | |
| 8255 | /* Make sure that Downlink frames are received at the UE */ |
| 8256 | Td.start(2.0); |
| 8257 | alt { |
| 8258 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl { |
| 8259 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8260 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8261 | l1_dl.payload.traffic_ind.data)); |
| 8262 | setverdict(pass); |
| 8263 | } |
| 8264 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8265 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8266 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8267 | "expected (", pl, ")"); |
| 8268 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8269 | } |
| 8270 | [] as_l1_sacch(); |
| 8271 | [] L1CTL.receive { repeat; } |
| 8272 | [] Td.timeout { |
| 8273 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8274 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8275 | } |
| 8276 | } |
| 8277 | |
| 8278 | /* Make sure that Uplink frames are received at the BTS */ |
| 8279 | RTPEM_DATA.clear; |
| 8280 | Tu.start(2.0); |
| 8281 | alt { |
| 8282 | [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu { |
| 8283 | if (rtp_pdu.data != pl) |
| 8284 | { repeat; } |
| 8285 | } |
| 8286 | [] RTPEM_DATA.receive { repeat; } |
| 8287 | [] Tu.timeout { |
| 8288 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8289 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8290 | } |
| 8291 | } |
| 8292 | |
| 8293 | f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE); |
| 8294 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8295 | f_rsl_chan_deact(); |
| 8296 | f_rslem_unregister(0, g_chan_nr); |
| 8297 | } |
| 8298 | testcase TC_speech_rtp_tchf() runs on test_CT { |
| 8299 | var ConnHdlr vc_conn; |
| 8300 | var ConnHdlrPars pars; |
| 8301 | |
| 8302 | f_init(); |
| 8303 | |
| 8304 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8305 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8306 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8307 | vc_conn.done; |
| 8308 | |
| 8309 | /* TS1, TCH/F, V2 (EFR codec) */ |
| 8310 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))); |
| 8311 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8312 | vc_conn.done; |
| 8313 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8314 | /* TS1, TCH/F, V3 (AMR codec) */ |
| 8315 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))); |
Vadim Yanitskiy | fcce705 | 2022-09-14 15:07:23 +0700 | [diff] [blame] | 8316 | pars.mr_conf := valueof(ts_RSL_MultirateCfg); |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8317 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8318 | vc_conn.done; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8319 | |
| 8320 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8321 | } |
| 8322 | testcase TC_speech_rtp_tchh() runs on test_CT { |
| 8323 | var ConnHdlr vc_conn; |
| 8324 | var ConnHdlrPars pars; |
| 8325 | |
| 8326 | f_init(); |
| 8327 | |
| 8328 | /* TS5, TCH/H0, V1 (HR codec) */ |
| 8329 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8330 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8331 | vc_conn.done; |
| 8332 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8333 | /* TS1, TCH/H0, V3 (AMR codec) */ |
| 8334 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))); |
Vadim Yanitskiy | fcce705 | 2022-09-14 15:07:23 +0700 | [diff] [blame] | 8335 | pars.mr_conf := valueof(ts_RSL_MultirateCfg); |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8336 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8337 | vc_conn.done; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8338 | |
| 8339 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8340 | } |
| 8341 | |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 8342 | |
| 8343 | /* Verify handling of Downlink and Uplink Osmux speech frames */ |
| 8344 | private function f_TC_speech_osmux(charstring id) runs on ConnHdlr { |
| 8345 | var L1ctlDlMessage l1_dl; |
| 8346 | var OSMUX_PDU osmux_pdu; |
| 8347 | var octetstring pl; |
| 8348 | var octetstring exp_rtp_pl; |
| 8349 | timer Td, Tu; |
| 8350 | |
| 8351 | f_l1_tune(L1CTL); |
| 8352 | f_est_dchan(); |
| 8353 | |
| 8354 | /* Activate the RTP emulation */ |
| 8355 | pl := f_rnd_octstring(6); |
| 8356 | f_osmuxem_activate(pl); |
| 8357 | |
| 8358 | /* Give the scheduler some time to fill up the buffers */ |
| 8359 | f_sleep(2.0); |
| 8360 | L1CTL.clear; |
| 8361 | RSL.clear; |
| 8362 | |
| 8363 | /* we transmit using AMR_FT_2 (5.90), see t_TxHandleAMR590 in f_osmuxem_activate() */ |
| 8364 | var integer amr_ft := get_start_amr_ft(); |
| 8365 | var integer amr_pl_len := f_amrft_payload_len(amr_ft); |
| 8366 | var octetstring hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 8367 | pl := f_osmux_gen_expected_rx_rtp_payload(amr_ft, pl); |
| 8368 | exp_rtp_pl := hdr & pl; |
| 8369 | |
| 8370 | /* Make sure that Downlink frames are received at the UE */ |
| 8371 | Td.start(2.0); |
| 8372 | alt { |
| 8373 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := exp_rtp_pl)) -> value l1_dl { |
| 8374 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8375 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8376 | l1_dl.payload.traffic_ind.data)); |
| 8377 | setverdict(pass); |
| 8378 | } |
| 8379 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8380 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8381 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8382 | "expected (", exp_rtp_pl, ")"); |
| 8383 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8384 | } |
| 8385 | [] as_l1_sacch(); |
| 8386 | [] L1CTL.receive { repeat; } |
| 8387 | [] Td.timeout { |
| 8388 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8389 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8390 | } |
| 8391 | } |
| 8392 | |
| 8393 | /* Make sure that Uplink frames are received at the BTS */ |
| 8394 | OsmuxEM_DATA.clear; |
| 8395 | var template (present) OSMUX_PDU osmux_pdu_exp := tr_PDU_Osmux_AMR(cid := g_pars.loc_osmux_cid, |
| 8396 | amr_ft := amr_ft, |
| 8397 | amr_cmr := amr_ft); |
| 8398 | Tu.start(2.0); |
| 8399 | alt { |
| 8400 | [] OsmuxEM_DATA.receive(osmux_pdu_exp) -> value osmux_pdu { |
| 8401 | var boolean matched := false; |
| 8402 | for (var integer i := 0; i < osmux_pdu.osmux_amr.header.ctr + 1; i := i + 1) { |
| 8403 | var octetstring rx_pl; |
| 8404 | rx_pl := f_osmux_amr_get_nth_amr_payload(osmux_pdu.osmux_amr, i); |
| 8405 | log("got ", rx_pl, " vs exp ", pl); |
| 8406 | if (rx_pl == pl) { |
| 8407 | matched := true; |
| 8408 | break; |
| 8409 | } |
| 8410 | } |
| 8411 | if (not matched) { |
| 8412 | repeat; |
| 8413 | } |
| 8414 | } |
| 8415 | [] OsmuxEM_DATA.receive { repeat; } |
| 8416 | [] Tu.timeout { |
| 8417 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8418 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8419 | } |
| 8420 | } |
| 8421 | |
| 8422 | f_osmuxem_mode(OsmuxEM_CTRL, OSMUXEM_MODE_NONE); |
| 8423 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8424 | f_rsl_chan_deact(); |
| 8425 | f_rslem_unregister(0, g_chan_nr); |
| 8426 | } |
| 8427 | testcase TC_speech_osmux_tchf() runs on test_CT { |
| 8428 | var ConnHdlr vc_conn; |
| 8429 | var ConnHdlrPars pars; |
| 8430 | |
| 8431 | f_init(); |
| 8432 | |
| 8433 | /* TS5, TCH/H0, V3 (AMR codec) */ |
| 8434 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))); |
Vadim Yanitskiy | fcce705 | 2022-09-14 15:07:23 +0700 | [diff] [blame] | 8435 | pars.mr_conf := valueof(ts_RSL_MultirateCfg); |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 8436 | vc_conn := f_start_handler(refers(f_TC_speech_osmux), pars); |
| 8437 | vc_conn.done; |
| 8438 | |
| 8439 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8440 | } |
| 8441 | testcase TC_speech_osmux_tchh() runs on test_CT { |
| 8442 | var ConnHdlr vc_conn; |
| 8443 | var ConnHdlrPars pars; |
| 8444 | |
| 8445 | f_init(); |
| 8446 | |
| 8447 | /* TS5, TCH/H0, V3 (AMR codec) */ |
| 8448 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))); |
Vadim Yanitskiy | fcce705 | 2022-09-14 15:07:23 +0700 | [diff] [blame] | 8449 | pars.mr_conf := valueof(ts_RSL_MultirateCfg); |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 8450 | vc_conn := f_start_handler(refers(f_TC_speech_osmux), pars); |
| 8451 | vc_conn.done; |
| 8452 | |
| 8453 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8454 | } |
| 8455 | |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8456 | private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr { |
| 8457 | var GsmFrameNumber fn; |
| 8458 | var ChannelDescription ch_desc; |
| 8459 | var integer ra := 23; |
| 8460 | |
| 8461 | f_l1_tune(L1CTL); |
| 8462 | RSL.clear; |
| 8463 | |
| 8464 | /* Send RACH request and wait for ChanReq */ |
| 8465 | fn := f_rach_req_wait_chan_rqd(ra); |
| 8466 | |
| 8467 | /* The BSC already sends the Immediate Assignment, before the channel is active. |
| 8468 | * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM |
| 8469 | * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the |
| 8470 | * IMM ASS. So move the IMM ASS even before the Chan Activ.) */ |
| 8471 | if (g_pars.fhp.enabled) { |
| 8472 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8473 | } else { |
| 8474 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8475 | } |
| 8476 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8477 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8478 | |
| 8479 | /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC |
| 8480 | * requests Chan Activ, to make sure the RR IMM ASS is held back. */ |
| 8481 | var L1ctlDlMessage dl; |
| 8482 | var GsmRrMessage rr; |
| 8483 | |
| 8484 | var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn); |
| 8485 | rr_imm_ass.payload.imm_ass.ded_or_tbf := ?; |
| 8486 | rr_imm_ass.payload.imm_ass.pkt_chan_desc := *; |
| 8487 | rr_imm_ass.payload.imm_ass.chan_desc := *; |
| 8488 | |
| 8489 | timer T := 1.0; |
| 8490 | T.start; |
| 8491 | alt { |
| 8492 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 8493 | rr := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 8494 | if (match(rr, rr_imm_ass)) { |
| 8495 | setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately"); |
| 8496 | mtc.stop; |
| 8497 | } else { |
| 8498 | repeat; |
| 8499 | } |
| 8500 | } |
| 8501 | [] L1CTL.receive { repeat; } |
| 8502 | [] T.timeout; |
| 8503 | } |
| 8504 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA)); |
| 8505 | RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)); |
| 8506 | |
| 8507 | /* Now expect the IMM ASS on Um */ |
| 8508 | f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8509 | setverdict(pass); |
| 8510 | |
| 8511 | /* Release the channel */ |
| 8512 | f_rsl_chan_deact(); |
| 8513 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8514 | } |
| 8515 | |
| 8516 | testcase TC_early_immediate_assignment() runs on test_CT { |
| 8517 | var ConnHdlr vc_conn; |
| 8518 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 8519 | f_init(); |
| 8520 | vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars); |
| 8521 | vc_conn.done; |
| 8522 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8523 | } |
| 8524 | |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8525 | private function f_TC_est_dchan(charstring id) runs on ConnHdlr { |
| 8526 | var integer ra := oct2int(f_rnd_ra_cs()); |
| 8527 | var ChannelDescription ch_desc; |
| 8528 | |
| 8529 | /* Tune the MS to BCCH */ |
| 8530 | f_l1_tune(L1CTL); |
| 8531 | |
| 8532 | /* Send RACH request and wait for ChanReq */ |
| 8533 | var GsmFrameNumber fn := f_rach_req_wait_chan_rqd(ra); |
| 8534 | |
| 8535 | /* Activate channel on the BTS side */ |
| 8536 | f_rsl_chan_act(g_pars.chan_mode); |
| 8537 | |
| 8538 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 8539 | if (g_pars.fhp.enabled) { |
| 8540 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8541 | } else { |
| 8542 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8543 | } |
| 8544 | |
| 8545 | /* Send IMM.ASS via CCHAN */ |
| 8546 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8547 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8548 | |
| 8549 | /* Receive IMM.ASS on the MS side */ |
| 8550 | var ImmediateAssignment imm_ass := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8551 | |
| 8552 | /* Match the Channel Description IE in received IMM.ASS */ |
| 8553 | if (not match(imm_ass.chan_desc, ch_desc)) { |
| 8554 | setverdict(fail, "Channel Description IE does not match"); |
| 8555 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8556 | } |
| 8557 | |
| 8558 | /* Tune the MS to a dedicated channel indicated in the IMM.ASS */ |
| 8559 | f_L1CTL_DM_EST_REQ_IA(L1CTL, imm_ass, g_pars.fhp.ma); |
| 8560 | |
| 8561 | /* Expect SACCH frames on Downlink */ |
| 8562 | L1CTL.clear; |
| 8563 | f_exp_sacch(true); |
| 8564 | |
| 8565 | /* We're done, deactivate and release */ |
| 8566 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8567 | f_rsl_chan_deact(); |
| 8568 | } |
| 8569 | testcase TC_est_dchan() runs on test_CT { |
| 8570 | var ConnHdlr vc_conn; |
| 8571 | var ConnHdlrPars pars; |
| 8572 | |
| 8573 | f_init(); |
| 8574 | |
| 8575 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 8576 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 8577 | vc_conn := f_start_handler(refers(f_TC_est_dchan), pars); |
| 8578 | vc_conn.done; |
| 8579 | } |
| 8580 | |
| 8581 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8582 | } |
| 8583 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8584 | private type record TopTestCase { |
| 8585 | RSL_IE_BS_Power bs_power, |
| 8586 | RSL_IE_OSMO_TopAcchCap top_cap, |
| 8587 | record of TopTestStep steps |
| 8588 | }; |
| 8589 | private type record TopTestStep { |
| 8590 | MeasurementResults meas_res optional, |
| 8591 | GsmRxLev overpower_sacch, |
| 8592 | GsmRxLev overpower_facch |
| 8593 | }; |
| 8594 | |
| 8595 | private function f_rxlev_match(template (present) RslLinkId link_id, |
| 8596 | template (present) GsmRxLev rxlev) |
| 8597 | runs on ConnHdlr { |
| 8598 | var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id); |
| 8599 | if (not match(dl.dl_info.rx_level, rxlev)) { |
| 8600 | setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level, |
| 8601 | " does not match expected RxLev := ", rxlev); |
| 8602 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8603 | } |
| 8604 | } |
| 8605 | |
| 8606 | private function f_TC_acch_overpower(charstring id) runs on ConnHdlr { |
| 8607 | var TopTestCase tc := g_pars.spec.top; |
| 8608 | var GsmRxLev rxlev_dcch; |
| 8609 | var L1ctlDlMessage dl; |
| 8610 | |
| 8611 | /* Wait for Pau ramping to complete */ |
| 8612 | f_sleep(6.0); |
| 8613 | |
| 8614 | f_l1_tune(L1CTL); |
| 8615 | L1CTL.clear; |
| 8616 | RSL.clear; |
| 8617 | |
| 8618 | /* Measure RxLev(BCCH), calculate RxLev(DCCH) */ |
| 8619 | dl := f_L1CTL_rx_data(L1CTL, t_RslChanNr_BCCH(0)); |
| 8620 | rxlev_dcch := dl.dl_info.rx_level - (tc.bs_power.power_level * 2); |
| 8621 | |
| 8622 | log("RxLev(BCCH) := ", dl.dl_info.rx_level); |
| 8623 | log("Expected RxLev(DCCH) := ", rxlev_dcch); |
| 8624 | |
| 8625 | /* Additional IEs for the CHANnel ACTIVation message */ |
| 8626 | var template (value) RSL_IE_List ies := { |
| 8627 | /* Employ BS power control in static mode */ |
| 8628 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8629 | bs_power := tc.bs_power |
| 8630 | }), |
| 8631 | /* Indicate the given Temporary Overpower capability */ |
| 8632 | t_RSL_IE(RSL_IE_OSMO_TOP_ACCH_CAP, RSL_IE_Body:{ |
| 8633 | top_acch_cap := tc.top_cap |
| 8634 | }) |
| 8635 | }; |
| 8636 | |
| 8637 | /* Establish a dedicated channel */ |
| 8638 | f_est_dchan(more_ies := valueof(ies)); |
| 8639 | |
| 8640 | /* Give it some time to stabilize */ |
| 8641 | f_sleep(0.480 * 2.0); |
| 8642 | L1CTL.clear; |
| 8643 | RSL.clear; |
| 8644 | |
| 8645 | for (var integer i := 0; i < lengthof(tc.steps); i := i + 1) { |
| 8646 | var TopTestStep step := tc.steps[i]; |
| 8647 | var GsmRxLev rxlev_facch := rxlev_dcch + step.overpower_facch; |
| 8648 | var GsmRxLev rxlev_sacch := rxlev_dcch + step.overpower_sacch; |
| 8649 | |
| 8650 | log("Executing step[", i, "] := ", step); |
| 8651 | |
| 8652 | /* Send RR Measurement Report (if present) */ |
| 8653 | if (ispresent(step.meas_res)) { |
| 8654 | f_transceive_meas_rep(step.meas_res); |
| 8655 | f_sleep(0.480 * 2.0); |
| 8656 | L1CTL.clear; |
| 8657 | } |
| 8658 | |
| 8659 | /* Check RxLev on both FACCH and SACCH */ |
| 8660 | f_rxlev_match(tr_RslLinkID_DCCH(?), rxlev_facch); |
| 8661 | f_rxlev_match(tr_RslLinkID_SACCH(?), rxlev_sacch); |
| 8662 | |
| 8663 | setverdict(pass); |
| 8664 | } |
| 8665 | } |
| 8666 | testcase TC_acch_overpower_rxqual_thresh() runs on test_CT { |
| 8667 | var ConnHdlrPars pars; |
| 8668 | var ConnHdlr vc_conn; |
| 8669 | |
| 8670 | f_init(); |
| 8671 | |
| 8672 | /* Verify lower and upper RxQual thresholds */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8673 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8674 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8675 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8676 | steps := { |
| 8677 | /* Channel established, no overpower */ |
| 8678 | { meas_res := omit, |
| 8679 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8680 | |
| 8681 | /* Worst possible RxQual value, overpower of 4dB */ |
| 8682 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8683 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8684 | /* Worst possible RxQual value, disabling overpower */ |
| 8685 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8686 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8687 | |
| 8688 | /* Lower threshold not reached, no overpower */ |
| 8689 | { meas_res := ts_MeasurementResults(rxq_f := 1), |
| 8690 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8691 | /* Lower threshold not reached, no overpower */ |
| 8692 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8693 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8694 | /* Lower threshold reached, overpower of 4dB */ |
| 8695 | { meas_res := ts_MeasurementResults(rxq_f := 4), |
| 8696 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8697 | /* Upper threshold not reached, keeping overpower */ |
| 8698 | { meas_res := ts_MeasurementResults(rxq_f := 3), |
| 8699 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8700 | /* Upper threshold reached, disabling overpower */ |
| 8701 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8702 | overpower_sacch := 0, overpower_facch := 0 } |
| 8703 | } |
| 8704 | }; |
| 8705 | |
| 8706 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8707 | spec := { top := top }, trx_nr := 1)); |
| 8708 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8709 | vc_conn.done; |
| 8710 | |
| 8711 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8712 | } |
| 8713 | testcase TC_acch_overpower_rxqual_thresh_dtx() runs on test_CT { |
| 8714 | var ConnHdlrPars pars; |
| 8715 | var ConnHdlr vc_conn; |
| 8716 | |
| 8717 | f_init(); |
| 8718 | |
| 8719 | /* Verify handling of FULL and SUB values */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8720 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8721 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8722 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8723 | steps := { |
| 8724 | /* Channel established, no overpower */ |
| 8725 | { meas_res := omit, |
| 8726 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8727 | |
| 8728 | /* Invalid measurement results, no overpower */ |
| 8729 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8730 | rxq_s := 7, |
| 8731 | valid := false), |
| 8732 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8733 | |
| 8734 | /* DTXu was in use, no overpower */ |
| 8735 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8736 | rxq_s := 0, |
| 8737 | dtx_used := true), |
| 8738 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8739 | /* DTXu was in use, overpower of 4 dB */ |
| 8740 | { meas_res := ts_MeasurementResults(rxq_f := 0, |
| 8741 | rxq_s := 7, |
| 8742 | dtx_used := true), |
| 8743 | overpower_sacch := 4, overpower_facch := 4 } |
| 8744 | } |
| 8745 | }; |
| 8746 | |
| 8747 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8748 | spec := { top := top }, trx_nr := 1)); |
| 8749 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8750 | vc_conn.done; |
| 8751 | |
| 8752 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8753 | } |
| 8754 | testcase TC_acch_overpower_always_on_facch() runs on test_CT { |
| 8755 | var ConnHdlrPars pars; |
| 8756 | var ConnHdlr vc_conn; |
| 8757 | |
| 8758 | f_init(); |
| 8759 | |
| 8760 | /* Overpower is always on, SACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8761 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8762 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8763 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8764 | rxqual := 0, /* always on */ |
| 8765 | sacch_enable := false), |
| 8766 | steps := { |
| 8767 | /* Channel established, FACCH overpower */ |
| 8768 | { meas_res := omit, |
| 8769 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8770 | /* MS indicates good RxQual, no difference */ |
| 8771 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8772 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8773 | /* MS indicates bad RxQual, no difference */ |
| 8774 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8775 | overpower_sacch := 0, overpower_facch := 4 } |
| 8776 | } |
| 8777 | }; |
| 8778 | |
| 8779 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8780 | spec := { top := top }, trx_nr := 1)); |
| 8781 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8782 | vc_conn.done; |
| 8783 | |
| 8784 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8785 | } |
| 8786 | testcase TC_acch_overpower_always_on_sacch() runs on test_CT { |
| 8787 | var ConnHdlrPars pars; |
| 8788 | var ConnHdlr vc_conn; |
| 8789 | |
| 8790 | f_init(); |
| 8791 | |
| 8792 | /* Overpower is always on, FACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8793 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8794 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8795 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8796 | rxqual := 0, /* always on */ |
| 8797 | facch_enable := false), |
| 8798 | steps := { |
| 8799 | /* Channel established, SACCH overpower */ |
| 8800 | { meas_res := omit, |
| 8801 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8802 | /* MS indicates good RxQual, no difference */ |
| 8803 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8804 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8805 | /* MS indicates bad RxQual, no difference */ |
| 8806 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8807 | overpower_sacch := 4, overpower_facch := 0 } |
| 8808 | } |
| 8809 | }; |
| 8810 | |
| 8811 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8812 | spec := { top := top }, trx_nr := 1)); |
| 8813 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8814 | vc_conn.done; |
| 8815 | |
| 8816 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8817 | } |
| 8818 | testcase TC_acch_overpower_limit() runs on test_CT { |
| 8819 | var ConnHdlrPars pars; |
| 8820 | var ConnHdlr vc_conn; |
| 8821 | |
| 8822 | f_init(); |
| 8823 | |
| 8824 | /* Overpower higher than current power reduction level (2dB) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8825 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8826 | bs_power := ts_RSL_IE_BS_Power(1), /* 1 x 2dB = 2dB */ |
| 8827 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8828 | rxqual := 0 /* always on */), |
| 8829 | steps := { |
| 8830 | /* Channel established, ACCH overpower of 2dB */ |
| 8831 | { meas_res := omit, |
| 8832 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8833 | /* MS indicates good RxQual, no difference */ |
| 8834 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8835 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8836 | /* MS indicates bad RxQual, no difference */ |
| 8837 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8838 | overpower_sacch := 2, overpower_facch := 2 } |
| 8839 | } |
| 8840 | }; |
| 8841 | |
| 8842 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8843 | spec := { top := top }, trx_nr := 1)); |
| 8844 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8845 | vc_conn.done; |
| 8846 | |
| 8847 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8848 | } |
| 8849 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8850 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 8851 | /* protocol error as per 44.006 */ |
| 8852 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 8853 | /* repetition of SABM or DISC N200 times without ACK */ |
| 8854 | /* receptiom of SABM in multi-frame established state */ |
| 8855 | |
| 8856 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8857 | /* TODO Areas: |
| 8858 | |
| 8859 | * channel activation |
| 8860 | ** with BS_Power / MS_Power, bypassing power control loop |
| 8861 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8862 | ** with timing advance from initial activation on |
| 8863 | * mode modify |
| 8864 | ** encryption |
| 8865 | ** multirate |
| 8866 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8867 | ** unsupported algorithm |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8868 | * BS Power Control |
| 8869 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8870 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8871 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8872 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8873 | ** DATA_IND from BTS->PCU |
| 8874 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8875 | |
| 8876 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8877 | |
| 8878 | control { |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8879 | execute( TC_est_dchan() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8880 | execute( TC_chan_act_stress() ); |
| 8881 | execute( TC_chan_act_react() ); |
| 8882 | execute( TC_chan_deact_not_active() ); |
| 8883 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 8884 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 8885 | execute( TC_sacch_filling() ); |
| 8886 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 8887 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 8888 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 8889 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 8890 | execute( TC_sacch_chan_act_ho_async() ); |
| 8891 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8892 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 8893 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8894 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 8895 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 8896 | execute( TC_ho_rach() ); |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 8897 | execute( TC_ho_physical_info() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 8898 | execute( TC_rach_load_idle_thresh0() ); |
| 8899 | execute( TC_rach_load_idle_below_thresh() ); |
| 8900 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8901 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8902 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8903 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8904 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 8905 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8906 | execute( TC_meas_res_sign_tchf() ); |
| 8907 | execute( TC_meas_res_sign_tchh() ); |
| 8908 | execute( TC_meas_res_sign_sdcch4() ); |
| 8909 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 8910 | execute( TC_meas_res_sign_tchh_toa256() ); |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 8911 | execute( TC_meas_res_speech_tchf_sapi3() ); |
| 8912 | execute( TC_meas_res_speech_tchh_sapi3() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 8913 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Daniel Willmann | bc61276 | 2022-12-19 15:15:52 +0100 | [diff] [blame] | 8914 | execute( TC_tx_power_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 8915 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 8916 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 8917 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 8918 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 8919 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 8920 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 8921 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 8922 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 8923 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 8924 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 8925 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 8926 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 8927 | execute( TC_rsl_modify_encr() ); |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 8928 | execute( TC_rsl_rf_resource_ind() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8929 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8930 | execute( TC_paging_imsi_80percent() ); |
| 8931 | execute( TC_paging_tmsi_80percent() ); |
| 8932 | execute( TC_paging_imsi_200percent() ); |
| 8933 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 8934 | execute( TC_rsl_protocol_error() ); |
| 8935 | execute( TC_rsl_mand_ie_error() ); |
| 8936 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8937 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 8938 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8939 | execute( TC_si_sched_2bis() ); |
| 8940 | execute( TC_si_sched_2ter() ); |
| 8941 | execute( TC_si_sched_2ter_2bis() ); |
| 8942 | execute( TC_si_sched_2quater() ); |
| 8943 | execute( TC_si_sched_13() ); |
| 8944 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 8945 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 8946 | execute( TC_ipa_crcx_twice_not_active() ); |
| 8947 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 8948 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 8949 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 8950 | execute( TC_ipa_crcx_ack_addr() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8951 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8952 | if (mp_pcu_socket != "") { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 8953 | execute( TC_paging_imsi_200percent_with_ps() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8954 | execute( TC_pcu_act_req() ); |
| 8955 | execute( TC_pcu_act_req_wrong_ts() ); |
| 8956 | execute( TC_pcu_act_req_wrong_bts() ); |
| 8957 | execute( TC_pcu_act_req_wrong_trx() ); |
| 8958 | execute( TC_pcu_deact_req() ); |
| 8959 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 8960 | execute( TC_pcu_ver_si1() ); |
| 8961 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8962 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8963 | if (mp_l1_supports_gprs) { |
| 8964 | execute( TC_pcu_data_req_pdtch() ); |
| 8965 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 8966 | execute( TC_pcu_data_req_wrong_bts() ); |
| 8967 | execute( TC_pcu_data_req_wrong_trx() ); |
| 8968 | execute( TC_pcu_data_req_wrong_ts() ); |
| 8969 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8970 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 8971 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8972 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 8973 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8974 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 8975 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 8976 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 8977 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8978 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 8979 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 8980 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 8981 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 8982 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 8983 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 8984 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8985 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8986 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8987 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8988 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8989 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8990 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 8991 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 8992 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 8993 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 8994 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 8995 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 8996 | execute( TC_pcu_info_ind_fh_params() ); |
| 8997 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 8998 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 8999 | execute( TC_pcu_socket_two_nsvc() ); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 9000 | execute( TC_pcu_interf_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 9001 | } else { |
| 9002 | log("PCU socket path not available, skipping PCU tests"); |
| 9003 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 9004 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 9005 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 9006 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 9007 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 9008 | execute( TC_dyn_osmo_pdch_sdcch8_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 9009 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 9010 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 9011 | |
| 9012 | execute( TC_rll_est_ind() ); |
| 9013 | execute( TC_rll_est_req_DCCH_3() ); |
| 9014 | execute( TC_rll_est_req_ACCH_3() ); |
| 9015 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 9016 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 9017 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 9018 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 9019 | execute( TC_rll_rel_req() ); |
| 9020 | execute( TC_rll_unit_data_req_DCCH() ); |
| 9021 | execute( TC_rll_unit_data_req_ACCH() ); |
| 9022 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 9023 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 9024 | |
| 9025 | execute( TC_chan_act_a51() ); |
| 9026 | execute( TC_chan_act_a52() ); |
| 9027 | execute( TC_chan_act_a53() ); |
Vadim Yanitskiy | 8b4e046 | 2022-08-27 19:18:17 +0700 | [diff] [blame] | 9028 | execute( TC_chan_act_a54() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 9029 | execute( TC_encr_cmd_a51() ); |
| 9030 | execute( TC_encr_cmd_a52() ); |
| 9031 | execute( TC_encr_cmd_a53() ); |
Vadim Yanitskiy | 8b4e046 | 2022-08-27 19:18:17 +0700 | [diff] [blame] | 9032 | execute( TC_encr_cmd_a54() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 9033 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 9034 | execute( TC_err_rep_wrong_mdisc() ); |
| 9035 | execute( TC_err_rep_wrong_msg_type() ); |
| 9036 | execute( TC_err_rep_wrong_sequence() ); |
| 9037 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 9038 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 9039 | |
| 9040 | execute( TC_tch_sign_l2_fill_frame() ); |
| 9041 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 9042 | |
| 9043 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 9044 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 9045 | |
| 9046 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 9047 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 9048 | |
| 9049 | execute( TC_speech_no_rtp_tchf() ); |
| 9050 | execute( TC_speech_no_rtp_tchh() ); |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 9051 | execute( TC_speech_rtp_tchf() ); |
| 9052 | execute( TC_speech_rtp_tchh() ); |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 9053 | execute( TC_speech_osmux_tchf() ); |
| 9054 | execute( TC_speech_osmux_tchh() ); |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 9055 | |
| 9056 | execute( TC_early_immediate_assignment() ); |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 9057 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 9058 | execute( TC_acch_overpower_rxqual_thresh() ); |
| 9059 | execute( TC_acch_overpower_rxqual_thresh_dtx() ); |
| 9060 | execute( TC_acch_overpower_always_on_facch() ); |
| 9061 | execute( TC_acch_overpower_always_on_sacch() ); |
| 9062 | execute( TC_acch_overpower_limit() ); |
| 9063 | |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 9064 | /* BEWARE: these test cases can potentially break the IUT or cause |
| 9065 | * weird/unexpected behavior. Ensure that they are executed last. */ |
| 9066 | execute( TC_dyn_osmo_pdch_tchh_race_act() ); |
| 9067 | execute( TC_dyn_osmo_pdch_sdcch8_race_act() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 9068 | } |
| 9069 | |
| 9070 | |
| 9071 | } |