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(); |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 782 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 783 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 784 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 785 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 786 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 787 | return rx; |
| 788 | } |
| 789 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 790 | friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, |
| 791 | charstring id, boolean ignore_other := false) |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 792 | runs on ConnHdlr { |
| 793 | 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] | 794 | } |
| 795 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 796 | /* Send the given measurement results to the IUT over the Um interface */ |
| 797 | friend function f_send_meas_rep(template (value) MeasurementResults meas_res) |
| 798 | runs on ConnHdlr { |
| 799 | var template (value) SacchL1Header l1h; |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 800 | |
| 801 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta); |
| 802 | f_send_meas_rep_l1h(meas_res, l1h); |
| 803 | } |
| 804 | |
| 805 | /* Send the given measurement results and L1H to the IUT over the Um interface */ |
| 806 | friend function f_send_meas_rep_l1h(template (value) MeasurementResults meas_res, |
| 807 | template (value) SacchL1Header l1h) |
| 808 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 809 | var octetstring l2; |
| 810 | |
| 811 | /* RR Measurement Report to be sent */ |
| 812 | var GsmRrL3Message meas_rep := { |
| 813 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 814 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 815 | }; |
| 816 | |
| 817 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 818 | 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] | 819 | |
| 820 | log(%definitionId, "(): Tx SACCH L1 header: ", l1h); |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 821 | |
| 822 | /* Send RR Measurement Report over the Um interface */ |
| 823 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
| 824 | } |
| 825 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 826 | /* Send the given measurement results to the IUT over the Um interface, |
| 827 | * wait for the IUT to receive then and forward over the A-bis/RSL interface. */ |
| 828 | friend function f_transceive_meas_rep(template (value) MeasurementResults meas_res) |
| 829 | runs on ConnHdlr { |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 830 | var octetstring l3; |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 831 | timer T; |
| 832 | |
| 833 | /* RR Measurement Report to be sent */ |
| 834 | var GsmRrL3Message meas_rep := { |
| 835 | header := valueof(t_RrL3Header(MEASUREMENT_REPORT)), |
| 836 | payload := { meas_rep := { meas_res := valueof(meas_res) } } |
| 837 | }; |
| 838 | |
| 839 | /* TITAN has weird (and often unusable) padding model, so we pad here manaully */ |
| 840 | l3 := f_pad_oct(enc_GsmRrL3Message(meas_rep), 18, '00'O); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 841 | |
Vadim Yanitskiy | 9dd880f | 2022-08-01 19:22:18 +0700 | [diff] [blame] | 842 | f_send_meas_rep(meas_res); |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 843 | |
| 844 | /* Expect MEASurement RESult on the A-bis/RSL interface */ |
| 845 | T.start(2.0); |
| 846 | alt { |
| 847 | [] RSL.receive(tr_RSL_MEAS_RES_OSMO(g_chan_nr, l3_info := l3)) { |
| 848 | setverdict(pass); |
| 849 | } |
| 850 | [] RSL.receive { repeat; } |
| 851 | [] T.timeout { |
| 852 | setverdict(fail, "Timeout waiting for RSL MEASurement RESult"); |
| 853 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 854 | } |
| 855 | } |
| 856 | } |
| 857 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 858 | friend function f_rsl_chan_act(RSL_IE_ChannelMode mode, |
| 859 | boolean encr_enable := false, |
| 860 | RSL_IE_List more_ies := {}, |
| 861 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) |
| 862 | runs on ConnHdlr { |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 863 | 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] | 864 | if (encr_enable) { |
| 865 | /* append encryption related IEs, if requested */ |
| 866 | var RSL_IE_EncryptionInfo encr_info; |
| 867 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 868 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 869 | encr_info})) }; |
| 870 | } |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 871 | if (mode.coding_alg_rate == RSL_CMOD_SP_GSM3) { |
| 872 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_MR_CONFIG, |
| 873 | RSL_IE_Body:{multirate_cfg := g_pars.mr_conf})) }; |
| 874 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 875 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 876 | 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] | 877 | } |
| 878 | |
Vadim Yanitskiy | b2a90db | 2020-07-04 20:33:47 +0700 | [diff] [blame] | 879 | friend function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 880 | 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] | 881 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 882 | } |
| 883 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 884 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 885 | template RSL_IE_ChannelMode chan_mode, |
| 886 | template (omit) TestSpecUnion spec := omit, |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 887 | uint8_t trx_nr := 0, float t_guard := 20.0) := { |
| 888 | trx_nr := trx_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 889 | chan_nr := valueof(chan_nr), |
| 890 | chan_mode := valueof(chan_mode), |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 891 | mr_conf := omit, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 892 | t_guard := t_guard, |
| 893 | l1_pars := { |
| 894 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 895 | toa256_enabled := false, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 896 | meas_valid := true, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 897 | meas_ul := { |
| 898 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 899 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 900 | rxqual := 0 |
| 901 | }, |
| 902 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 903 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 904 | rxqual := 0 |
| 905 | } |
| 906 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 907 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 908 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 909 | ms_power_level := mp_ms_power_level_exp, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 910 | ms_actual_ta := mp_ms_actual_ta_exp, |
| 911 | facch_enabled := false |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 912 | }, |
Vadim Yanitskiy | e6c1755 | 2021-06-01 01:20:55 +0200 | [diff] [blame] | 913 | spec := spec, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 914 | encr := omit, |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 915 | bts0_band := omit, |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 916 | tsc := mp_tsc_def, |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 917 | fhp := { |
| 918 | enabled := false, |
| 919 | maio_hsn := ts_HsnMaio(0, 0), |
| 920 | ma_map := c_MA_null, |
Vadim Yanitskiy | 2b991b6 | 2020-11-14 21:40:41 +0700 | [diff] [blame] | 921 | ma := { } |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 922 | }, |
| 923 | loc_osmux_cid := trx_nr, |
| 924 | rem_osmux_cid := omit |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 925 | } |
| 926 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 927 | /* This altstep triggers on receipt of a L1CTL DATA.ind matching the given |
| 928 | * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */ |
| 929 | private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg, |
| 930 | template (present) octetstring tr_data := ?, |
| 931 | template (present) RslChannelNr chan_nr := ?, |
| 932 | template (present) RslLinkId link_id := ?) |
| 933 | runs on ConnHdlr { |
| 934 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg; |
| 935 | } |
| 936 | |
| 937 | /* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt |
| 938 | * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */ |
| 939 | private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?, |
| 940 | template (present) RslLinkId link_id := ?, |
| 941 | template (present) LapdmSapi sapi := ?, |
| 942 | boolean do_repeat := true) |
| 943 | runs on ConnHdlr { |
| 944 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O); |
| 945 | var L1ctlDlMessage dl_msg; |
| 946 | |
| 947 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) { |
| 948 | if (do_repeat) { |
| 949 | repeat; |
| 950 | } |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | /* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload |
| 955 | * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */ |
| 956 | private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame, |
| 957 | template (present) LapdmFrameAB tr_frame := ?, |
| 958 | template (present) RslLinkId link_id := ?) |
| 959 | runs on ConnHdlr { |
| 960 | var L1ctlDlMessage dl_msg; |
| 961 | |
| 962 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) { |
| 963 | frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload); |
| 964 | } |
| 965 | } |
| 966 | |
Vadim Yanitskiy | a144e3c | 2022-03-14 23:56:40 +0300 | [diff] [blame] | 967 | /* This altstep triggers on receipt of a Downlink SACCH containing a L2 payload |
| 968 | * that matches the given LAPDm frame, as well as the given SACCH L1 header. */ |
| 969 | private altstep as_dl_sacch_lapdm_ab(out SacchL1Header l1h, out LapdmFrameAB frame, |
| 970 | template (present) LapdmFrameAB tr_frame := ?, |
| 971 | template (present) SacchL1Header tr_l1h := ?, |
| 972 | template (present) GsmSapi sapi := ?) |
| 973 | runs on ConnHdlr { |
| 974 | var L1ctlDlMessage dl_msg; |
| 975 | template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi); |
| 976 | template (present) L1ctlDataReq tr_data := { |
| 977 | l1header := tr_l1h, |
| 978 | l2_payload := decmatch tr_frame |
| 979 | }; |
| 980 | |
| 981 | [] as_l1ctl_dl_msg(dl_msg, decmatch tr_data, g_chan_nr, link_id) { |
| 982 | var octetstring data := dl_msg.payload.data_ind.payload; |
| 983 | l1h := dec_SacchL1Header(substr(data, 0, 2)); |
| 984 | frame := dec_LapdmFrameAB(substr(data, 2, lengthof(data) - 2)); |
| 985 | } |
| 986 | } |
| 987 | |
Vadim Yanitskiy | f8a9df5 | 2022-03-12 13:29:26 +0300 | [diff] [blame] | 988 | /* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt |
| 989 | * of a LAPDm AB frame with a L3 payload matching the given template. The L3 |
| 990 | * payload is treated as PDU_ML3_NW_MS. */ |
| 991 | private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu, |
| 992 | template (present) PDU_ML3_NW_MS tr_pdu := ?, |
| 993 | template (present) GsmSapi sapi := 0) |
| 994 | runs on ConnHdlr { |
| 995 | template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu); |
| 996 | template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi); |
| 997 | var LapdmFrameAB lapdm_frame; |
| 998 | |
| 999 | [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) { |
| 1000 | pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload); |
| 1001 | } |
| 1002 | } |
| 1003 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1004 | /*********************************************************************** |
| 1005 | * Channel Activation / Deactivation |
| 1006 | ***********************************************************************/ |
| 1007 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1008 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1009 | private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1010 | for (var integer i := 0; i < 500; i := i+1) { |
| 1011 | f_rsl_chan_act(g_pars.chan_mode); |
| 1012 | f_rsl_chan_deact(); |
| 1013 | } |
| 1014 | setverdict(pass); |
| 1015 | } |
| 1016 | testcase TC_chan_act_stress() runs on test_CT { |
| 1017 | var ConnHdlr vc_conn; |
| 1018 | 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] | 1019 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1020 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 1021 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1022 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1023 | } |
| 1024 | |
| 1025 | /* Test if re-activation of an already active channel fails as expected */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1026 | private function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1027 | f_rsl_chan_act(g_pars.chan_mode); |
| 1028 | /* attempt to activate the same lchan again -> expect reject */ |
| 1029 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1030 | alt { |
| 1031 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1032 | 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] | 1033 | } |
| 1034 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1035 | setverdict(pass); |
| 1036 | } |
| 1037 | } |
| 1038 | f_rsl_chan_deact(); |
| 1039 | } |
| 1040 | testcase TC_chan_act_react() runs on test_CT { |
| 1041 | var ConnHdlr vc_conn; |
| 1042 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1043 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1044 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 1045 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1046 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | /* Attempt to de-activate a channel that's not active */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1050 | 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] | 1051 | timer T := 3.0; |
| 1052 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 1053 | T.start; |
| 1054 | alt { |
| 1055 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 1056 | setverdict(pass); |
| 1057 | } |
| 1058 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1059 | 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] | 1060 | } |
| 1061 | } |
| 1062 | } |
| 1063 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 1064 | 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] | 1065 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1066 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 1067 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1068 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1072 | 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] | 1073 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 1074 | alt { |
| 1075 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1076 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1077 | } |
| 1078 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 1079 | setverdict(pass); |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | private type record WrongChanNrCase { |
| 1084 | RslChannelNr chan_nr, |
| 1085 | charstring description |
| 1086 | } |
| 1087 | private type record of WrongChanNrCase WrongChanNrCases; |
| 1088 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 1089 | chan_nr := chan_nr, |
| 1090 | description := desc |
| 1091 | } |
| 1092 | |
| 1093 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 1094 | var ConnHdlr vc_conn; |
| 1095 | var ConnHdlrPars pars; |
| 1096 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1097 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1098 | |
| 1099 | var WrongChanNrCases wrong := { |
| 1100 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 1101 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 1102 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 1103 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 1104 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 1105 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 1106 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 1107 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 1108 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 1109 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 1110 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 1111 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 1112 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 1113 | }; |
| 1114 | |
| 1115 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 1116 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 1117 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 1118 | vc_conn.done; |
| 1119 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1120 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1121 | } |
| 1122 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1123 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1124 | 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] | 1125 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1126 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1127 | |
| 1128 | /* test on each of the channels we have */ |
| 1129 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1130 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 1131 | |
| 1132 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 1133 | vc_conn := f_start_handler(fn, pars); |
| 1134 | vc_conn.done; |
| 1135 | } |
| 1136 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1137 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1138 | } |
| 1139 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1140 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1141 | * SACCH handling |
| 1142 | ***********************************************************************/ |
| 1143 | |
| 1144 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 1145 | timer T_sacch := 3.0; |
| 1146 | T_sacch.start; |
| 1147 | alt { |
| 1148 | [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] | 1149 | 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] | 1150 | } |
| 1151 | [not exp] T_sacch.timeout { |
| 1152 | setverdict(pass); |
| 1153 | } |
| 1154 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 1155 | setverdict(pass); |
| 1156 | } |
| 1157 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1158 | 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] | 1159 | } |
| 1160 | [] L1CTL.receive { repeat; } |
| 1161 | [] RSL.receive { repeat; } |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 1166 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 1167 | f_l1_tune(L1CTL); |
| 1168 | RSL.clear; |
| 1169 | |
| 1170 | /* activate the logical channel */ |
| 1171 | f_est_dchan(); |
| 1172 | L1CTL.clear; |
| 1173 | |
| 1174 | /* check that SACCH actually are received as expected */ |
| 1175 | f_exp_sacch(true); |
| 1176 | |
| 1177 | /* deactivate SACCH on the logical channel */ |
| 1178 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 1179 | f_sleep(1.0); |
| 1180 | L1CTL.clear; |
| 1181 | |
| 1182 | /* check that no SACCH are received anymore */ |
| 1183 | f_exp_sacch(false); |
| 1184 | |
| 1185 | /* release the channel */ |
| 1186 | f_rsl_chan_deact(); |
| 1187 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1188 | } |
| 1189 | testcase TC_deact_sacch() runs on test_CT { |
| 1190 | var ConnHdlr vc_conn; |
| 1191 | var ConnHdlrPars pars; |
| 1192 | f_init(); |
| 1193 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1194 | //for (var integer i := 0; i < 1; i := i+1) { |
| 1195 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1196 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1197 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 1198 | vc_conn.done; |
| 1199 | } |
| 1200 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1201 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1202 | } |
| 1203 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1204 | /* verify that given SACCH payload is present */ |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1205 | private function f_sacch_present(template octetstring l3_exp, |
| 1206 | boolean do_fail := true) |
| 1207 | runs on ConnHdlr { |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1208 | var L1ctlDlMessage dl; |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1209 | timer T_sacch := 3.0; |
| 1210 | L1CTL.clear; |
| 1211 | T_sacch.start; |
| 1212 | alt { |
| 1213 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1214 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1215 | if (match(l3, l3_exp)) { |
| 1216 | setverdict(pass); |
| 1217 | } else { |
| 1218 | repeat; |
| 1219 | } |
| 1220 | } |
| 1221 | [] L1CTL.receive { repeat; } |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1222 | [not do_fail] T_sacch.timeout { |
| 1223 | log("Timeout waiting for SACCH ", l3_exp); |
| 1224 | } |
| 1225 | [do_fail] T_sacch.timeout { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1226 | setverdict(fail, "Timeout waiting for SACCH ", l3_exp); |
| 1227 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1228 | } |
| 1229 | } |
| 1230 | } |
| 1231 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1232 | /* verify that given SACCH payload is not present */ |
| 1233 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 1234 | var L1ctlDlMessage dl; |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1235 | timer T_sacch := 3.0; |
| 1236 | L1CTL.clear; |
| 1237 | T_sacch.start; |
| 1238 | alt { |
| 1239 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 1240 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 1241 | if (match(l3, l3_exp)) { |
Vadim Yanitskiy | 77a65f8 | 2022-03-11 12:34:47 +0300 | [diff] [blame] | 1242 | setverdict(fail, "Received unexpected SACCH ", dl); |
| 1243 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1244 | } else { |
| 1245 | repeat; |
| 1246 | } |
| 1247 | } |
| 1248 | [] L1CTL.receive { repeat; } |
| 1249 | [] T_sacch.timeout { |
| 1250 | setverdict(pass); |
| 1251 | } |
| 1252 | } |
| 1253 | } |
| 1254 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1255 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1256 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 1257 | /* Set a known default SACCH filling for SI5 */ |
| 1258 | var octetstring si5 := f_rnd_octstring(19); |
| 1259 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1260 | |
| 1261 | f_l1_tune(L1CTL); |
| 1262 | RSL.clear; |
| 1263 | |
| 1264 | /* activate the logical channel */ |
| 1265 | f_est_dchan(); |
| 1266 | |
| 1267 | /* check that the specified SI5 value is actually sent */ |
| 1268 | f_sacch_present(si5); |
| 1269 | |
| 1270 | /* release the channel */ |
| 1271 | RSL.clear; |
| 1272 | f_rsl_chan_deact(); |
| 1273 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1274 | } |
| 1275 | testcase TC_sacch_filling() runs on test_CT { |
| 1276 | var ConnHdlr vc_conn; |
| 1277 | var ConnHdlrPars pars; |
| 1278 | f_init(); |
| 1279 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1280 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1281 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1282 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 1283 | vc_conn.done; |
| 1284 | } |
| 1285 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1286 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1287 | } |
| 1288 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1289 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1290 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 1291 | /* Set a known default SACCH filling for SI5 */ |
| 1292 | var octetstring si5 := f_rnd_octstring(19); |
| 1293 | var octetstring si5_diff := f_rnd_octstring(19); |
| 1294 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1295 | |
| 1296 | f_l1_tune(L1CTL); |
| 1297 | RSL.clear; |
| 1298 | |
| 1299 | log("Activating channel, expecting standard SI5"); |
| 1300 | /* activate the logical channel */ |
| 1301 | f_est_dchan(); |
| 1302 | /* check that the specified SI5 value is actually sent */ |
| 1303 | f_sacch_present(si5); |
| 1304 | |
| 1305 | /* set channel-specific different SI5 */ |
| 1306 | log("Setting channel specific SACCH INFO, expecting it"); |
| 1307 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 1308 | /* check that the specified lchan-specific value is now used */ |
| 1309 | f_sacch_present(si5_diff); |
| 1310 | |
| 1311 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 1312 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 1313 | f_rsl_chan_deact(); |
| 1314 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 1315 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 1316 | f_sacch_present(si5); |
| 1317 | |
| 1318 | /* release the channel */ |
| 1319 | RSL.clear; |
| 1320 | f_rsl_chan_deact(); |
| 1321 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1322 | } |
| 1323 | testcase TC_sacch_info_mod() runs on test_CT { |
| 1324 | var ConnHdlr vc_conn; |
| 1325 | var ConnHdlrPars pars; |
| 1326 | f_init(); |
| 1327 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1328 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1329 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1330 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 1331 | vc_conn.done; |
| 1332 | } |
| 1333 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1334 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 1335 | } |
| 1336 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1337 | /* Test SACCH scheduling of multiple different SI message types */ |
| 1338 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 1339 | var octetstring si5 := f_rnd_octstring(19); |
| 1340 | var octetstring si5bis := f_rnd_octstring(19); |
| 1341 | var octetstring si5ter := f_rnd_octstring(19); |
| 1342 | var octetstring si6 := f_rnd_octstring(19); |
| 1343 | |
| 1344 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1345 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 1346 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 1347 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1348 | |
| 1349 | f_l1_tune(L1CTL); |
| 1350 | RSL.clear; |
| 1351 | |
| 1352 | /* activate the logical channel */ |
| 1353 | f_est_dchan(); |
| 1354 | L1CTL.clear; |
| 1355 | |
| 1356 | /* check that SACCH actually are received as expected */ |
| 1357 | f_sacch_present(si5); |
| 1358 | f_sacch_present(si5bis); |
| 1359 | f_sacch_present(si5ter); |
| 1360 | f_sacch_present(si6); |
| 1361 | |
| 1362 | /* release the channel */ |
| 1363 | f_rsl_chan_deact(); |
| 1364 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1365 | } |
| 1366 | testcase TC_sacch_multi() runs on test_CT { |
| 1367 | var ConnHdlr vc_conn; |
| 1368 | var ConnHdlrPars pars; |
| 1369 | f_init(); |
| 1370 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1371 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1372 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1373 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 1374 | vc_conn.done; |
| 1375 | } |
| 1376 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1377 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 1378 | } |
| 1379 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1380 | /* Test if SACH information is modified as expected */ |
| 1381 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 1382 | var octetstring si5 := f_rnd_octstring(19); |
| 1383 | var octetstring si6 := f_rnd_octstring(19); |
| 1384 | |
| 1385 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1386 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1387 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1388 | |
| 1389 | f_l1_tune(L1CTL); |
| 1390 | RSL.clear; |
| 1391 | |
| 1392 | /* activate the logical channel */ |
| 1393 | f_est_dchan(); |
| 1394 | L1CTL.clear; |
| 1395 | |
| 1396 | /* check that SACCH actually are received as expected */ |
| 1397 | f_sacch_present(si5); |
| 1398 | f_sacch_present(si6); |
| 1399 | |
| 1400 | /* disable SI6 */ |
| 1401 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1402 | |
| 1403 | /* check that SI5 is still transmitted */ |
| 1404 | f_sacch_present(si5); |
| 1405 | /* check if SI6 is now gone */ |
| 1406 | f_sacch_missing(si6); |
| 1407 | |
| 1408 | /* release the channel */ |
| 1409 | f_rsl_chan_deact(); |
| 1410 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1411 | } |
| 1412 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1413 | var ConnHdlr vc_conn; |
| 1414 | var ConnHdlrPars pars; |
| 1415 | f_init(); |
| 1416 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1417 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1418 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1419 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1420 | vc_conn.done; |
| 1421 | } |
| 1422 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1423 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1424 | } |
| 1425 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1426 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1427 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1428 | var octetstring si5 := f_rnd_octstring(19); |
| 1429 | var octetstring si6 := f_rnd_octstring(19); |
| 1430 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1431 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1432 | |
| 1433 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1434 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1435 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1436 | |
| 1437 | f_l1_tune(L1CTL); |
| 1438 | RSL.clear; |
| 1439 | |
| 1440 | /* activate channel with different SACCH filling */ |
| 1441 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1442 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1443 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1444 | })); |
| 1445 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1446 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1447 | f_est_dchan(more_ies := addl_ies); |
| 1448 | |
| 1449 | /* check that SACCH actually are received as expected */ |
| 1450 | f_sacch_present(si5_specific); |
| 1451 | f_sacch_present(si6_specific); |
| 1452 | |
| 1453 | /* release the channel */ |
| 1454 | f_rsl_chan_deact(); |
| 1455 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1456 | } |
| 1457 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1458 | var ConnHdlr vc_conn; |
| 1459 | var ConnHdlrPars pars; |
| 1460 | f_init(); |
| 1461 | |
| 1462 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1463 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1464 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1465 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1466 | vc_conn.done; |
| 1467 | } |
| 1468 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1469 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1470 | } |
| 1471 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1472 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1473 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1474 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1475 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1476 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1477 | |
| 1478 | f_l1_tune(L1CTL); |
| 1479 | RSL.clear; |
| 1480 | |
| 1481 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1482 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1483 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1484 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1485 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1486 | var RSL_IE_List addl_ies := { |
| 1487 | ho_ref_ie |
| 1488 | }; |
| 1489 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1490 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1491 | 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] | 1492 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1493 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1494 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1495 | |
| 1496 | /* Verify that no DL SACCH is being received */ |
| 1497 | f_sacch_missing(?); |
| 1498 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1499 | /* Send handover Access Burst and expect SACCH to start */ |
| 1500 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1501 | |
| 1502 | f_sacch_present(si5); |
| 1503 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1504 | f_rsl_chan_deact(); |
| 1505 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1506 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1507 | /* Tune back to CCCH/BCCH */ |
| 1508 | f_l1_tune(L1CTL); |
| 1509 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1510 | |
| 1511 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1512 | |
| 1513 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1514 | addl_ies := { |
| 1515 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1516 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1517 | }; |
| 1518 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1519 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1520 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1521 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1522 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1523 | /* 4.1.3 "If the MS Power IE is present the BTS *may* start transmission |
| 1524 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1525 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1526 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1527 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1528 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1529 | |
| 1530 | f_sacch_present(si5); |
| 1531 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1532 | f_rsl_chan_deact(); |
| 1533 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1534 | } |
| 1535 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1536 | var ConnHdlr vc_conn; |
| 1537 | var ConnHdlrPars pars; |
| 1538 | f_init(); |
| 1539 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1540 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1541 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1542 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1543 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1544 | vc_conn.done; |
| 1545 | } |
| 1546 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1547 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1548 | } |
| 1549 | |
| 1550 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1551 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1552 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1553 | var octetstring si5 := f_rnd_octstring(19); |
Neels Hofmeyr | dd59741 | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1554 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1555 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1556 | var RSL_IE_List addl_ies; |
| 1557 | |
| 1558 | f_l1_tune(L1CTL); |
| 1559 | RSL.clear; |
| 1560 | |
| 1561 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1562 | |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1563 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1564 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1565 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1566 | addl_ies := { |
| 1567 | ho_ref_ie |
| 1568 | }; |
| 1569 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1570 | /* Activate channel on BTS side */ |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1571 | 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] | 1572 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1573 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1574 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1575 | |
| 1576 | /* Verify that no DL SACCH is being received */ |
| 1577 | f_sacch_missing(?); |
| 1578 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1579 | /* Send handover Access Burst and expect SACCH to start */ |
| 1580 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1581 | |
| 1582 | f_sacch_present(si5); |
| 1583 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1584 | f_rsl_chan_deact(); |
| 1585 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1586 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1587 | /* Tune back to CCCH/BCCH */ |
| 1588 | f_l1_tune(L1CTL); |
| 1589 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1590 | |
| 1591 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1592 | |
| 1593 | /* Activate channel on BTS side */ |
| 1594 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1595 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1596 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1597 | }; |
| 1598 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1599 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1600 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1601 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1602 | |
Vadim Yanitskiy | f9136a1 | 2022-03-11 14:04:27 +0300 | [diff] [blame] | 1603 | /* 4.1.4 "If only the MS Power IE is present the BTS *may* start transmission |
| 1604 | * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */ |
| 1605 | f_sacch_present(si5, do_fail := false); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1606 | |
Neels Hofmeyr | d55a3ac | 2020-11-09 00:54:34 +0000 | [diff] [blame] | 1607 | /* Send handover Access Burst and expect SACCH to remain present */ |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1608 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1609 | |
| 1610 | f_sacch_present(si5); |
| 1611 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1612 | f_rsl_chan_deact(); |
| 1613 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1614 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1615 | /* Tune back to CCCH/BCCH */ |
| 1616 | f_l1_tune(L1CTL); |
| 1617 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1618 | |
| 1619 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1620 | |
| 1621 | /* Activate channel on BTS side */ |
| 1622 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1623 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1624 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1625 | }; |
| 1626 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1627 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1628 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1629 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1630 | |
| 1631 | /* Verify that no DL SACCH is being received */ |
| 1632 | f_sacch_missing(?); |
| 1633 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1634 | /* Send handover Access Burst and expect SACCH to start */ |
| 1635 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1636 | |
| 1637 | f_sacch_present(si5); |
| 1638 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1639 | f_rsl_chan_deact(); |
| 1640 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1641 | |
Vadim Yanitskiy | e3351bb | 2022-07-29 05:22:51 +0700 | [diff] [blame] | 1642 | /* Tune back to CCCH/BCCH */ |
| 1643 | f_l1_tune(L1CTL); |
| 1644 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1645 | |
| 1646 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1647 | |
| 1648 | /* Activate channel on BTS side */ |
| 1649 | addl_ies := { |
Neels Hofmeyr | d34681b | 2020-11-03 20:35:00 +0000 | [diff] [blame] | 1650 | ho_ref_ie, |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1651 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1652 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1653 | }; |
| 1654 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1655 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1656 | /* enable dedicated mode */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1657 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1658 | |
| 1659 | /* Verify that DL SACCH is being received */ |
| 1660 | f_sacch_present(si5); |
| 1661 | |
Neels Hofmeyr | 76d1d1a | 2020-11-09 00:03:33 +0000 | [diff] [blame] | 1662 | /* Send handover Access Burst and expect SACCH to remain present */ |
| 1663 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1664 | |
| 1665 | f_sacch_present(si5); |
| 1666 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1667 | f_rsl_chan_deact(); |
| 1668 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1669 | } |
| 1670 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1671 | var ConnHdlr vc_conn; |
| 1672 | var ConnHdlrPars pars; |
| 1673 | f_init(); |
| 1674 | |
Vadim Yanitskiy | ce96d35 | 2022-03-11 15:32:07 +0300 | [diff] [blame] | 1675 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 1676 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 1677 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1678 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1679 | vc_conn.done; |
| 1680 | } |
| 1681 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1682 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1683 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1684 | |
| 1685 | |
| 1686 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1687 | * RACH Handling |
| 1688 | ***********************************************************************/ |
| 1689 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1690 | /* 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] | 1691 | private function f_TC_rach_content(boolean emerg) runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1692 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1693 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1694 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1695 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1696 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1697 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1698 | for (var integer i := 0; i < 1000; i := i+1) { |
Neels Hofmeyr | c897cfb | 2020-11-09 00:06:01 +0000 | [diff] [blame] | 1699 | var OCT1 ra; |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1700 | if (emerg == true) { |
| 1701 | ra := f_rnd_ra_emerg(); |
| 1702 | } else { |
| 1703 | ra := f_rnd_ra_cs(); |
| 1704 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1705 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1706 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1707 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1708 | } |
| 1709 | fn_last := fn; |
| 1710 | |
| 1711 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1712 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1713 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1714 | [] 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] | 1715 | T.stop; |
| 1716 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1717 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1718 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1719 | } |
| 1720 | [] RSL_CCHAN.receive { repeat; } |
| 1721 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1722 | test_failed := true; |
| 1723 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1724 | } |
| 1725 | } |
| 1726 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1727 | if (test_failed) { |
| 1728 | 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] | 1729 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1730 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1731 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1732 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1733 | |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 1734 | /* Normal variant */ |
| 1735 | testcase TC_rach_content() runs on test_CT { |
| 1736 | f_TC_rach_content(emerg := false); |
| 1737 | } |
| 1738 | |
| 1739 | /* Emergency call variant */ |
| 1740 | testcase TC_rach_content_emerg() runs on test_CT { |
| 1741 | f_TC_rach_content(emerg := true); |
| 1742 | } |
| 1743 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1744 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1745 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1746 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1747 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1748 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1749 | f_l1_tune(L1CTL); |
| 1750 | |
| 1751 | var GsmFrameNumber fn_last := 0; |
| 1752 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1753 | var OCT1 ra := f_rnd_ra_cs(); |
| 1754 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1755 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1756 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1757 | } |
| 1758 | fn_last := fn; |
| 1759 | } |
| 1760 | var integer rsl_chrqd := 0; |
| 1761 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1762 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1763 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1764 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1765 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1766 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1767 | repeat; |
| 1768 | } |
| 1769 | [] RSL_CCHAN.receive { repeat; } |
| 1770 | [] T.timeout { } |
| 1771 | } |
| 1772 | if (rsl_chrqd == 1000) { |
| 1773 | setverdict(pass); |
| 1774 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1775 | 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] | 1776 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1777 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1778 | } |
| 1779 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1780 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1781 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1782 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1783 | } |
| 1784 | |
| 1785 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1786 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1787 | |
| 1788 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1789 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1790 | var ASP_RSL_Unitdata rx_ud; |
| 1791 | |
| 1792 | f_init_vty_bsc(); |
| 1793 | /* send load indications even at 0% load */ |
| 1794 | f_vty_load_ind_thresh(0); |
| 1795 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1796 | f_sleep(2.0); |
| 1797 | |
| 1798 | f_init(); |
| 1799 | |
Harald Welte | e37f9a5 | 2020-10-11 20:45:23 +0200 | [diff] [blame] | 1800 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1801 | alt { |
| 1802 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1803 | [] RSL_CCHAN.receive { repeat } |
| 1804 | } |
| 1805 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1806 | timer T := 5.0; |
| 1807 | T.start; |
| 1808 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1809 | [] 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] | 1810 | setverdict(pass); |
| 1811 | repeat; |
| 1812 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1813 | [] 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] | 1814 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1815 | repeat; |
| 1816 | } |
| 1817 | [] RSL_CCHAN.receive { |
| 1818 | repeat; |
| 1819 | } |
| 1820 | [] T.timeout { } |
| 1821 | } |
| 1822 | |
| 1823 | f_vty_load_ind_thresh(10); |
| 1824 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1825 | } |
| 1826 | |
| 1827 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1828 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1829 | var ASP_RSL_Unitdata rx_ud; |
| 1830 | |
| 1831 | f_init_vty_bsc(); |
| 1832 | f_init(); |
| 1833 | |
| 1834 | timer T := 5.0; |
| 1835 | T.start; |
| 1836 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1837 | [] 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] | 1838 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1839 | repeat; |
| 1840 | } |
| 1841 | [] RSL_CCHAN.receive { |
| 1842 | repeat; |
| 1843 | } |
| 1844 | [] T.timeout { |
| 1845 | setverdict(pass); |
| 1846 | } |
| 1847 | } |
| 1848 | |
| 1849 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1850 | } |
| 1851 | |
| 1852 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1853 | testcase TC_rach_load_count() runs on test_CT { |
| 1854 | var ASP_RSL_Unitdata rx_ud; |
| 1855 | var integer load_access_count := 0; |
| 1856 | |
| 1857 | f_init_vty_bsc(); |
| 1858 | /* send load indications even at 0% load */ |
| 1859 | f_vty_load_ind_thresh(0); |
| 1860 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1861 | f_sleep(2.0); |
| 1862 | f_init(); |
| 1863 | |
| 1864 | f_init_l1ctl(); |
| 1865 | f_sleep(1.0); |
| 1866 | f_l1_tune(L1CTL); |
| 1867 | |
Harald Welte | 52ae168 | 2020-10-11 20:45:55 +0200 | [diff] [blame] | 1868 | /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */ |
| 1869 | alt { |
| 1870 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { } |
| 1871 | [] RSL_CCHAN.receive { repeat } |
| 1872 | } |
| 1873 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1874 | var GsmFrameNumber fn_last := 0; |
| 1875 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1876 | var OCT1 ra := f_rnd_ra_cs(); |
| 1877 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1878 | if (fn == fn_last) { |
| 1879 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1880 | } |
| 1881 | fn_last := fn; |
| 1882 | } |
| 1883 | |
| 1884 | timer T := 5.0; |
| 1885 | T.start; |
| 1886 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1887 | [] 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] | 1888 | -> value rx_ud { |
| 1889 | var RSL_IE_Body ie; |
| 1890 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1891 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1892 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1893 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1894 | } |
| 1895 | repeat; |
| 1896 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1897 | [] 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] | 1898 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1899 | repeat; |
| 1900 | } |
| 1901 | [] RSL_CCHAN.receive { |
| 1902 | repeat; |
| 1903 | } |
| 1904 | [] T.timeout { } |
| 1905 | } |
| 1906 | if (load_access_count == 1000) { |
| 1907 | setverdict(pass); |
| 1908 | } else { |
| 1909 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1910 | } |
| 1911 | |
| 1912 | f_vty_load_ind_thresh(10); |
| 1913 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1914 | } |
| 1915 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1916 | 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] | 1917 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1918 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 1919 | 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] | 1920 | f_sleep(0.5); |
| 1921 | |
| 1922 | /* Transmit RACH request + wait for confirmation */ |
| 1923 | var OCT1 ra := f_rnd_ra_cs(); |
| 1924 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1925 | |
| 1926 | /* Check for expected result */ |
| 1927 | timer T := 1.5; |
| 1928 | T.start; |
| 1929 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1930 | [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] | 1931 | setverdict(pass); |
| 1932 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1933 | [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] | 1934 | 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] | 1935 | } |
| 1936 | [] RSL_CCHAN.receive { repeat; } |
| 1937 | [not expect_pass] T.timeout { |
| 1938 | setverdict(pass); |
| 1939 | } |
| 1940 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1941 | 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] | 1942 | } |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1947 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1948 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1949 | f_init_l1ctl(); |
| 1950 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1951 | f_sleep(1.0); |
| 1952 | |
| 1953 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1954 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1955 | /* We allow early arrival up to 2 symbols */ |
| 1956 | f_rach_toffs(-1*256, true); |
| 1957 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1958 | f_rach_toffs(-10*256, false); |
| 1959 | |
| 1960 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1961 | f_rach_toffs(0, true); |
| 1962 | f_rach_toffs(32*256, true); |
| 1963 | f_rach_toffs(63*256, true); |
| 1964 | |
| 1965 | /* more than 63 bits is not legal / permitted */ |
| 1966 | f_rach_toffs(64*256, false); |
| 1967 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1968 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1969 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1970 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 1971 | private function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1972 | var GsmFrameNumber fn; |
| 1973 | var RSL_Message rm; |
| 1974 | |
| 1975 | f_l1_tune(L1CTL); |
| 1976 | RSL.clear; |
| 1977 | |
| 1978 | /* Generate a random Handover Reference */ |
| 1979 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1980 | |
| 1981 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1982 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1983 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1984 | |
| 1985 | /* Activate a channel on the BTS side (no encryption) */ |
| 1986 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1987 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1988 | |
| 1989 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1990 | * waiting for Immediate Assignment and sending Access Burst */ |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 1991 | f_l1ctl_est_dchan(L1CTL, g_pars); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1992 | |
| 1993 | /* Send handover Access Burst */ |
| 1994 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1995 | |
| 1996 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1997 | |
| 1998 | /* Wait for handover detection */ |
| 1999 | timer T := 3.0; |
| 2000 | T.start; |
| 2001 | alt { |
| 2002 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 2003 | log("Handover RACH has been detected: ", rm); |
| 2004 | setverdict(pass); |
| 2005 | } |
| 2006 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 2007 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2008 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 2009 | } |
| 2010 | [] RSL.receive { repeat; } |
| 2011 | [] T.timeout { |
| 2012 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2013 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 2014 | } |
| 2015 | } |
| 2016 | |
| 2017 | /* Release the channel */ |
| 2018 | f_rsl_chan_deact(); |
| 2019 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2020 | } |
| 2021 | |
| 2022 | /* Test handover RACH detection */ |
| 2023 | testcase TC_ho_rach() runs on test_CT { |
| 2024 | var ConnHdlrPars pars; |
| 2025 | var ConnHdlr vc_conn; |
| 2026 | |
| 2027 | f_init(); |
| 2028 | |
| 2029 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 2030 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 2031 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 2032 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 2033 | vc_conn.done; |
| 2034 | } |
| 2035 | |
| 2036 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2038 | } |
| 2039 | |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 2040 | /* Test sending of the RR Physical Information message on DCCH */ |
| 2041 | private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr { |
| 2042 | var PDU_ML3_NW_MS dcch_pdu; |
| 2043 | var integer count := 0; |
| 2044 | var L1ctlDlMessage dl; |
| 2045 | timer T; |
| 2046 | |
| 2047 | f_l1_tune(L1CTL); |
| 2048 | RSL.clear; |
| 2049 | |
| 2050 | /* Generate a random Handover Reference */ |
| 2051 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 2052 | |
| 2053 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 2054 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 2055 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 2056 | |
| 2057 | /* Activate a channel on the BTS side (no encryption) */ |
| 2058 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 2059 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 2060 | |
| 2061 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 2062 | * waiting for Immediate Assignment and sending of an Access Burst. */ |
| 2063 | f_l1ctl_est_dchan(L1CTL, g_pars); /* FIXME: disable Uplink Tx */ |
| 2064 | |
| 2065 | /* Expect nothing to be transmitted on Downlink DCCH. Nothing in this |
| 2066 | * context means any L2 frames, not only the RR Physical Information. */ |
| 2067 | T.start(2.0); |
| 2068 | L1CTL.clear; |
| 2069 | alt { |
| 2070 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value dl { |
| 2071 | setverdict(fail, "Rx unexpected Downlink DCCH (before handover RACH): ", dl); |
| 2072 | T.stop; |
| 2073 | } |
| 2074 | [] L1CTL.receive { repeat; } |
| 2075 | [] T.timeout { setverdict(pass); } |
| 2076 | } |
| 2077 | |
| 2078 | /* Send handover Access Burst */ |
| 2079 | log("Sending handover Access Burst"); |
| 2080 | f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 2081 | |
| 2082 | /* Expect RR Physical Information being sent on Downlink DCCH Ny1 times */ |
| 2083 | T.start(int2float(mp_ho_t3105_ms * mp_ho_ny1) / 1000.0 + 1.0); |
| 2084 | L1CTL.clear; |
| 2085 | alt { |
| 2086 | [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */ |
| 2087 | [] as_dl_dcch_pdu(dcch_pdu, tr_RRM_PhysicalInfo) { |
| 2088 | log("Rx RR Physical Information: ", dcch_pdu); |
| 2089 | /* Wait until the count reaches Ny1 */ |
| 2090 | count := count + 1; |
| 2091 | if (count < mp_ho_ny1) |
| 2092 | { repeat; } |
| 2093 | setverdict(pass); |
| 2094 | } |
| 2095 | [] as_dl_dcch_pdu(dcch_pdu, ?) { |
| 2096 | setverdict(fail, "Rx unexpected DCCH PDU: ", dcch_pdu); |
| 2097 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2098 | } |
| 2099 | [] L1CTL.receive { repeat; } |
| 2100 | [] T.timeout { |
| 2101 | setverdict(fail, "Timeout waiting for RR Physical Information"); |
| 2102 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2103 | } |
| 2104 | } |
| 2105 | |
| 2106 | /* Release the channel */ |
| 2107 | f_rsl_chan_deact(); |
| 2108 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2109 | } |
| 2110 | testcase TC_ho_physical_info() runs on test_CT { |
| 2111 | var ConnHdlrPars pars; |
| 2112 | var ConnHdlr vc_conn; |
| 2113 | |
| 2114 | f_init(); |
| 2115 | |
| 2116 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 2117 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 2118 | log(testcasename(), ": Starting for ", g_AllChanTypes[i]); |
| 2119 | vc_conn := f_start_handler(refers(f_TC_ho_physical_info), pars); |
| 2120 | vc_conn.done; |
| 2121 | } |
| 2122 | |
| 2123 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 2124 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2125 | } |
| 2126 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2127 | /*********************************************************************** |
| 2128 | * Measurement Processing / Reporting |
| 2129 | ***********************************************************************/ |
| 2130 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2131 | private template (value) LapdmAddressField |
| 2132 | ts_LapdmAddr(template (value) LapdmSapi sapi, |
| 2133 | template (value) boolean c_r) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2134 | spare := '0'B, |
| 2135 | lpd := 0, |
| 2136 | sapi := sapi, |
| 2137 | c_r := c_r, |
| 2138 | ea := true |
| 2139 | } |
| 2140 | |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2141 | private template (value) LapdmFrameAB |
| 2142 | ts_LAPDm_AB(template (value) LapdmSapi sapi, |
| 2143 | template (value) GsmRrL3Message l3, |
| 2144 | template (value) boolean c_r := false, |
| 2145 | template (value) boolean p := false) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2146 | addr := ts_LapdmAddr(sapi, c_r), |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2147 | ctrl := ts_LapdmCtrlUI(valueof(p)), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2148 | len := 0, /* overwritten */ |
| 2149 | m := false, |
| 2150 | el := 1, |
Vadim Yanitskiy | 16e2991 | 2022-03-12 13:26:21 +0300 | [diff] [blame] | 2151 | payload := enc_GsmRrL3Message(valueof(l3)), |
| 2152 | padding := ''O |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2153 | } |
| 2154 | |
| 2155 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2156 | private altstep as_l1_sacch() runs on ConnHdlr { |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2157 | var template (value) LapdmFrameAB lb; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2158 | var L1ctlDlMessage l1_dl; |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2159 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2160 | [] 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] | 2161 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Vadim Yanitskiy | 5351ccf | 2020-11-11 20:48:17 +0700 | [diff] [blame] | 2162 | |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2163 | 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] | 2164 | g_pars.l1_pars.meas_ul.full.rxlev, |
| 2165 | g_pars.l1_pars.meas_ul.sub.rxlev, |
| 2166 | g_pars.l1_pars.meas_ul.full.rxqual, |
| 2167 | g_pars.l1_pars.meas_ul.sub.rxqual)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2168 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 2169 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 2170 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 2171 | 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] | 2172 | |
Vadim Yanitskiy | f105a5b | 2020-11-30 14:27:55 +0100 | [diff] [blame] | 2173 | /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */ |
| 2174 | 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] | 2175 | |
| 2176 | log("Sending Measurement Report: ", l1h, l2); |
| 2177 | 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] | 2178 | repeat; |
| 2179 | } |
| 2180 | } |
| 2181 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 2182 | /* handle incoming downlink SACCH, decode the L1 header into the given record */ |
| 2183 | private altstep as_l1_sacch_l1h(inout SacchL1Header l1h, |
| 2184 | boolean do_apply := true) |
| 2185 | runs on ConnHdlr |
| 2186 | { |
| 2187 | var L1ctlDlMessage l1_dl; |
| 2188 | |
| 2189 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2190 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 2191 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 2192 | log(%definitionId, "(): Rx SACCH L1 header: ", l1h); |
| 2193 | |
| 2194 | if (do_apply) { |
| 2195 | /* Update TA and MS power to follow what BTS requests */ |
| 2196 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 2197 | } |
| 2198 | } |
| 2199 | } |
| 2200 | |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2201 | private altstep as_l1_dcch_loop() runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2202 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2203 | [] 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] | 2204 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 2205 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 2206 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2207 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2208 | repeat; |
| 2209 | } |
| 2210 | } |
| 2211 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2212 | private altstep as_l1_tch_loop() runs on ConnHdlr { |
| 2213 | var L1ctlDlMessage l1_dl; |
| 2214 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl { |
| 2215 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2216 | |
| 2217 | /* occasionaly inject FACCH frames into the uplink */ |
| 2218 | if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) { |
| 2219 | var octetstring pl := '010301'O; |
| 2220 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 2221 | f_pad_oct(pl, 23, '2B'O))); |
| 2222 | } else { |
| 2223 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 2224 | l1_dl.payload.traffic_ind.data)); |
| 2225 | } |
| 2226 | |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2227 | repeat; |
| 2228 | } |
| 2229 | } |
| 2230 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2231 | private type record MeasElem { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2232 | uint6_t rxlev, |
| 2233 | uint3_t rxqual |
| 2234 | } |
| 2235 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2236 | private type record MeasElemFS { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2237 | MeasElem full, |
| 2238 | MeasElem sub |
| 2239 | } |
| 2240 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2241 | private type record ConnL1Pars { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2242 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2243 | boolean toa256_enabled, |
Vadim Yanitskiy | 7dad608 | 2020-11-28 22:42:27 +0100 | [diff] [blame] | 2244 | boolean meas_valid, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2245 | MeasElemFS meas_ul, |
| 2246 | int16_t timing_offset_256syms, |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 2247 | uint4_t bs_power_level, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2248 | uint5_t ms_power_level, |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 2249 | uint8_t ms_actual_ta, |
| 2250 | boolean facch_enabled |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2251 | } |
| 2252 | |
| 2253 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 2254 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 2255 | return 63 + (toffs256s/256); |
| 2256 | } |
| 2257 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2258 | private function f_max(integer a, integer b) return integer { |
| 2259 | if (a > b) { |
| 2260 | return a; |
| 2261 | } else { |
| 2262 | return b; |
| 2263 | } |
| 2264 | } |
| 2265 | |
| 2266 | private function f_min(integer a, integer b) return integer { |
| 2267 | if (a < b) { |
| 2268 | return a; |
| 2269 | } else { |
| 2270 | return b; |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 2275 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 2276 | val := val - tolerance; |
| 2277 | return f_max(val, min); |
| 2278 | } |
| 2279 | |
| 2280 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 2281 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 2282 | val := val + tolerance; |
| 2283 | return f_min(val, max); |
| 2284 | } |
| 2285 | |
| 2286 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 2287 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 2288 | return template integer { |
| 2289 | var template integer ret; |
| 2290 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 2291 | return ret; |
| 2292 | } |
| 2293 | |
| 2294 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2295 | /* build a template for matching measurement results against */ |
| 2296 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 2297 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2298 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2299 | len := 3, |
| 2300 | rfu := '0'B, |
| 2301 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2302 | 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] | 2303 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2304 | 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] | 2305 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 2306 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 2307 | 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] | 2308 | supp_meas_info := omit |
| 2309 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2310 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 2311 | ul_meas.len := (3+8); |
| 2312 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2313 | 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] | 2314 | toa256_min := ?, |
| 2315 | toa256_max := ?, |
| 2316 | toa256_std_dev := ? |
| 2317 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2318 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2319 | var template RSL_IE_BS_Power bs_power := { |
| 2320 | reserved := 0, |
| 2321 | epc := false, |
| 2322 | fpc := false, |
| 2323 | power_level := l1p.bs_power_level |
| 2324 | }; |
| 2325 | var template RSL_IE_L1Info l1_info := { |
| 2326 | ms_power_lvl := l1p.ms_power_level, |
| 2327 | fpc := false, |
| 2328 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2329 | 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] | 2330 | }; |
| 2331 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2332 | 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] | 2333 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 2334 | ?, t_toffs); |
| 2335 | } |
| 2336 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2337 | /* build a template for matching measurement results that do not contain any |
| 2338 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 2339 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 2340 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 2341 | var template RSL_IE_UplinkMeas ul_meas := { |
| 2342 | len := 3, |
| 2343 | rfu := '0'B, |
| 2344 | dtx_d := l1p.dtx_enabled, |
| 2345 | rxlev_f_u := ?, |
| 2346 | reserved1 := '00'B, |
| 2347 | rxlev_s_u := ?, |
| 2348 | reserved2 := '00'B, |
| 2349 | rxq_f_u := ?, |
| 2350 | rxq_s_u := ?, |
| 2351 | supp_meas_info := omit |
| 2352 | }; |
| 2353 | if (l1p.toa256_enabled) { |
| 2354 | ul_meas.len := (3+8); |
| 2355 | ul_meas.supp_meas_info := { |
| 2356 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 2357 | toa256_min := ?, |
| 2358 | toa256_max := ?, |
| 2359 | toa256_std_dev := ? |
| 2360 | } |
| 2361 | } |
| 2362 | var template RSL_IE_BS_Power bs_power := { |
| 2363 | reserved := 0, |
| 2364 | epc := false, |
| 2365 | fpc := false, |
| 2366 | power_level := l1p.bs_power_level |
| 2367 | }; |
| 2368 | |
| 2369 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 2370 | } |
| 2371 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2372 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2373 | private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2374 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2375 | var boolean chan_est := false; |
| 2376 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 2377 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2378 | |
| 2379 | /* Receive osmocom specific measurement reports. This is the normal |
| 2380 | * case. Here we verify that the measurement reports we sent are |
| 2381 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2382 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 2383 | /* increment counter of next to-be-expected meas rep */ |
| 2384 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2385 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 2386 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2387 | |
| 2388 | /* The following two cases may only happen in the beginning |
| 2389 | * of the channel establishment phase. Once we have received |
| 2390 | * the "our" measurement report the first time, the channel |
| 2391 | * is established and empty or hardcoded TRXCON reports must |
| 2392 | * not occur anymore. */ |
| 2393 | chan_est := true; |
| 2394 | |
| 2395 | repeat; |
| 2396 | } |
| 2397 | |
| 2398 | /* When the BTS has established the channel, the MS might need slightly |
| 2399 | * more time to establish the channel and actually start sending. The |
| 2400 | * result is then a measurement report that just lacks the measurement |
| 2401 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 2402 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 2403 | /* increment counter of next to-be-expected meas rep */ |
| 2404 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2405 | /* Re-start the timer expecting the next MEAS RES */ |
| 2406 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2407 | repeat; |
| 2408 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 2409 | |
| 2410 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 2411 | * measurements if the TTCN3 side does not supply measurement input in |
| 2412 | * time. In those cases TRXCON will either use a cached measurement |
| 2413 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 2414 | * report the templates above will not match. We tolerate this |
| 2415 | * behavior, but only once. */ |
| 2416 | [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] | 2417 | /* increment counter of next to-be-expected meas rep */ |
| 2418 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 2419 | if (g_first_meas_res) { |
| 2420 | g_first_meas_res := false; |
| 2421 | repeat; |
| 2422 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2423 | 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] | 2424 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2425 | } |
| 2426 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2427 | 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] | 2428 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 2429 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2430 | 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] | 2431 | } |
| 2432 | } |
| 2433 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2434 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 2435 | select (rsl_alg_id) { |
| 2436 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 2437 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 2438 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 2439 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 2440 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 2441 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 2442 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 2443 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 2444 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2445 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2446 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2447 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2448 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2449 | } |
| 2450 | } |
| 2451 | } |
| 2452 | |
| 2453 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 2454 | select (rsl_alg_id) { |
| 2455 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 2456 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 2457 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 2458 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 2459 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 2460 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 2461 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 2462 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2463 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 2464 | /* Make compiler happy by calling mtc.stop here. It is already |
| 2465 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 2466 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2467 | } |
| 2468 | } |
| 2469 | } |
| 2470 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 2471 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 2472 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 2473 | var GsmFrameNumber fn; |
| 2474 | timer T := 8.0; |
| 2475 | |
| 2476 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 2477 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 2478 | |
| 2479 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 2480 | /* Send the actual RACH */ |
| 2481 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 2482 | |
| 2483 | T.start; |
| 2484 | alt { |
| 2485 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 2486 | [] T.timeout { |
| 2487 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 2488 | } |
| 2489 | } |
| 2490 | T.stop |
| 2491 | return fn; |
| 2492 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2493 | |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2494 | /* Tune to a dedicated channel: L1CTL only */ |
| 2495 | private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2496 | if (not pars.fhp.enabled) { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2497 | var TrxParsItem trx_pars := mp_trx_pars[pars.trx_nr]; |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2498 | 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] | 2499 | trx_pars.arfcn)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2500 | } else { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2501 | 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] | 2502 | pars.fhp.maio_hsn.hsn, |
| 2503 | pars.fhp.maio_hsn.maio, |
| 2504 | pars.fhp.ma)); |
Vadim Yanitskiy | 6c71c17 | 2020-07-13 21:49:48 +0700 | [diff] [blame] | 2505 | } |
| 2506 | } |
| 2507 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2508 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2509 | 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] | 2510 | var ChannelDescription ch_desc; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2511 | |
| 2512 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 2513 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2514 | |
Vadim Yanitskiy | 28cabc4 | 2020-05-27 19:44:44 +0700 | [diff] [blame] | 2515 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 2516 | if (g_pars.fhp.enabled) { |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 2517 | 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] | 2518 | } else { |
Vadim Yanitskiy | f54db11 | 2020-11-16 18:00:15 +0700 | [diff] [blame] | 2519 | var TrxParsItem trx_pars := mp_trx_pars[g_pars.trx_nr]; |
| 2520 | 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] | 2521 | } |
| 2522 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2523 | /* enable dedicated mode */ |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 2524 | f_l1ctl_est_dchan(L1CTL, g_pars); |
| 2525 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 2526 | /* enable encryption, if requested */ |
| 2527 | if (encr_enable) { |
| 2528 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 2529 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 2530 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2531 | |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2532 | /* Send TCH Mode Request to the L1 if needed */ |
| 2533 | if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) { |
| 2534 | var L1ctlTchMode tch_mode; |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2535 | var uint8_t amr_start_codec := 0; |
| 2536 | var BIT8 amr_codecs_bitmask := '00000000'B; |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2537 | |
| 2538 | select (g_pars.chan_mode.coding_alg_rate) { |
| 2539 | case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; } |
| 2540 | case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; } |
| 2541 | 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] | 2542 | case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; |
| 2543 | amr_codecs_bitmask := g_pars.mr_conf.amr_codec_modes; |
| 2544 | } |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2545 | case else { |
| 2546 | log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate, |
| 2547 | " is not supported by the L1, falling back to signalling"); |
| 2548 | tch_mode := L1CTL_CHAN_MODE_SIGN; |
| 2549 | } |
| 2550 | } |
| 2551 | |
Pau Espin Pedrol | 440e1dc | 2022-09-02 16:35:49 +0200 | [diff] [blame] | 2552 | f_L1CTL_TCH_MODE(L1CTL, |
| 2553 | ts_L1CTL_TCH_MODE_REQ(tch_mode, |
| 2554 | amr_start_codec := amr_start_codec, |
| 2555 | amr_codecs_bitmask := amr_codecs_bitmask)); |
Vadim Yanitskiy | 52787bf | 2020-10-19 17:34:52 +0700 | [diff] [blame] | 2556 | } |
| 2557 | |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 2558 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2559 | } |
| 2560 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 2561 | private function get_start_amr_ft() runs on ConnHdlr return integer { |
| 2562 | var integer start_nth; |
| 2563 | if (g_pars.mr_conf.icmi) { |
| 2564 | start_nth := 0; /* FIXME: implement 3GPP TS 45.009 3.4.3 */ |
| 2565 | } else { |
| 2566 | start_nth := g_pars.mr_conf.start_mode; |
| 2567 | } |
| 2568 | |
| 2569 | var integer n := 0; |
| 2570 | for (var integer i:= 7; i >= 0; i := i - 1) { |
| 2571 | if (g_pars.mr_conf.amr_codec_modes[i] == '1'B) { |
| 2572 | if (n == start_nth) { |
| 2573 | return 7 - i; |
| 2574 | } |
| 2575 | n := n + 1; |
| 2576 | } |
| 2577 | } |
| 2578 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2579 | log2str("mr_conf is wrong! ", g_pars.mr_conf)); |
| 2580 | return 0; |
| 2581 | } |
| 2582 | |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2583 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2584 | friend function f_rtpem_activate(inout octetstring payload, |
| 2585 | RtpemConfig cfg := c_RtpemDefaultCfg, |
| 2586 | RtpemMode mode := RTPEM_MODE_BIDIR) |
| 2587 | runs on ConnHdlr { |
| 2588 | /* Step 0: initialize, connect and start the emulation component */ |
| 2589 | vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM"); |
| 2590 | map(vc_RTPEM:RTP, system:RTP); |
| 2591 | map(vc_RTPEM:RTCP, system:RTCP); |
| 2592 | connect(vc_RTPEM:CTRL, self:RTPEM_CTRL); |
| 2593 | connect(vc_RTPEM:DATA, self:RTPEM_DATA); |
| 2594 | vc_RTPEM.start(RTP_Emulation.f_main()); |
| 2595 | |
| 2596 | /* Step 1: configure the RTP parameters */ |
| 2597 | var integer payload_len := 0; |
| 2598 | var octetstring hdr := ''O; |
| 2599 | |
| 2600 | select (g_pars.chan_mode) { |
| 2601 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */ |
| 2602 | { payload_len := 33; hdr := 'D0'O; } |
| 2603 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */ |
| 2604 | { payload_len := 15; hdr := '00'O; } |
| 2605 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */ |
| 2606 | { payload_len := 31; hdr := 'C0'O; } |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 2607 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3)) /* TCH/AFS */ |
| 2608 | { |
| 2609 | var integer amr_ft := get_start_amr_ft(); |
| 2610 | payload_len := f_amrft_payload_len(amr_ft) + 2; |
| 2611 | hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 2612 | } |
| 2613 | case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3)) /* TCH/AHS */ |
| 2614 | { |
| 2615 | var integer amr_ft := get_start_amr_ft(); |
| 2616 | payload_len := f_amrft_payload_len(amr_ft) + 2; |
| 2617 | hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 2618 | } |
| 2619 | case else { |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2620 | setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode); |
| 2621 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2622 | } |
| 2623 | } |
| 2624 | |
| 2625 | /* Pad the payload to conform the expected length */ |
| 2626 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2627 | cfg.tx_fixed_payload := payload; |
| 2628 | f_rtpem_configure(RTPEM_CTRL, cfg); |
| 2629 | |
| 2630 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2631 | var PortNumber rtpem_bind_port := mp_rtpem_bind_port; |
| 2632 | f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port); |
| 2633 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2634 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2635 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2636 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2637 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2638 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit), |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 2639 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?, omit), |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2640 | "IPA CRCX ACK"); |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2641 | 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] | 2642 | |
Vadim Yanitskiy | 0dd96e9 | 2022-05-01 01:36:12 +0300 | [diff] [blame] | 2643 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2644 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2645 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2646 | remote_ip := f_inet_addr(mp_rtpem_bind_ip), |
| 2647 | remote_port := rtpem_bind_port, |
| 2648 | rtp_pt2 := 0), |
| 2649 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?), |
| 2650 | "IPA MDCX ACK"); |
| 2651 | |
| 2652 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2653 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2654 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2655 | f_rtpem_connect(RTPEM_CTRL, bts_bind_ip, bts_bind_port); |
Vadim Yanitskiy | dd228c4 | 2021-07-04 02:37:30 +0200 | [diff] [blame] | 2656 | |
| 2657 | /* Step 5: set the given RTP emulation mode */ |
| 2658 | f_rtpem_mode(RTPEM_CTRL, mode); |
| 2659 | } |
| 2660 | |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 2661 | /* Initialize and start the RTP emulation component for a ConnHdlr */ |
| 2662 | friend function f_osmuxem_activate(inout octetstring payload, |
| 2663 | OsmuxemConfig cfg := c_OsmuxemDefaultCfg, |
| 2664 | OsmuxemMode mode := OSMUXEM_MODE_BIDIR) |
| 2665 | runs on ConnHdlr { |
| 2666 | var RSL_IE_Body ie; |
| 2667 | var OsmuxTxHandle tx_hdl; |
| 2668 | var OsmuxRxHandle rx_hdl; |
| 2669 | /* Step 0: initialize, connect and start the emulation component */ |
| 2670 | vc_OsmuxEM := OSMUX_Emulation_CT.create(testcasename() & "-OsmuxEM"); |
| 2671 | map(vc_OsmuxEM:OSMUX, system:OSMUX); |
| 2672 | connect(vc_OsmuxEM:CTRL, self:OsmuxEM_CTRL); |
| 2673 | connect(vc_OsmuxEM:DATA, self:OsmuxEM_DATA); |
| 2674 | vc_OsmuxEM.start(OSMUX_Emulation.f_main()); |
| 2675 | |
| 2676 | /* Step 1: configure the RTP parameters */ |
| 2677 | var integer payload_len := 31; |
| 2678 | var octetstring hdr := ''O; |
| 2679 | |
| 2680 | /* Pad the payload to conform the expected length */ |
| 2681 | payload := f_pad_oct(hdr & payload, payload_len, '00'O); |
| 2682 | cfg.tx_fixed_payload := payload; |
| 2683 | f_osmuxem_configure(OsmuxEM_CTRL, cfg); |
| 2684 | |
| 2685 | /* Step 2: bind the RTP emulation to the configured address */ |
| 2686 | var PortNumber osmuxem_bind_port := mp_osmuxem_bind_port; |
| 2687 | f_osmuxem_bind(OsmuxEM_CTRL, mp_osmuxem_bind_ip, osmuxem_bind_port); |
| 2688 | rx_hdl := c_OsmuxemDefaultRxHandle; |
| 2689 | rx_hdl.cid := g_pars.loc_osmux_cid; |
| 2690 | f_osmuxem_register_rxhandle(OsmuxEM_CTRL, rx_hdl); |
| 2691 | |
| 2692 | /* Step 3a: send CRCX to create an RTP connection at the IUT */ |
| 2693 | var RSL_Message crcx_ack := f_rsl_transceive_ret( |
| 2694 | /* FIXME (OS#5242): do not include Remote IP/Port IEs because |
| 2695 | * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */ |
| 2696 | ts_RSL_IPA_CRCX(g_chan_nr, omit, omit, g_pars.loc_osmux_cid), |
| 2697 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?, ?), |
| 2698 | "IPA CRCX ACK"); |
| 2699 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 2700 | f_rsl_find_ie(crcx_ack, RSL_IE_OSMO_OSMUX_CID, ie); |
| 2701 | g_pars.rem_osmux_cid := ie.osmux_cid.cid; |
| 2702 | |
| 2703 | |
| 2704 | /* Step 3b: send MDCX with the configured address/port to the IUT */ |
| 2705 | var RSL_Message mdcx_ack := f_rsl_transceive_ret( |
| 2706 | ts_RSL_IPA_MDCX(g_chan_nr, conn_id, |
| 2707 | remote_ip := f_inet_addr(mp_osmuxem_bind_ip), |
| 2708 | remote_port := osmuxem_bind_port, |
| 2709 | rtp_pt2 := 0, |
| 2710 | osmux_cid := g_pars.loc_osmux_cid), |
| 2711 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?, g_pars.rem_osmux_cid), |
| 2712 | "IPA MDCX ACK"); |
| 2713 | |
| 2714 | tx_hdl := valueof(t_TxHandleAMR590(g_pars.rem_osmux_cid)); |
| 2715 | f_osmuxem_register_txhandle(OsmuxEM_CTRL, tx_hdl); |
| 2716 | |
| 2717 | /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */ |
| 2718 | var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip); |
| 2719 | var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port; |
| 2720 | f_osmuxem_connect(OsmuxEM_CTRL, bts_bind_ip, bts_bind_port); |
| 2721 | |
| 2722 | /* Step 5: set the given RTP emulation mode */ |
| 2723 | f_osmuxem_mode(OsmuxEM_CTRL, mode); |
| 2724 | } |
| 2725 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2726 | /* establish DChan, verify existance + contents of measurement reports */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2727 | private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2728 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2729 | RSL.clear; |
| 2730 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 2731 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 2732 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2733 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 2734 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2735 | |
| 2736 | f_est_dchan(); |
| 2737 | |
| 2738 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 2739 | * RSL measurement reports on Abis side */ |
| 2740 | timer T := 8.0; |
| 2741 | T.start; |
| 2742 | alt { |
| 2743 | [] as_l1_sacch(); |
| 2744 | [] as_meas_res(); |
Vadim Yanitskiy | a4f88c6 | 2020-10-19 14:38:37 +0700 | [diff] [blame] | 2745 | [] as_l1_dcch_loop(); |
Vadim Yanitskiy | dc00811 | 2020-10-19 14:42:04 +0700 | [diff] [blame] | 2746 | [] as_l1_tch_loop(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2747 | [] L1CTL.receive { repeat; } |
| 2748 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2749 | /* 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] | 2750 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 2751 | setverdict(pass); |
| 2752 | } |
| 2753 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2754 | 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] | 2755 | } |
| 2756 | } |
| 2757 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 2758 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2759 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2760 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2761 | /* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */ |
| 2762 | private function f_wait_ramp_up() runs on ConnHdlr return integer { |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2763 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2764 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2765 | timer Tup := 10.0; |
| 2766 | Tup.start; |
| 2767 | alt { |
| 2768 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2769 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2770 | log("Received rx_level=", rx_lvl); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2771 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2772 | if (rx_lvl != max_rx_lvl) { |
| 2773 | repeat; |
| 2774 | } |
| 2775 | Tup.stop; |
| 2776 | } |
| 2777 | [] L1CTL.receive { repeat; } |
| 2778 | [] Tup.timeout { |
| 2779 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2780 | log2str("Didn't reach full power ", max_rx_lvl)); |
| 2781 | } |
| 2782 | } |
| 2783 | return max_rx_lvl; |
| 2784 | } |
| 2785 | |
| 2786 | /* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */ |
| 2787 | private function f_verify_ramp_up() runs on ConnHdlr { |
| 2788 | var L1ctlDlMessage l1_dl; |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2789 | var integer initial_rx_lvl := -1; |
| 2790 | var integer last_rx_lvl := -1; |
| 2791 | var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp; |
| 2792 | |
| 2793 | timer T := 2.0; |
| 2794 | alt { |
| 2795 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2796 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2797 | log("Received rx_level=", rx_lvl); |
| 2798 | if (initial_rx_lvl == -1) { |
| 2799 | initial_rx_lvl := rx_lvl; |
| 2800 | last_rx_lvl := rx_lvl; |
| 2801 | |
| 2802 | /* Expect a somehow low value during first received messages */ |
| 2803 | if (initial_rx_lvl >= max_rx_lvl / 2) { |
| 2804 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2805 | log2str("Detected high initial tx power during ramp up: ", |
| 2806 | initial_rx_lvl , ", full power is", max_rx_lvl)); |
| 2807 | } |
| 2808 | } |
| 2809 | |
| 2810 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2811 | if (rx_lvl > max_rx_lvl) { |
| 2812 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2813 | log2str("Detected Tx power higher than full power: ", |
| 2814 | rx_lvl , " > ", max_rx_lvl)); |
| 2815 | } |
| 2816 | |
| 2817 | /* Make sure it never decreases, since we are rumping up */ |
| 2818 | if (last_rx_lvl > rx_lvl) { |
| 2819 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2820 | log2str("Detected Tx power decrease during ramp up: ", |
| 2821 | last_rx_lvl , " -> ", rx_lvl)); |
| 2822 | } |
| 2823 | |
| 2824 | if (rx_lvl == max_rx_lvl and not T.running) { |
| 2825 | /* We reached the maximum power, start timer and receive |
| 2826 | /* a few more to make sure we don't surpass it */ |
| 2827 | log("Reached full power, wating a bit more until success"); |
| 2828 | T.start; |
| 2829 | } |
| 2830 | |
| 2831 | last_rx_lvl := rx_lvl; |
| 2832 | repeat; |
| 2833 | } |
| 2834 | [] L1CTL.receive { repeat; } |
| 2835 | [] T.timeout { } |
| 2836 | } |
| 2837 | |
| 2838 | /* We didn't increase tx power during ramp up */ |
| 2839 | if (initial_rx_lvl < last_rx_lvl) { |
| 2840 | log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl); |
| 2841 | } else { |
| 2842 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2843 | log2str("No Tx power increase during whole ramp up: ", |
| 2844 | initial_rx_lvl , " -> ", last_rx_lvl)); |
| 2845 | } |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2846 | } |
| 2847 | |
| 2848 | /* verify BTS ramps power down to rx_level 0 */ |
| 2849 | private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr { |
| 2850 | var L1ctlDlMessage l1_dl; |
| 2851 | var integer last_rx_lvl := max_rx_lvl; |
| 2852 | |
| 2853 | timer Tdown := 5.0; |
| 2854 | Tdown.start; |
| 2855 | alt { |
| 2856 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2857 | var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level; |
| 2858 | log("Received rx_level=", rx_lvl); |
| 2859 | |
| 2860 | /* received Rx level bigger than maximum allowed power by CN */ |
| 2861 | if (rx_lvl > max_rx_lvl) { |
| 2862 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2863 | log2str("Detected Tx power higher than full power: ", |
| 2864 | rx_lvl , " > ", max_rx_lvl)); |
| 2865 | } |
| 2866 | |
| 2867 | /* Make sure it never increases, since we are rumping down */ |
| 2868 | if (last_rx_lvl < rx_lvl) { |
| 2869 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2870 | log2str("Detected Tx power increase during ramp up: ", |
| 2871 | last_rx_lvl , " -> ", rx_lvl)); |
| 2872 | } |
| 2873 | |
| 2874 | last_rx_lvl := rx_lvl; |
| 2875 | if (last_rx_lvl != 0) { |
| 2876 | repeat; |
| 2877 | } |
| 2878 | /* we reached power level 0, we are done */ |
| 2879 | Tdown.stop; |
| 2880 | } |
| 2881 | [] L1CTL.receive { repeat; } |
| 2882 | [] Tdown.timeout { } |
| 2883 | } |
| 2884 | |
| 2885 | /* We didn't increase tx power during ramp down */ |
| 2886 | if (max_rx_lvl > last_rx_lvl) { |
| 2887 | log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl); |
| 2888 | } else { |
| 2889 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2890 | log2str("No Tx power decrease during whole ramp down: ", |
| 2891 | max_rx_lvl , " -> ", last_rx_lvl)); |
| 2892 | } |
| 2893 | } |
| 2894 | |
| 2895 | /* Verify Tx power reduction and ramping up during BTS bring up */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2896 | 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] | 2897 | f_l1_tune(L1CTL); |
| 2898 | RSL.clear; |
| 2899 | |
| 2900 | f_verify_ramp_up(); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 2901 | |
| 2902 | setverdict(pass); |
| 2903 | } |
| 2904 | testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT { |
| 2905 | var ConnHdlr vc_conn; |
| 2906 | var ConnHdlrPars pars; |
| 2907 | f_init(); |
| 2908 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2909 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars, |
| 2910 | pcu_comp := false, trxc_comp := true); |
| 2911 | vc_conn.done; |
| 2912 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2913 | } |
| 2914 | |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2915 | /* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2916 | private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr { |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 2917 | f_connhdlr_init_vty_bsc(); |
| 2918 | |
| 2919 | f_l1_tune(L1CTL); |
| 2920 | RSL.clear; |
| 2921 | |
| 2922 | /* Wait until BTS is started and at full power */ |
| 2923 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2924 | log("Reached nominal level ", max_rx_lvl, ", shutting down OML link"); |
| 2925 | |
| 2926 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 2927 | f_verify_ramp_down(max_rx_lvl); |
| 2928 | |
| 2929 | setverdict(pass); |
| 2930 | } |
| 2931 | testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT { |
| 2932 | var ConnHdlr vc_conn; |
| 2933 | var ConnHdlrPars pars; |
| 2934 | f_init(); |
| 2935 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2936 | vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars, |
| 2937 | pcu_comp := false, trxc_comp := true); |
| 2938 | vc_conn.done; |
| 2939 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2940 | } |
| 2941 | |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 2942 | /* Verify Tx power: |
| 2943 | * + ramping down during ADM state UNLOCKED->LOCKED |
| 2944 | * + ramping up during ADM state LOCKED->UNLOCKED |
| 2945 | */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 2946 | 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] | 2947 | var L1ctlDlMessage l1_dl; |
| 2948 | var integer last_rx_lvl; |
| 2949 | |
| 2950 | f_connhdlr_init_vty_bsc(); |
| 2951 | |
| 2952 | f_l1_tune(L1CTL); |
| 2953 | RSL.clear; |
| 2954 | |
| 2955 | /* Wait until BTS is started and at full power */ |
| 2956 | var integer max_rx_lvl := f_wait_ramp_up(); |
| 2957 | log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED"); |
| 2958 | |
| 2959 | log("ADM STATE UNLOCKED->LOCKED"); |
| 2960 | f_vty_enter_cfg_trx(BSCVTY); |
| 2961 | f_vty_transceive(BSCVTY, "rf_locked 1"); |
| 2962 | last_rx_lvl := max_rx_lvl; |
| 2963 | f_verify_ramp_down(max_rx_lvl); |
| 2964 | |
| 2965 | /* Let some time after we received 0dBm, then check we don't receive BCCH |
| 2966 | * anymore because scheduler has stopped after ramping down */ |
| 2967 | f_sleep(2.0); |
| 2968 | L1CTL.clear; |
| 2969 | timer Tlocked := 2.0; |
| 2970 | Tlocked.start; |
| 2971 | alt { |
| 2972 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 2973 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2974 | log2str("Received data_ind during rf_locked: ", l1_dl)); |
| 2975 | } |
| 2976 | [] L1CTL.receive { repeat; } |
| 2977 | [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); } |
| 2978 | } |
| 2979 | |
| 2980 | log("ADM STATE LOCKED->UNLOCKED"); |
| 2981 | f_vty_transceive(BSCVTY, "rf_locked 0"); |
| 2982 | f_verify_ramp_up(); |
| 2983 | setverdict(pass); |
| 2984 | } |
| 2985 | testcase TC_tx_power_ramp_adm_state_change() runs on test_CT { |
| 2986 | var ConnHdlr vc_conn; |
| 2987 | var ConnHdlrPars pars; |
| 2988 | f_init(); |
| 2989 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN)); |
| 2990 | vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars, |
| 2991 | pcu_comp := false, trxc_comp := true); |
| 2992 | vc_conn.done; |
| 2993 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2994 | } |
| 2995 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 2996 | 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] | 2997 | timer T := 8.0; |
| 2998 | T.start; |
| 2999 | var RSL_Message rsl; |
| 3000 | alt { |
| 3001 | [] as_l1_sacch(); |
| 3002 | [] L1CTL.receive { repeat; } |
| 3003 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 3004 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 3005 | setverdict(pass) |
| 3006 | } else { |
| 3007 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 3008 | } |
| 3009 | } |
| 3010 | [] T.timeout { |
| 3011 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 3012 | } |
| 3013 | } |
| 3014 | } |
| 3015 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3016 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 3017 | * set _during_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3018 | 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] | 3019 | f_l1_tune(L1CTL); |
| 3020 | RSL.clear; |
| 3021 | |
| 3022 | if (mp_bts_trxc_port != -1) { |
| 3023 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 3024 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 3025 | } |
| 3026 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 3027 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3028 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 3029 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 3030 | |
| 3031 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3032 | |
| 3033 | f_check_meas_bs_power_level(pwr_var); |
| 3034 | |
| 3035 | f_rsl_chan_deact(); |
| 3036 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3037 | } |
| 3038 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3039 | /* See if the RSL MEASurement RESult contains expeced BS power level |
| 3040 | * set _after_ the CHANnel ACTIVation procedure. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3041 | 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] | 3042 | f_l1_tune(L1CTL); |
| 3043 | RSL.clear; |
| 3044 | |
| 3045 | if (mp_bts_trxc_port != -1) { |
| 3046 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 3047 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 3048 | } |
| 3049 | |
Vadim Yanitskiy | 117c176 | 2020-06-16 01:40:10 +0700 | [diff] [blame] | 3050 | var uint4_t pwr_var := 1; |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3051 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 3052 | |
| 3053 | f_est_dchan(); |
| 3054 | |
| 3055 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 3056 | |
| 3057 | f_check_meas_bs_power_level(pwr_var); |
| 3058 | |
| 3059 | f_rsl_chan_deact(); |
| 3060 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3061 | } |
| 3062 | |
| 3063 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 3064 | var ConnHdlr vc_conn; |
| 3065 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3066 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3067 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3068 | |
| 3069 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 3070 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 3071 | pcu_comp := false, trxc_comp := true); |
| 3072 | vc_conn.done; |
| 3073 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3074 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3075 | } |
| 3076 | |
| 3077 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 3078 | var ConnHdlr vc_conn; |
| 3079 | var ConnHdlrPars pars; |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3080 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3081 | f_init(); |
Vadim Yanitskiy | da5964d | 2021-10-23 16:27:27 +0300 | [diff] [blame] | 3082 | |
| 3083 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1)); |
| 3084 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 3085 | pcu_comp := false, trxc_comp := true); |
| 3086 | vc_conn.done; |
| 3087 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 3088 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3089 | } |
| 3090 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3091 | /* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 3092 | * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds. |
| 3093 | * 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] | 3094 | 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] | 3095 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3096 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3097 | |
| 3098 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3099 | f_l1_tune(L1CTL); |
| 3100 | RSL.clear; |
| 3101 | |
| 3102 | var RSL_IE_List addl_ies; |
| 3103 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3104 | |
| 3105 | addl_ies := { |
| 3106 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3107 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3108 | }; |
| 3109 | |
| 3110 | /* establish with power parameters */ |
| 3111 | f_est_dchan(more_ies := addl_ies); |
| 3112 | |
| 3113 | /* set a high value to ensure L1 power control level increases */ |
| 3114 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 3115 | |
| 3116 | timer T2 := 6.0; |
| 3117 | T2.start; |
| 3118 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3119 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3120 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3121 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3122 | if (l1h.ms_power_lvl < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3123 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 3124 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3125 | T2.stop; |
| 3126 | } |
| 3127 | [] L1CTL.receive { repeat; } |
| 3128 | [] T2.timeout { |
| 3129 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3130 | "Power Level in L1 header has not increased sufficiently"); |
| 3131 | } |
| 3132 | } |
| 3133 | |
| 3134 | /* set a low value to ensure L1 power control level decreases */ |
| 3135 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 3136 | |
| 3137 | timer T4 := 6.0; |
| 3138 | T4.start; |
| 3139 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3140 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3141 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3142 | |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3143 | if (l1h.ms_power_lvl > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3144 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 3145 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3146 | T4.stop; |
| 3147 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 3148 | } |
| 3149 | [] L1CTL.receive { repeat; } |
| 3150 | [] T4.timeout { |
| 3151 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3152 | "Power Level in L1 header has not decreased sufficiently"); |
| 3153 | } |
| 3154 | } |
| 3155 | |
| 3156 | f_rsl_chan_deact(); |
| 3157 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3158 | |
| 3159 | } |
| 3160 | |
| 3161 | /* check that we do not exceed the max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3162 | 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] | 3163 | var uint5_t pwr_var := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3164 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3165 | |
| 3166 | /* set a low value to ensure power increases */ |
| 3167 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3168 | f_l1_tune(L1CTL); |
| 3169 | RSL.clear; |
| 3170 | |
| 3171 | var RSL_IE_List addl_ies; |
| 3172 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 3173 | |
| 3174 | addl_ies := { |
| 3175 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 3176 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 3177 | }; |
| 3178 | |
| 3179 | /* establish with power parameters */ |
| 3180 | f_est_dchan(more_ies := addl_ies); |
| 3181 | |
| 3182 | timer T1 := 10.0; |
| 3183 | T1.start; |
| 3184 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3185 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3186 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3187 | repeat; |
| 3188 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3189 | [] L1CTL.receive { repeat; } |
| 3190 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3191 | if (not isbound(l1h)) { |
| 3192 | setverdict(fail, "No SACCH blocks were received"); |
| 3193 | } else if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3194 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 3195 | } |
| 3196 | } |
| 3197 | } |
| 3198 | |
| 3199 | f_rsl_chan_deact(); |
| 3200 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3201 | |
| 3202 | } |
| 3203 | |
| 3204 | /* see if we reach the band max power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3205 | 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] | 3206 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3207 | var uint5_t pwr_var := 15; |
| 3208 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 3209 | |
| 3210 | /* set a low value to ensure power increases */ |
| 3211 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 3212 | f_l1_tune(L1CTL); |
| 3213 | RSL.clear; |
| 3214 | |
| 3215 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3216 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3217 | |
| 3218 | /* establish with fixed power level */ |
| 3219 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3220 | |
| 3221 | /* check our initial power level */ |
| 3222 | f_wait_for_l1_power_level(pwr_var); |
| 3223 | |
| 3224 | /* update power param to enable power loop |
| 3225 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 3226 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 3227 | |
Vadim Yanitskiy | 93ad814 | 2022-04-08 01:52:13 +0300 | [diff] [blame] | 3228 | /* By default, the MS power loop gets triggered every 4th SACCH block (1.92s). |
| 3229 | * We need 9 * 4 dB steps to get from 0 dBm to 33 dBm, so 9 * 1.92s total. |
| 3230 | * Add an extra offset to avoid race conditions: +1.92s. */ |
| 3231 | timer T1 := 9.0 * 1.92 + 1.92; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3232 | T1.start; |
| 3233 | alt { |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3234 | [] as_l1_sacch_l1h(l1h) { |
Vadim Yanitskiy | a2cd893 | 2022-08-10 17:56:25 +0700 | [diff] [blame] | 3235 | f_send_meas_rep_l1h(ts_MeasurementResults, l1h); |
Vadim Yanitskiy | 3999491 | 2022-07-30 18:06:13 +0700 | [diff] [blame] | 3236 | repeat; |
| 3237 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3238 | [] L1CTL.receive { repeat; } |
| 3239 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3240 | if (not isbound(l1h)) { |
| 3241 | setverdict(fail, "No SACCH blocks were received"); |
| 3242 | } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3243 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 3244 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3245 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ", |
| 3246 | "reach the expected value := ", pwr_max_var); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3247 | } |
| 3248 | } |
| 3249 | } |
| 3250 | |
| 3251 | f_rsl_chan_deact(); |
| 3252 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3253 | |
| 3254 | } |
| 3255 | |
| 3256 | /* see if we reach the band min power */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3257 | 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] | 3258 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3259 | |
| 3260 | /* set a high value to ensure power decreases */ |
| 3261 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3262 | f_l1_tune(L1CTL); |
| 3263 | RSL.clear; |
| 3264 | |
| 3265 | var uint5_t pwr_var := 5; |
| 3266 | var uint5_t pwr_target_val := 15; |
| 3267 | |
| 3268 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3269 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3270 | |
| 3271 | /* establish with fixed power level */ |
| 3272 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3273 | |
| 3274 | /* check our initial power level */ |
| 3275 | f_wait_for_l1_power_level(pwr_var); |
| 3276 | |
| 3277 | /* update power param to enable power loop |
| 3278 | 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] | 3279 | 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] | 3280 | |
| 3281 | /* wait, then check that our power level was increased */ |
| 3282 | timer T1 := 10.0; |
| 3283 | T1.start; |
| 3284 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3285 | [] as_l1_sacch_l1h(l1h) { repeat; } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3286 | [] L1CTL.receive { repeat; } |
| 3287 | [] T1.timeout { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3288 | if (not isbound(l1h)) { |
| 3289 | setverdict(fail, "No SACCH blocks were received"); |
| 3290 | } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) { |
| 3291 | setverdict(pass, "Power level increased to lowest power value"); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3292 | } else { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3293 | setverdict(fail, "Power level NOT increased to lowest power value"); |
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 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3303 | /* See if the power level remains constant when MS Power Parameters IE |
| 3304 | * is _absent_ in the CHANnel ACTIVation message. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3305 | 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] | 3306 | var SacchL1Header l1h; |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3307 | |
| 3308 | /* set a high value to ensure power decreases */ |
| 3309 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3310 | f_l1_tune(L1CTL); |
| 3311 | RSL.clear; |
| 3312 | |
| 3313 | var uint5_t pwr_var := 5; |
| 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 | /* wait, then check that our power level did not change */ |
| 3325 | timer T1 := 10.0; |
| 3326 | T1.start; |
| 3327 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3328 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3329 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3330 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3331 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3332 | } |
| 3333 | repeat; |
| 3334 | } |
| 3335 | [] L1CTL.receive { repeat; } |
| 3336 | [] T1.timeout { setverdict(pass); } |
| 3337 | } |
| 3338 | |
| 3339 | f_rsl_chan_deact(); |
| 3340 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3341 | |
| 3342 | } |
| 3343 | |
Vadim Yanitskiy | 6860e86 | 2021-06-30 00:16:26 +0200 | [diff] [blame] | 3344 | /* See if the power level remains constant when MS Power Parameters IE |
| 3345 | * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 3346 | 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] | 3347 | var SacchL1Header l1h; |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3348 | |
| 3349 | /* set a high value to ensure power decreases */ |
| 3350 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 3351 | f_l1_tune(L1CTL); |
| 3352 | RSL.clear; |
| 3353 | |
| 3354 | var uint5_t pwr_var := 5; |
| 3355 | |
| 3356 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 3357 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 3358 | |
| 3359 | /* establish with fixed power level */ |
| 3360 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 3361 | |
| 3362 | /* check our initial power level */ |
| 3363 | f_wait_for_l1_power_level(pwr_var); |
| 3364 | |
| 3365 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 3366 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3367 | |
| 3368 | /* wait, then check that our power level did not change */ |
| 3369 | timer T1 := 10.0; |
| 3370 | T1.start; |
| 3371 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3372 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3373 | if (l1h.ms_power_lvl != pwr_var) { |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3374 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3375 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 3376 | } |
| 3377 | repeat; |
| 3378 | } |
| 3379 | [] L1CTL.receive { repeat; } |
| 3380 | [] T1.timeout { setverdict(pass); } |
| 3381 | } |
| 3382 | |
| 3383 | f_rsl_chan_deact(); |
| 3384 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3385 | |
| 3386 | } |
| 3387 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3388 | 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] | 3389 | var SacchL1Header l1h; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3390 | timer T0 := 10.0; |
| 3391 | T0.start; |
| 3392 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3393 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3394 | if (l1h.ms_power_lvl != level) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3396 | "Power level in L1 header != signaled (RSL) power level."); |
| 3397 | } |
| 3398 | } |
| 3399 | [] L1CTL.receive { repeat; } |
| 3400 | [] T0.timeout { |
| 3401 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 3402 | "Timeout waiting for initial power level"); |
| 3403 | } |
| 3404 | } |
| 3405 | T0.stop; |
| 3406 | } |
| 3407 | |
| 3408 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3409 | var IntegerRecord min_dbm_level; |
| 3410 | var IntegerRecord max_dbm_level; |
| 3411 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3412 | |
| 3413 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 3414 | if (min_dbm_level[i] == level) { |
| 3415 | return true; |
| 3416 | } |
| 3417 | } |
| 3418 | return false; |
| 3419 | } |
| 3420 | |
| 3421 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 3422 | var IntegerRecord min_dbm_level; |
| 3423 | var IntegerRecord max_dbm_level; |
| 3424 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3425 | |
| 3426 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 3427 | if (max_dbm_level[i] == level) { |
| 3428 | return true; |
| 3429 | } |
| 3430 | } |
| 3431 | return false; |
| 3432 | } |
| 3433 | |
| 3434 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 3435 | var IntegerRecord min_dbm_level; |
| 3436 | var IntegerRecord max_dbm_level; |
| 3437 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 3438 | return max_dbm_level[0]; |
| 3439 | } |
| 3440 | |
| 3441 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3442 | private template charstring BtsBand_allGSM := pattern "GSM???"; |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3443 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 3444 | // 45.005 4.1.1 |
| 3445 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 3446 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 3447 | 2, 1, 0}; |
| 3448 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 3449 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 3450 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 3451 | var IntegerRecord rv; |
| 3452 | |
| 3453 | select(band){ |
| 3454 | case (BtsBand_allGSM){ |
| 3455 | rv := gsm_power; |
| 3456 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 3457 | max_dbm_level := {2, 1, 0}; |
| 3458 | } |
| 3459 | case("DCS1800"){ |
| 3460 | rv := dcs_power; |
| 3461 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 3462 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 3463 | } |
| 3464 | case("PCS1900"){ |
| 3465 | rv := pcs_power; |
| 3466 | min_dbm_level := {15}; |
| 3467 | max_dbm_level := {30}; |
| 3468 | } |
Harald Welte | 194b691 | 2020-10-11 21:01:55 +0200 | [diff] [blame] | 3469 | case else { |
| 3470 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band); |
| 3471 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 3472 | } |
| 3473 | |
| 3474 | return rv; |
| 3475 | } |
| 3476 | |
| 3477 | 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] | 3478 | 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] | 3479 | } |
| 3480 | |
| 3481 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 3482 | var ConnHdlr vc_conn; |
| 3483 | var ConnHdlrPars pars; |
| 3484 | f_init(); |
| 3485 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3486 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3487 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3488 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3489 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 3490 | vc_conn.done; |
| 3491 | } |
| 3492 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3493 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3494 | } |
| 3495 | |
| 3496 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 3497 | var ConnHdlr vc_conn; |
| 3498 | var ConnHdlrPars pars; |
| 3499 | f_init(); |
| 3500 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3501 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
Vadim Yanitskiy | c78aeb7 | 2022-07-30 17:56:39 +0700 | [diff] [blame] | 3502 | 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] | 3503 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3504 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 3505 | vc_conn.done; |
| 3506 | } |
| 3507 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3508 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3509 | } |
| 3510 | |
| 3511 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 3512 | var ConnHdlr vc_conn; |
| 3513 | var ConnHdlrPars pars; |
| 3514 | f_init(); |
| 3515 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 3516 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3517 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3518 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3519 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 3520 | vc_conn.done; |
| 3521 | } |
| 3522 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3523 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3524 | } |
| 3525 | |
| 3526 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 3527 | var ConnHdlr vc_conn; |
| 3528 | var ConnHdlrPars pars; |
| 3529 | f_init(); |
| 3530 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3531 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3532 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3533 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3534 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 3535 | vc_conn.done; |
| 3536 | } |
| 3537 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3538 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3539 | } |
| 3540 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 3541 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 3542 | var ConnHdlr vc_conn; |
| 3543 | var ConnHdlrPars pars; |
| 3544 | f_init(); |
| 3545 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3546 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3547 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3548 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3549 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 3550 | vc_conn.done; |
| 3551 | } |
| 3552 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3553 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3554 | } |
| 3555 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 3556 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 3557 | var ConnHdlr vc_conn; |
| 3558 | var ConnHdlrPars pars; |
| 3559 | f_init(); |
| 3560 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 3561 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 3562 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3563 | pars.bts0_band := f_vty_get_bts0_band(); |
| 3564 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 3565 | vc_conn.done; |
| 3566 | } |
| 3567 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 3568 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3569 | } |
| 3570 | |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3571 | 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] | 3572 | var template RSL_IE_ChannelMode ch_mode; |
| 3573 | var ConnHdlr vc_conn; |
| 3574 | var ConnHdlrPars pars; |
| 3575 | f_init(); |
| 3576 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3577 | for (var integer tn := 1; tn <= 1; tn := tn + 1) { |
| 3578 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3579 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3580 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3581 | pcu_comp := false, trxc_comp := true); |
| 3582 | vc_conn.done; |
| 3583 | } |
| 3584 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3585 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3586 | |
| 3587 | testcase TC_meas_res_speech_tchf() runs on test_CT { |
| 3588 | f_TC_meas_res_speech_tchf(false); |
| 3589 | } |
| 3590 | |
| 3591 | testcase TC_meas_res_speech_tchf_facch() runs on test_CT { |
| 3592 | f_TC_meas_res_speech_tchf(true); |
| 3593 | } |
| 3594 | |
| 3595 | 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] | 3596 | var template RSL_IE_ChannelMode ch_mode; |
| 3597 | var ConnHdlr vc_conn; |
| 3598 | var ConnHdlrPars pars; |
| 3599 | f_init(); |
| 3600 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3601 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3602 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3603 | pars.l1_pars.facch_enabled := facch_enabled; |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3604 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3605 | pcu_comp := false, trxc_comp := true); |
| 3606 | vc_conn.done; |
| 3607 | } |
| 3608 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3609 | } |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 3610 | |
| 3611 | testcase TC_meas_res_speech_tchh() runs on test_CT { |
| 3612 | f_TC_meas_res_speech_tchh(false) |
| 3613 | } |
| 3614 | |
| 3615 | testcase TC_meas_res_speech_tchh_facch() runs on test_CT { |
| 3616 | f_TC_meas_res_speech_tchh(true) |
| 3617 | } |
| 3618 | |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 3619 | testcase TC_meas_res_speech_tchh_toa256() runs on test_CT { |
| 3620 | var template RSL_IE_ChannelMode ch_mode; |
| 3621 | var ConnHdlr vc_conn; |
| 3622 | var ConnHdlrPars pars; |
| 3623 | f_init(); |
| 3624 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3625 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3626 | for (var integer ss := 0; ss <= 1; ss := ss + 1) { |
| 3627 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode)); |
| 3628 | pars.l1_pars.toa256_enabled := true; |
| 3629 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3630 | pcu_comp := false, trxc_comp := true); |
| 3631 | vc_conn.done; |
| 3632 | } |
| 3633 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3634 | } |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 3635 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3636 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 3637 | var ConnHdlr vc_conn; |
| 3638 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3639 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3640 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3641 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3642 | 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] | 3643 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3644 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3645 | vc_conn.done; |
| 3646 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3647 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3648 | } |
| 3649 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 3650 | var ConnHdlr vc_conn; |
| 3651 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3652 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3653 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3654 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3655 | 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] | 3656 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3657 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3658 | vc_conn.done; |
| 3659 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3660 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3661 | } |
| 3662 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 3663 | var ConnHdlr vc_conn; |
| 3664 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3665 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3666 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3667 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 3668 | 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] | 3669 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3670 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3671 | vc_conn.done; |
| 3672 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3673 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3674 | } |
| 3675 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 3676 | var ConnHdlr vc_conn; |
| 3677 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3678 | f_init(); |
Pau Espin Pedrol | 93a7b8b | 2021-10-08 16:57:50 +0200 | [diff] [blame] | 3679 | f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3680 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 3681 | 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] | 3682 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3683 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3684 | vc_conn.done; |
| 3685 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3686 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3687 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3688 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 3689 | var ConnHdlr vc_conn; |
| 3690 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3691 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3692 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 3693 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 3694 | 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] | 3695 | pars.l1_pars.toa256_enabled := true; |
Vadim Yanitskiy | 0b65219 | 2020-10-20 02:39:02 +0700 | [diff] [blame] | 3696 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 3697 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3698 | vc_conn.done; |
| 3699 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3700 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3701 | } |
| 3702 | |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 3703 | /* Make sure that we always get RSL MEASurement RESult messages regardless |
| 3704 | * of what is sent on SACCH: (RR) Measurement Report or SAPI=3 data (SMS). */ |
| 3705 | private function f_TC_meas_res_sapi3(charstring id) runs on ConnHdlr { |
| 3706 | timer Texec := 8.0; |
| 3707 | timer Timpf := 2.0; |
| 3708 | timer Tmr; |
| 3709 | |
| 3710 | f_l1_tune(L1CTL); |
| 3711 | RSL.clear; |
| 3712 | |
| 3713 | f_est_dchan(); |
| 3714 | L1CTL.clear; |
| 3715 | |
| 3716 | /* Establish the main SAPI=0 link on DCCH first */ |
| 3717 | f_tx_lapdm(ts_LAPDm_SABM(0, cr_MO_CMD, true, ''O), ts_RslLinkID_DCCH(0)); |
| 3718 | |
| 3719 | /* Give more time for the first RSL MEASurement RESult */ |
| 3720 | Tmr.start(0.480 * 2.0); |
| 3721 | Texec.start; /* EXECution timer */ |
| 3722 | Timpf.start; /* IMPFung timer */ |
| 3723 | |
| 3724 | alt { |
| 3725 | /* We expect RSL MEASurement RESult messages every ~480ms (plus some guard) */ |
| 3726 | [] RSL.receive(tr_RSL_MEAS_RES(g_pars.chan_nr)) { |
| 3727 | /* Reschedule the MEAS RES timer */ |
| 3728 | Tmr.start(0.480 + 0.120); |
| 3729 | repeat; |
| 3730 | } |
| 3731 | [] RSL.receive { repeat; } |
| 3732 | [] Tmr.timeout { |
| 3733 | setverdict(fail, "Timeout waiting for RSL MEAS RES"); |
| 3734 | } |
| 3735 | /* Inject some SAPI=3 traffic on SACCH every 2 seconds */ |
| 3736 | [] Timpf.timeout { |
| 3737 | f_tx_lapdm(ts_LAPDm_SABM(3, cr_MO_CMD, true, ''O), ts_RslLinkID_SACCH(3)); |
| 3738 | log("Injected SAPI=3 traffic on SACCH"); |
| 3739 | Timpf.start; |
| 3740 | repeat; |
| 3741 | } |
| 3742 | /* We're good if survived so far */ |
| 3743 | [] Texec.timeout { |
| 3744 | setverdict(pass); |
| 3745 | } |
| 3746 | } |
| 3747 | |
| 3748 | f_rsl_chan_deact(); |
| 3749 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3750 | f_rslem_unregister(0, g_chan_nr); |
| 3751 | } |
| 3752 | testcase TC_meas_res_speech_tchf_sapi3() runs on test_CT { |
| 3753 | var template RSL_IE_ChannelMode ch_mode; |
| 3754 | var template ConnHdlrPars pars; |
| 3755 | var ConnHdlr vc_conn; |
| 3756 | |
| 3757 | f_init(); |
| 3758 | |
| 3759 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1); |
| 3760 | pars := t_Pars(t_RslChanNr_Bm(1), ch_mode); |
| 3761 | |
| 3762 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3763 | vc_conn.done; |
| 3764 | |
| 3765 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3766 | } |
| 3767 | testcase TC_meas_res_speech_tchh_sapi3() runs on test_CT { |
| 3768 | var template RSL_IE_ChannelMode ch_mode; |
| 3769 | var template ConnHdlrPars pars; |
| 3770 | var ConnHdlr vc_conn; |
| 3771 | |
| 3772 | f_init(); |
| 3773 | |
| 3774 | ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1); |
| 3775 | pars := t_Pars(t_RslChanNr_Lm(5, 0), ch_mode); |
| 3776 | |
| 3777 | vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars)); |
| 3778 | vc_conn.done; |
| 3779 | |
| 3780 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3781 | } |
| 3782 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3783 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 3784 | * 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] | 3785 | 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] | 3786 | var SacchL1Header l1h; |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3787 | var RSL_IE_MS_Power ms_power; |
| 3788 | var RSL_Message rsl; |
| 3789 | var uint5_t power_level := 0; |
| 3790 | |
| 3791 | f_l1_tune(L1CTL); |
| 3792 | RSL.clear; |
| 3793 | |
| 3794 | f_est_dchan(); |
| 3795 | |
| 3796 | ms_power.reserved := 0; |
| 3797 | ms_power.fpc_epc := false; |
| 3798 | |
| 3799 | /* Send the first power control command. This will disable any BTS/TRX |
| 3800 | * internal power control and switch the MS (which is not in scope of |
| 3801 | * this test) to a constant power level. We start with a power level |
| 3802 | * of 0 */ |
| 3803 | ms_power.power_level := power_level; |
| 3804 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3805 | RSL.send(rsl); |
| 3806 | |
| 3807 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3808 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3809 | if (l1h.ms_power_lvl != power_level) { |
| 3810 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3811 | "match the signaled (RSL) power level := ", power_level); |
| 3812 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3813 | } |
| 3814 | |
| 3815 | /* Signal a new power level via RSL for the next turn. */ |
| 3816 | if (power_level < 31) { |
| 3817 | power_level := power_level + 1; |
| 3818 | ms_power.power_level := power_level; |
| 3819 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 3820 | RSL.send(rsl); |
| 3821 | repeat; |
| 3822 | } |
| 3823 | |
| 3824 | } |
| 3825 | |
| 3826 | /* Ignore all other blocks */ |
| 3827 | [] L1CTL.receive { repeat; } |
| 3828 | |
| 3829 | } |
| 3830 | |
| 3831 | f_rsl_chan_deact(); |
| 3832 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3833 | |
| 3834 | setverdict(pass); |
| 3835 | } |
| 3836 | |
| 3837 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 3838 | var ConnHdlr vc_conn; |
| 3839 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3840 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 3841 | |
| 3842 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 3843 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 3844 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 3845 | vc_conn.done; |
| 3846 | } |
| 3847 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3848 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3849 | |
Pau Espin Pedrol | 188bfd2 | 2020-06-03 20:32:45 +0200 | [diff] [blame] | 3850 | /* 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] | 3851 | 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] | 3852 | 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] | 3853 | var uint5_t ta_to_test := 16; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3854 | var SacchL1Header l1h; |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3855 | |
| 3856 | f_l1_tune(L1CTL); |
| 3857 | RSL.clear; |
| 3858 | |
| 3859 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 3860 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3861 | |
| 3862 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 3863 | |
| 3864 | |
| 3865 | alt { |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3866 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3867 | if (l1h.actual_ta != ta_to_test) { |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3868 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 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_chan_initial_ta() 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(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3888 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 3889 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 3890 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 3891 | vc_conn.done; |
| 3892 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3893 | } |
| 3894 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3895 | /* 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] | 3896 | 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] | 3897 | var uint5_t ms_power_level := 7; |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3898 | var SacchL1Header l1h; |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3899 | |
| 3900 | var RSL_IE_MS_Power ms_power; |
| 3901 | ms_power.reserved := 0; |
| 3902 | ms_power.fpc_epc := false; |
| 3903 | ms_power.power_level := ms_power_level; |
| 3904 | |
| 3905 | f_l1_tune(L1CTL); |
| 3906 | RSL.clear; |
| 3907 | |
| 3908 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 3909 | |
| 3910 | timer T := 1.0; |
| 3911 | T.start; |
| 3912 | alt { |
| 3913 | /* Pick all SACCH blocks for checking */ |
Vadim Yanitskiy | ab5769c | 2020-11-11 07:02:28 +0700 | [diff] [blame] | 3914 | [] as_l1_sacch_l1h(l1h, do_apply := false) { |
| 3915 | if (l1h.ms_power_lvl != ms_power_level) { |
| 3916 | setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ", |
| 3917 | "match the signaled (RSL) power level := ", ms_power_level); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 3918 | } |
| 3919 | } |
| 3920 | /* Ignore all other blocks */ |
| 3921 | [] L1CTL.receive { repeat; } |
| 3922 | [] T.timeout { |
| 3923 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 3924 | } |
| 3925 | } |
| 3926 | |
| 3927 | f_rsl_chan_deact(); |
| 3928 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3929 | setverdict(pass); |
| 3930 | } |
| 3931 | |
| 3932 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 3933 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3934 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 3935 | } |
| 3936 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3937 | /* 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] | 3938 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3939 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3940 | RSL.clear; |
| 3941 | |
| 3942 | f_est_dchan(); |
| 3943 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3944 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3945 | |
| 3946 | timer T := 40.0; |
| 3947 | T.start; |
| 3948 | alt { |
| 3949 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 3950 | setverdict(pass) |
| 3951 | } |
| 3952 | [] RSL.receive { repeat }; |
| 3953 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3954 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3955 | } |
| 3956 | } |
| 3957 | f_rsl_chan_deact(); |
| 3958 | } |
| 3959 | testcase TC_conn_fail_crit() runs on test_CT { |
| 3960 | var ConnHdlr vc_conn; |
| 3961 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3962 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3963 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 3964 | pars.t_guard := 60.0; |
| 3965 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 3966 | vc_conn.done; |
| 3967 | } |
| 3968 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3969 | /*********************************************************************** |
| 3970 | * Paging |
| 3971 | ***********************************************************************/ |
| 3972 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3973 | private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3974 | if (tmsi == 'FFFFFFFF'O) { |
| 3975 | return true; |
| 3976 | } else { |
| 3977 | return false; |
| 3978 | } |
| 3979 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3980 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 3981 | private type record allowedFn { integer frame_nr } |
| 3982 | private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 3983 | private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 3984 | private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 3985 | private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 3986 | private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 3987 | private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 3988 | private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 3989 | private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 3990 | 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] | 3991 | { |
| 3992 | var integer frame_nr_51; |
| 3993 | frame_nr_51 := frame_nr mod 51 |
| 3994 | |
| 3995 | var allowedFn fn_check; |
| 3996 | fn_check.frame_nr := frame_nr_51; |
| 3997 | |
| 3998 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3999 | 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] | 4000 | return; |
| 4001 | } |
| 4002 | |
| 4003 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 4004 | return; |
| 4005 | } |
| 4006 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 4007 | return; |
| 4008 | } |
| 4009 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 4010 | return; |
| 4011 | } |
| 4012 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 4013 | return; |
| 4014 | } |
| 4015 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 4016 | return; |
| 4017 | } |
| 4018 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 4019 | return; |
| 4020 | } |
| 4021 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 4022 | return; |
| 4023 | } |
| 4024 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 4025 | return; |
| 4026 | } |
| 4027 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4028 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4029 | return; |
| 4030 | } |
| 4031 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4032 | private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, |
| 4033 | inout integer num_paging_rcv_ids, |
| 4034 | PagingTestCfg cfg) |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4035 | runs on test_CT { |
| 4036 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4037 | [] 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] | 4038 | repeat; |
| 4039 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4040 | [] 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] | 4041 | var octetstring without_plen := |
| 4042 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 4043 | 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] | 4044 | |
| 4045 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 4046 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 4047 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 4048 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 4049 | * TODO: does it make sense to count them? */ |
| 4050 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4051 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4052 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 4053 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4054 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4055 | } |
| 4056 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 4057 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4058 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 4059 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4060 | } |
| 4061 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 4062 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4063 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 4064 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4065 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4066 | } |
| 4067 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 4068 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 4069 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 4070 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4071 | } |
| 4072 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 4073 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4074 | } |
| 4075 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 4076 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4077 | } |
| 4078 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 4079 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 4080 | } |
| 4081 | } |
| 4082 | repeat; |
| 4083 | } |
| 4084 | } |
| 4085 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4086 | private type record PagingTestCfg { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4087 | boolean combined_ccch, |
| 4088 | integer bs_ag_blks_res, |
| 4089 | float load_factor, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4090 | /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus) |
| 4091 | * paging command that is issued via RSL. */ |
| 4092 | integer ps_load_modulus, |
| 4093 | /* Wait until the paging queue inside the BTS is congested before starting to add |
| 4094 | * pagings via the PCU socket (0 = disabled) */ |
| 4095 | boolean ps_wait_cong, |
| 4096 | /* Maximum time to wait until the paging queue is drained at the end of the test. |
| 4097 | * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended |
| 4098 | * to set this value to 18s, however the draining process may take significantly |
| 4099 | * longer when the queue contains paging requests for PS as those are implemented |
| 4100 | * as immediate assignments and require an entire MAC block alone. */ |
| 4101 | float queue_drain_timeout, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4102 | boolean exp_load_ind, |
| 4103 | boolean exp_overload, |
| 4104 | boolean use_tmsi |
| 4105 | } |
| 4106 | |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4107 | private type record PagingTestState { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4108 | integer num_paging_sent, |
| 4109 | integer num_paging_rcv_msgs, |
| 4110 | integer num_paging_rcv_ids, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4111 | integer num_overload, |
| 4112 | /* When free space inside the paging queue reaches more than 2 thirds |
| 4113 | * of its capacity cong_detected is set to true. */ |
| 4114 | boolean cong_detected |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4115 | } |
| 4116 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4117 | /* Helper function for paging related testing */ |
| 4118 | 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] | 4119 | /* Using the PCU socket affects the timing of the paging processing. We only |
| 4120 | * activate the PCU socket if we do paging load tests that include additional |
| 4121 | * paging load that is introduced through the PCU socket. */ |
| 4122 | if (cfg.ps_load_modulus > 0) { |
| 4123 | f_init_with_pcuif(); |
| 4124 | } else { |
| 4125 | f_init(); |
| 4126 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4127 | f_init_l1ctl(); |
| 4128 | f_l1_tune(L1CTL); |
| 4129 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4130 | var octetstring imm_ass := f_rnd_octstring(23); |
| 4131 | var ASP_RSL_Unitdata load_ind; |
| 4132 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4133 | var PagingTestState st := { |
| 4134 | num_paging_sent := 0, |
| 4135 | num_paging_rcv_msgs := 0, |
| 4136 | num_paging_rcv_ids := 0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4137 | num_overload := 0, |
| 4138 | cong_detected := false |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4139 | }; |
| 4140 | |
| 4141 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 4142 | var float max_pch_imsi_per_sec; |
| 4143 | if (cfg.use_tmsi) { |
| 4144 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 4145 | } else { |
| 4146 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 4147 | } |
| 4148 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 4149 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4150 | var float time_total := 20.0; |
| 4151 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 4152 | 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] | 4153 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4154 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 4155 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4156 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4157 | timer T_itv := 0.0; |
| 4158 | T_itv.start; |
| 4159 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4160 | alt { |
| 4161 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4162 | [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] | 4163 | st.num_overload := st.num_overload + 1; |
| 4164 | repeat; |
| 4165 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4166 | [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] | 4167 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4168 | } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4169 | [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] | 4170 | log("Rx LOAD_IND"); |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4171 | |
| 4172 | /* Detect paging congestion: The logic inside the BTS will diagnose the |
| 4173 | * paging queue as congested when the fill state is more than 66% (which |
| 4174 | * is two thirds fill state, or approx. 66 of 200 paging slots. When a |
| 4175 | * paging congestion is detected pagings that are issued through the PCU |
| 4176 | * socket (PS) are dropped in order to prefer the CS related pagings. */ |
| 4177 | if (load_ind.rsl.ies[1].body.paging_load < 66) { |
| 4178 | st.cong_detected := true; |
| 4179 | } |
| 4180 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4181 | /* FIXME: analyze/verify interval + contents */ |
| 4182 | repeat; |
| 4183 | } |
Vadim Yanitskiy | 2372db6 | 2021-06-09 00:50:11 +0200 | [diff] [blame] | 4184 | /* ignore other RSL messages like RF RESource INDication */ |
| 4185 | [] RSL_CCHAN.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4186 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4187 | [] 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] | 4188 | [] L1CTL.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4189 | /* Only relevant when testing including with PCU sock connected */ |
| 4190 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4191 | [] T_itv.timeout { |
| 4192 | /* Send paging cmds based on elapsed time */ |
| 4193 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 4194 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4195 | var MobileIdentityV mi; |
| 4196 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4197 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4198 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4199 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4200 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4201 | 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] | 4202 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4203 | |
| 4204 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4205 | 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] | 4206 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4207 | /* Add additional pagings through the PCU socket interface. */ |
| 4208 | if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) { |
| 4209 | if (st.cong_detected == true or cfg.ps_wait_cong == false) { |
| 4210 | f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false); |
| 4211 | } |
| 4212 | } |
| 4213 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4214 | st.num_paging_sent := st.num_paging_sent + 1; |
| 4215 | } |
| 4216 | if (st.num_paging_sent < pkt_total) { |
| 4217 | /* Wait for interval to next PAGING COMMAND */ |
| 4218 | var float time_now := T_total.read; |
| 4219 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 4220 | if (next_sched > time_now) { |
| 4221 | T_itv.start(next_sched - time_now); |
| 4222 | } else { |
| 4223 | T_itv.start(0.0); |
| 4224 | } |
| 4225 | } else { |
| 4226 | /* We are done, no need to keep counting */ |
| 4227 | T_total.stop; |
| 4228 | } |
| 4229 | } |
| 4230 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4231 | } |
| 4232 | } |
| 4233 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4234 | timer T_wait := cfg.queue_drain_timeout |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4235 | T_wait.start; |
| 4236 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 4237 | [] 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] | 4238 | [] L1CTL.receive { repeat; } |
| 4239 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4240 | [] 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] | 4241 | [] 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] | 4242 | /* ignore other RSL messages like RF RESource INDication */ |
| 4243 | [] RSL_CCHAN.receive { repeat; } |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4244 | /* Only relevant when testing including with PCU sock connected */ |
| 4245 | [] PCU.receive { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4246 | [] T_wait.timeout { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4247 | 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] | 4248 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 4252 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 4253 | return st; |
| 4254 | } |
| 4255 | |
| 4256 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 4257 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4258 | * - that CCCH LOAD IND (PCH) are being generated |
| 4259 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4260 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4261 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4262 | var PagingTestCfg cfg := { |
| 4263 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4264 | 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] | 4265 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4266 | ps_load_modulus := 0, |
| 4267 | ps_wait_cong := false, |
| 4268 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4269 | exp_load_ind := true, |
| 4270 | exp_overload := false, |
| 4271 | use_tmsi := false |
| 4272 | }; |
| 4273 | var PagingTestState st := f_TC_paging(cfg); |
| 4274 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4275 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4276 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4277 | } else { |
| 4278 | setverdict(pass); |
| 4279 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4280 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4281 | } |
| 4282 | |
| 4283 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 4284 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 4285 | * - that CCCH LOAD IND (PCH) are being generated |
| 4286 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4287 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4288 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4289 | var PagingTestCfg cfg := { |
| 4290 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4291 | 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] | 4292 | load_factor := 0.8, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4293 | ps_load_modulus := 0, |
| 4294 | ps_wait_cong := false, |
| 4295 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4296 | exp_load_ind := true, |
| 4297 | exp_overload := false, |
| 4298 | use_tmsi := true |
| 4299 | }; |
| 4300 | var PagingTestState st := f_TC_paging(cfg); |
| 4301 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4302 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 4303 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4304 | } else { |
| 4305 | setverdict(pass); |
| 4306 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4307 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4308 | } |
| 4309 | |
| 4310 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 4311 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4312 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4313 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4314 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4315 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4316 | var PagingTestCfg cfg := { |
| 4317 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4318 | 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] | 4319 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4320 | ps_load_modulus := 0, |
| 4321 | ps_wait_cong := false, |
| 4322 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4323 | exp_load_ind := true, |
| 4324 | exp_overload := true, |
| 4325 | use_tmsi := false |
| 4326 | }; |
| 4327 | var PagingTestState st := f_TC_paging(cfg); |
| 4328 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4329 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4330 | 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] | 4331 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4332 | 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] | 4333 | } else { |
| 4334 | setverdict(pass); |
| 4335 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4336 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4337 | } |
| 4338 | |
| 4339 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 4340 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 4341 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 4342 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 4343 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4344 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4345 | var PagingTestCfg cfg := { |
| 4346 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 4347 | 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] | 4348 | load_factor := 2.0, |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4349 | ps_load_modulus := 0, |
| 4350 | ps_wait_cong := false, |
| 4351 | queue_drain_timeout := 18.0, |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4352 | exp_load_ind := true, |
| 4353 | exp_overload := true, |
| 4354 | use_tmsi := true |
| 4355 | }; |
| 4356 | var PagingTestState st := f_TC_paging(cfg); |
| 4357 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 4358 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 4359 | 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] | 4360 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4361 | 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] | 4362 | } else { |
| 4363 | setverdict(pass); |
| 4364 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4365 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4366 | } |
| 4367 | |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 4368 | /* Same as above, but with additional paging load created by PS pagings that |
| 4369 | * are issued through the PCU socket. The additional load is introduced when |
| 4370 | * the paging queue is already two thirds full. Since the BTS implements a |
| 4371 | * prioritization logic that drops the pagings from the PCU under in those |
| 4372 | * congestive sitautions the behaviour on the PS side is expected to be |
| 4373 | * unaffected and match the behavior of TC_paging_imsi_200percent() */ |
| 4374 | testcase TC_paging_imsi_200percent_with_ps() runs on test_CT { |
| 4375 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 4376 | var PagingTestCfg cfg := { |
| 4377 | combined_ccch := true, |
| 4378 | bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res, |
| 4379 | load_factor := 2.0, |
| 4380 | ps_load_modulus := 16, |
| 4381 | ps_wait_cong := true, |
| 4382 | queue_drain_timeout := 18.0, |
| 4383 | exp_load_ind := true, |
| 4384 | exp_overload := true, |
| 4385 | use_tmsi := false |
| 4386 | }; |
| 4387 | var PagingTestState st := f_TC_paging(cfg); |
| 4388 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 4389 | * slots and will fully drain that buffer before returning */ |
| 4390 | var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100); |
| 4391 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 4392 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids)); |
| 4393 | } else { |
| 4394 | setverdict(pass); |
| 4395 | } |
| 4396 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4397 | } |
| 4398 | |
| 4399 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4400 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4401 | /*********************************************************************** |
| 4402 | * Immediate Assignment / AGCH |
| 4403 | ***********************************************************************/ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 4404 | private const MobileAllocationLV c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4405 | len := 0, |
| 4406 | ma := ''B |
| 4407 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4408 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4409 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 4410 | return int2str(num_tx) & " sent, " |
| 4411 | & int2str(num_rx) & " received, " |
| 4412 | & int2str(num_del) & " deleted"; |
| 4413 | } |
| 4414 | |
| 4415 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 4416 | var L1ctlDlMessage l1_dl; |
| 4417 | timer T := 10.0; |
| 4418 | var integer num_tx := 0; |
| 4419 | var integer num_rx := 0; |
| 4420 | var integer num_del := 0; |
| 4421 | var charstring res_str; |
| 4422 | var float rx_ratio; |
| 4423 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4424 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4425 | f_init_l1ctl(); |
| 4426 | f_l1_tune(L1CTL); |
| 4427 | |
| 4428 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 42d8bd5 | 2020-11-15 20:41:02 +0700 | [diff] [blame] | 4429 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0), |
Vadim Yanitskiy | 3191d73 | 2020-11-15 20:45:01 +0700 | [diff] [blame] | 4430 | mp_trx_pars[0].arfcn, |
| 4431 | mp_tsc_def)); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4432 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 4433 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4434 | 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] | 4435 | num_tx := num_tx+1; |
| 4436 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4437 | } |
| 4438 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4439 | T.start; |
| 4440 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4441 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4442 | num_del := num_del+1; |
| 4443 | repeat; |
| 4444 | } |
| 4445 | [] RSL_CCHAN.receive { |
| 4446 | repeat; |
| 4447 | } |
| 4448 | [] 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] | 4449 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 4450 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 4451 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4452 | //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] | 4453 | } else { |
| 4454 | num_rx := num_rx+1; |
| 4455 | } |
| 4456 | repeat; |
| 4457 | } |
| 4458 | [] L1CTL.receive { repeat; } |
| 4459 | [] T.timeout { } |
| 4460 | } |
| 4461 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 4462 | log("AGCH test: " & res_str); |
| 4463 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4464 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4465 | } |
| 4466 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 4467 | 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] | 4468 | 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] | 4469 | } else { |
| 4470 | setverdict(pass); |
| 4471 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4472 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4473 | } |
| 4474 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 4475 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 4476 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 4477 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 4478 | } |
| 4479 | |
| 4480 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 4481 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 4482 | f_TC_imm_ass(200, 0.0, 0.05); |
| 4483 | } |
| 4484 | |
| 4485 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 4486 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 4487 | f_TC_imm_ass(150, 0.076, 1.00); |
| 4488 | } |
| 4489 | |
| 4490 | |
| 4491 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4492 | /*********************************************************************** |
| 4493 | * BCCH |
| 4494 | ***********************************************************************/ |
| 4495 | |
| 4496 | /* tuple of Frame Number + decoded SI */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4497 | private type record SystemInformationFn { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4498 | GsmFrameNumber frame_number, |
| 4499 | SystemInformation si |
| 4500 | } |
| 4501 | |
| 4502 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4503 | private type record of SystemInformationFn SystemInformationVector; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4504 | |
| 4505 | /* an array of SI-vectors indexed by TC value */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4506 | private type SystemInformationVector SystemInformationVectorPerTc[8]; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4507 | |
| 4508 | /* 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] | 4509 | private function f_si_vecslot_contains(SystemInformationVector arr, |
| 4510 | RrMessageType key, |
| 4511 | boolean bcch_ext := false) |
| 4512 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4513 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4514 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4515 | if (not bcch_ext and fn_mod51 == 2 or |
| 4516 | bcch_ext and fn_mod51 == 6) { |
| 4517 | if (arr[i].si.header.message_type == key) { |
| 4518 | return true; |
| 4519 | } |
| 4520 | } |
| 4521 | } |
| 4522 | return false; |
| 4523 | } |
| 4524 | |
| 4525 | /* 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] | 4526 | private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4527 | integer tc, RrMessageType key, |
| 4528 | boolean ext_bcch := false) |
| 4529 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4530 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4531 | 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] | 4532 | } |
| 4533 | } |
| 4534 | |
| 4535 | /* 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] | 4536 | private function f_si_vec_contains(SystemInformationVectorPerTc arr, |
| 4537 | RrMessageType key) |
| 4538 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4539 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 4540 | if (f_si_vecslot_contains(arr[tc], key) or |
| 4541 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 4542 | return true; |
| 4543 | } |
| 4544 | } |
| 4545 | return false; |
| 4546 | } |
| 4547 | |
| 4548 | /* 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] | 4549 | private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, |
| 4550 | RrMessageType key, |
| 4551 | boolean bcch_ext := false, |
| 4552 | integer n := 1, integer m := 4) |
| 4553 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4554 | var integer count := 0; |
| 4555 | if (sizeof(arr) < m) { |
Harald Welte | a616ec9 | 2020-10-11 21:28:00 +0200 | [diff] [blame] | 4556 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: " |
| 4557 | & int2str(sizeof(arr)) & " < " & int2str(m)); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4558 | } |
| 4559 | for (var integer i:= 0; i < m; i := i + 1) { |
| 4560 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4561 | if (not bcch_ext and fn_mod51 == 2 or |
| 4562 | bcch_ext and fn_mod51 == 6) { |
| 4563 | if (arr[i].si.header.message_type == key) { |
| 4564 | count := count + 1; |
| 4565 | } |
| 4566 | } |
| 4567 | } |
| 4568 | if (count >= n) { |
| 4569 | return true; |
| 4570 | } else { |
| 4571 | return false; |
| 4572 | } |
| 4573 | } |
| 4574 | |
| 4575 | /* 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] | 4576 | private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, |
| 4577 | integer tc, RrMessageType key, |
| 4578 | boolean ext_bcch := false, |
| 4579 | integer n, integer m) |
| 4580 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4581 | 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] | 4582 | 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] | 4583 | } |
| 4584 | } |
| 4585 | |
| 4586 | /* 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] | 4587 | private function f_si_vecslot_contains_only(SystemInformationVector arr, |
| 4588 | RrMessageType key, |
| 4589 | boolean bcch_ext := false) |
| 4590 | return boolean { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4591 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 4592 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 4593 | if (not bcch_ext and fn_mod51 == 2 or |
| 4594 | bcch_ext and fn_mod51 == 6) { |
| 4595 | if (arr[i].si.header.message_type != key) { |
| 4596 | return false; |
| 4597 | } |
| 4598 | } |
| 4599 | } |
| 4600 | return true; |
| 4601 | } |
| 4602 | |
| 4603 | /* 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] | 4604 | private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, |
| 4605 | integer tc, RrMessageType key, |
| 4606 | boolean ext_bcch := false) |
| 4607 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4608 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4609 | 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] | 4610 | } |
| 4611 | } |
| 4612 | |
| 4613 | /* SI configuration of cell, against which we validate actual SI messages */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4614 | private type set SystemInformationConfig { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4615 | boolean bcch_extended, |
| 4616 | boolean si1_present, |
| 4617 | boolean si2bis_present, |
| 4618 | boolean si2ter_present, |
| 4619 | boolean si2quater_present, |
| 4620 | boolean si7_present, |
| 4621 | boolean si8_present, |
| 4622 | boolean si9_present, |
| 4623 | boolean si13_present, |
| 4624 | boolean si13alt_present, |
| 4625 | boolean si15_present, |
| 4626 | boolean si16_present, |
| 4627 | boolean si17_present, |
| 4628 | boolean si2n_present, |
| 4629 | boolean si21_present, |
| 4630 | boolean si22_present |
| 4631 | } |
| 4632 | |
| 4633 | /* 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] | 4634 | private function f_validate_si_scheduling(SystemInformationConfig cfg, |
| 4635 | SystemInformationVectorPerTc si_per_tc) |
| 4636 | { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4637 | var integer i; |
| 4638 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 4639 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4640 | 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] | 4641 | } |
| 4642 | } |
| 4643 | if (cfg.si1_present) { |
| 4644 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 4645 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 4646 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 4647 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4648 | /* make sure *ALL* contain SI1 */ |
| 4649 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 4650 | } |
| 4651 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 4652 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 4653 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 4654 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 4655 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 4656 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 4657 | |
| 4658 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 4659 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 4660 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 4661 | * consecutive occurrences of TC = 4. */ |
| 4662 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 4663 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4664 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 4665 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 4666 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 4667 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 4668 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 4669 | } |
| 4670 | |
| 4671 | if (cfg.si7_present or cfg.si8_present) { |
| 4672 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 4673 | * if System Information type 4 does not contain all information needed for cell |
| 4674 | * selection and reselection. */ |
| 4675 | if (not cfg.bcch_extended) { |
| 4676 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 4677 | } |
| 4678 | if (cfg.si7_present) { |
| 4679 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 4680 | } |
| 4681 | if (cfg.si8_present) { |
| 4682 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 4683 | } |
| 4684 | } |
| 4685 | |
| 4686 | if (cfg.si2quater_present) { |
| 4687 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 4688 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 4689 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 4690 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 4691 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 4692 | if (not (cfg.bcch_extended)) { |
| 4693 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 4694 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 4695 | } else { |
| 4696 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 4697 | } |
| 4698 | } else { |
| 4699 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 4700 | } |
| 4701 | } |
| 4702 | if (cfg.si9_present) { |
| 4703 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 4704 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 4705 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 4706 | } |
| 4707 | if (cfg.si13_present) { |
| 4708 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 4709 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 4710 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 4711 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 4712 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 4713 | * within any of 4 consecutive occurrences of TC=4. */ |
| 4714 | if (not cfg.bcch_extended) { |
| 4715 | log("not-bccch-extended"); |
| 4716 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 4717 | } else { |
| 4718 | log("bccch-extended"); |
| 4719 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 4720 | } |
| 4721 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4722 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4723 | } |
| 4724 | } |
| 4725 | if (cfg.si16_present or cfg.si17_present) { |
| 4726 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 4727 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 4728 | if (cfg.si22_present) { |
| 4729 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4730 | } |
| 4731 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4732 | 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] | 4733 | } |
| 4734 | if (not cfg.bcch_extended) { |
| 4735 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 4736 | } |
| 4737 | if (cfg.si16_present) { |
| 4738 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 4739 | } |
| 4740 | if (cfg.si17_present) { |
| 4741 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 4742 | } |
| 4743 | } |
| 4744 | |
| 4745 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 4746 | * broadcast information. The frequency with which they are sent is determined by the |
| 4747 | * system operator. System Information type 9 identifies the scheduling of System |
| 4748 | * Information type 18 and 20 messages. */ |
| 4749 | |
| 4750 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 4751 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 4752 | * Information Type 9. */ |
| 4753 | |
| 4754 | if (cfg.si15_present) { |
| 4755 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 4756 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 4757 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 4758 | * 4 consecutive occurrences of TC = 1. */ |
| 4759 | if (not cfg.bcch_extended) { |
| 4760 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 4761 | } else { |
| 4762 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 4763 | } |
| 4764 | } |
| 4765 | if (cfg.si13alt_present) { |
| 4766 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 4767 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 4768 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 4769 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 4770 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 4771 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 4772 | * of TC = 4. */ |
| 4773 | if (cfg.si13_present) { |
| 4774 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 4775 | } |
| 4776 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4777 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4778 | } |
| 4779 | if (not cfg.bcch_extended) { |
| 4780 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 4781 | } else { |
| 4782 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 4783 | } |
| 4784 | } |
| 4785 | if (cfg.si2n_present) { |
| 4786 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 4787 | * as determined by the system operator. In the case that the message is sent on the |
| 4788 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 4789 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 4790 | * consecutive occurrences of TC = 4. */ |
| 4791 | if (not cfg.bcch_extended) { |
| 4792 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 4793 | } else { |
| 4794 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 4795 | } |
| 4796 | } |
| 4797 | if (cfg.si21_present) { |
| 4798 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 4799 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 4800 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 4801 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 4802 | * cell then this message shall only be sent on BCCH Ext. */ |
| 4803 | if (not cfg.bcch_extended) { |
| 4804 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 4805 | } else { |
| 4806 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 4807 | 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] | 4808 | 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] | 4809 | } |
| 4810 | } |
| 4811 | } |
| 4812 | if (cfg.si22_present) { |
| 4813 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 4814 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 4815 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 4816 | * =2 and TC=6. */ |
| 4817 | if (cfg.si16_present or cfg.si17_present) { |
| 4818 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 4819 | } |
| 4820 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 4821 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4822 | 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] | 4823 | } |
| 4824 | if (not cfg.bcch_extended) { |
| 4825 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 4826 | } else { |
| 4827 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 4828 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 4829 | } |
| 4830 | } |
| 4831 | } |
| 4832 | |
| 4833 | /* sample Systme Information for specified duration via L1CTL */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 4834 | private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) |
| 4835 | return SystemInformationVectorPerTc { |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4836 | timer T := duration; |
| 4837 | var SystemInformationVectorPerTc si_per_tc; |
| 4838 | var L1ctlDlMessage l1_dl; |
| 4839 | |
| 4840 | /* initialize all per-TC vectors empty */ |
| 4841 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4842 | si_per_tc[i] := {}; |
| 4843 | } |
| 4844 | |
| 4845 | /* flush all previous L1 queued msgs */ |
| 4846 | pt.clear; |
| 4847 | |
| 4848 | T.start; |
| 4849 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4850 | [] 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] | 4851 | var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr }; |
| 4852 | if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) { |
| 4853 | log("Ignoring non-RR or invalid SI ", l1_dl); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4854 | repeat; |
| 4855 | } |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 4856 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4857 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 4858 | log("SI received at TC=", tc, ": ", sig.si); |
| 4859 | /* append to the per-TC bucket */ |
| 4860 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 4861 | repeat; |
| 4862 | } |
| 4863 | [] pt.receive { repeat; } |
| 4864 | [] T.timeout { } |
| 4865 | } |
| 4866 | |
| 4867 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 4868 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 4869 | } |
| 4870 | log("si_per_tc=", si_per_tc); |
| 4871 | return si_per_tc; |
| 4872 | } |
| 4873 | |
| 4874 | /* helper function: Set given SI via RSL + validate scheduling. |
| 4875 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4876 | 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] | 4877 | var SystemInformationVectorPerTc si_per_tc; |
| 4878 | f_init_l1ctl(); |
| 4879 | f_l1_tune(L1CTL); |
| 4880 | |
| 4881 | /* Sample + Validate Scheduling */ |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4882 | si_per_tc := f_l1_sample_si(L1CTL, duration); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4883 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 4884 | |
| 4885 | setverdict(pass); |
| 4886 | } |
| 4887 | |
| 4888 | testcase TC_si_sched_default() runs on test_CT { |
| 4889 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4890 | /* 2+3+4 are mandatory and set in f_init() */ |
| 4891 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4892 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 4893 | } |
| 4894 | |
| 4895 | testcase TC_si_sched_1() runs on test_CT { |
| 4896 | f_init(); |
| 4897 | si_cfg.si1_present := true; |
| 4898 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4899 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4900 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4901 | } |
| 4902 | |
| 4903 | testcase TC_si_sched_2bis() runs on test_CT { |
| 4904 | f_init(); |
| 4905 | si_cfg.si2bis_present := true; |
| 4906 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4907 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4908 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4909 | } |
| 4910 | |
| 4911 | testcase TC_si_sched_2ter() runs on test_CT { |
| 4912 | f_init(); |
| 4913 | si_cfg.si2ter_present := true; |
| 4914 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4915 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4916 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4917 | } |
| 4918 | |
| 4919 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 4920 | f_init(); |
| 4921 | si_cfg.si2bis_present := true; |
| 4922 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4923 | si_cfg.si2ter_present := true; |
| 4924 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4925 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4926 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4927 | } |
| 4928 | |
| 4929 | testcase TC_si_sched_2quater() runs on test_CT { |
| 4930 | f_init(); |
| 4931 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4932 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4933 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4934 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4935 | } |
| 4936 | |
| 4937 | testcase TC_si_sched_13() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4938 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4939 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4940 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4941 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4942 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4943 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4944 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4945 | } |
| 4946 | |
| 4947 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 4948 | /* NOTE: PCUIF connection is not used in this test case, but |
| 4949 | * without it the IUT would not broadcast SI13 (see OS#3075). */ |
| 4950 | f_init_with_pcuif(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4951 | si_cfg.si2bis_present := true; |
| 4952 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 4953 | si_cfg.si2ter_present := true; |
| 4954 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 4955 | si_cfg.si2quater_present := true; |
Vadim Yanitskiy | 3bb3b60 | 2020-10-24 21:24:05 +0700 | [diff] [blame] | 4956 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4957 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 4958 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 9b965d5 | 2020-10-11 21:28:22 +0200 | [diff] [blame] | 4959 | f_TC_si_sched(16.0); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4960 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 4961 | } |
| 4962 | |
| 4963 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4964 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4965 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4966 | /* FIXME: enable / disable individual BCCH info */ |
| 4967 | //ts_RSL_BCCH_INFO(si_type, info); |
| 4968 | /* expect no ERROR REPORT after either of them * |
| 4969 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4970 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 4971 | } |
| 4972 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 4973 | /*********************************************************************** |
| 4974 | * Low-Level Protocol Errors / ERROR REPORT |
| 4975 | ***********************************************************************/ |
| 4976 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4977 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 4978 | timer T := 5.0; |
| 4979 | T.start; |
| 4980 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4981 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4982 | setverdict(pass); |
| 4983 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4984 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4985 | 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] | 4986 | } |
| 4987 | [] RSL_CCHAN.receive { |
| 4988 | repeat; |
| 4989 | } |
| 4990 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4991 | 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] | 4992 | } |
| 4993 | } |
| 4994 | } |
| 4995 | |
| 4996 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 4997 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4998 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 4999 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5000 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5001 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5002 | |
| 5003 | f_exp_err_rep(RSL_ERR_PROTO); |
| 5004 | } |
| 5005 | |
| 5006 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 5007 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5008 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5009 | |
| 5010 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5011 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5012 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5013 | |
| 5014 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 5015 | } |
| 5016 | |
| 5017 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 5018 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5019 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5020 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5021 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5022 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 5023 | |
| 5024 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 5025 | } |
| 5026 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5027 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 5028 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 5029 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 5030 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 5031 | RSL.send(rsl); |
| 5032 | f_rslem_unregister(0, g_chan_nr); |
| 5033 | } |
| 5034 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 5035 | var ConnHdlr vc_conn; |
| 5036 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5037 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5038 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5039 | |
| 5040 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 5041 | vc_conn.done; |
| 5042 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 5043 | |
| 5044 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5045 | } |
| 5046 | |
| 5047 | /* Send messages with wrong message type */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5048 | 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] | 5049 | var template (value) RSL_Message rsl_tx; |
| 5050 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 5051 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 5052 | RSL.send(rsl_tx); |
| 5053 | f_rslem_unregister(0, g_chan_nr); |
| 5054 | } |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5055 | 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] | 5056 | var template (value) RSL_Message rsl_tx; |
| 5057 | /* we first have to activate the dedicated channel */ |
| 5058 | f_rsl_chan_act(g_pars.chan_mode); |
| 5059 | /* ... to then send an invalid RLL message */ |
| 5060 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 5061 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 5062 | RSL.send(rsl_tx); |
| 5063 | f_rslem_unregister(0, g_chan_nr); |
| 5064 | } |
| 5065 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 5066 | var ConnHdlr vc_conn; |
| 5067 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5068 | var template (value) RSL_Message rsl_tx; |
| 5069 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5070 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5071 | |
| 5072 | /* Common Channel with wrong message type */ |
| 5073 | RSL_CCHAN.clear; |
| 5074 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 5075 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5076 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5077 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5078 | |
| 5079 | /* TRX Management */ |
| 5080 | RSL_CCHAN.clear; |
| 5081 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 5082 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5083 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5084 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5085 | |
| 5086 | /* Dedicated Channel */ |
| 5087 | RSL_CCHAN.clear; |
| 5088 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 5089 | vc_conn.done; |
| 5090 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5091 | |
| 5092 | /* RLL */ |
| 5093 | RSL_CCHAN.clear; |
| 5094 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 5095 | vc_conn.done; |
| 5096 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 5097 | } |
| 5098 | |
| 5099 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5100 | 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] | 5101 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 5102 | f_rslem_unregister(0, g_chan_nr); |
| 5103 | } |
| 5104 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 5105 | var ConnHdlr vc_conn; |
| 5106 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 5107 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5108 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 5109 | |
| 5110 | RSL_CCHAN.clear; |
| 5111 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 5112 | vc_conn.done; |
| 5113 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 5114 | } |
| 5115 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 5116 | /*********************************************************************** |
| 5117 | * IPA CRCX/MDCX/DLCS media stream handling |
| 5118 | ***********************************************************************/ |
| 5119 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5120 | /* Send IPA DLCX to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5121 | 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] | 5122 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5123 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5124 | } |
| 5125 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 5126 | 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] | 5127 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 5128 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 5129 | vc_conn.done; |
| 5130 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 5131 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5132 | /* Send IPA CRCX twice to inactive lchan */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5133 | 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] | 5134 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5135 | "IPA CRCX ACK"); |
| 5136 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 5137 | "IPA CRCX NACK"); |
| 5138 | } |
| 5139 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 5140 | 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] | 5141 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5142 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 5143 | vc_conn.done; |
| 5144 | } |
| 5145 | |
| 5146 | /* Regular sequence of CRCX/MDCX/DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5147 | 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] | 5148 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5149 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5150 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5151 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5152 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5153 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5154 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5155 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5156 | "IPA MDCX ACK"); |
| 5157 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5158 | "IPA DLCX ACK"); |
| 5159 | } |
| 5160 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5161 | 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] | 5162 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5163 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 5164 | vc_conn.done; |
| 5165 | } |
| 5166 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5167 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5168 | 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] | 5169 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5170 | "IPA CRCX ACK"); |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5171 | var OCT4 remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5172 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 5173 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 5174 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 5175 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5176 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5177 | "IPA MDCX ACK"); |
| 5178 | /* Second MDCX */ |
Vadim Yanitskiy | fc63164 | 2021-07-03 02:42:45 +0200 | [diff] [blame] | 5179 | remote_ip := f_rnd_octstring(4); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5180 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 5181 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 5182 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 5183 | "IPA MDCX ACK"); |
| 5184 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5185 | "IPA DLCX ACK"); |
| 5186 | } |
| 5187 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 5188 | 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] | 5189 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 5190 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 5191 | vc_conn.done; |
| 5192 | } |
| 5193 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5194 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 5195 | 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] | 5196 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 5197 | "IPA CRCX NACK"); |
| 5198 | } |
| 5199 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 5200 | var ConnHdlrPars pars; |
| 5201 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5202 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 5203 | |
| 5204 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 5205 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5206 | vc_conn.done; |
| 5207 | |
| 5208 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 5209 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 5210 | vc_conn.done; |
| 5211 | } |
| 5212 | |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 5213 | /* Make sure that CRCX ACK contains a valid listen address (see OS#5242) */ |
| 5214 | private function f_TC_ipa_crcx_ack_addr(charstring id) runs on ConnHdlr { |
| 5215 | var OCT4 bind_ip := f_inet_addr("192.168.1.1"); |
| 5216 | var PortNumber bind_port := 16811; |
| 5217 | var RSL_Message crcx_ack; |
| 5218 | |
| 5219 | crcx_ack := f_rsl_transceive_ret(ts_RSL_IPA_CRCX(g_chan_nr, bind_ip, bind_port), |
| 5220 | tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 5221 | "IPA CRCX ACK"); |
| 5222 | var HostName bts_bind_ip := f_inet_ntoa(crcx_ack.ies[2].body.ipa_local_ip); |
| 5223 | if (match(bts_bind_ip, "0.0.0.0")) { |
| 5224 | setverdict(fail, "CRCX ACK indicates nonsense addr ", bts_bind_ip); |
| 5225 | } |
| 5226 | |
| 5227 | var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id; |
| 5228 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, conn_id), |
| 5229 | tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 5230 | "IPA DLCX ACK"); |
| 5231 | } |
| 5232 | testcase TC_ipa_crcx_ack_addr() runs on test_CT { |
| 5233 | var ConnHdlrPars pars; |
| 5234 | var ConnHdlr vc_conn; |
| 5235 | f_init(); |
| 5236 | |
| 5237 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 5238 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5239 | vc_conn.done; |
| 5240 | |
| 5241 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 5242 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars); |
| 5243 | vc_conn.done; |
| 5244 | } |
| 5245 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 5246 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5247 | /*********************************************************************** |
| 5248 | * PCU Socket related tests |
| 5249 | ***********************************************************************/ |
| 5250 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5251 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5252 | 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] | 5253 | runs on test_CT { |
| 5254 | timer T := 3.0; |
| 5255 | |
| 5256 | /* we don't expect any RTS.req before PDCH are active */ |
| 5257 | T.start; |
| 5258 | alt { |
| 5259 | [] 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] | 5260 | 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] | 5261 | } |
| 5262 | [] PCU.receive { repeat; } |
| 5263 | [] T.timeout { } |
| 5264 | } |
| 5265 | |
| 5266 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5267 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 5268 | |
| 5269 | /* we now expect RTS.req for this timeslot (only) */ |
| 5270 | T.start; |
| 5271 | alt { |
| 5272 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 5273 | setverdict(pass); |
| 5274 | } |
| 5275 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5276 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5277 | 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] | 5278 | } |
| 5279 | [] 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] | 5280 | 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] | 5281 | } |
| 5282 | [] PCU.receive { repeat; } |
| 5283 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5284 | 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] | 5285 | } |
| 5286 | [not exp_success] T.timeout { |
| 5287 | setverdict(pass); |
| 5288 | } |
| 5289 | } |
| 5290 | } |
| 5291 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 5292 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5293 | 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] | 5294 | runs on test_CT { |
| 5295 | timer T := 3.0; |
| 5296 | |
| 5297 | /* Send PDCH activate request for known PDCH timeslot */ |
| 5298 | 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] | 5299 | /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know |
| 5300 | * when it will actually have been executed in the BTS */ |
| 5301 | f_sleep(1.0); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5302 | PCU.clear; |
| 5303 | /* we now expect no RTS.req for this timeslot */ |
| 5304 | T.start; |
| 5305 | alt { |
| 5306 | [] 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] | 5307 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5308 | } |
| 5309 | [] PCU.receive { repeat; } |
| 5310 | [] T.timeout { |
| 5311 | setverdict(pass); |
| 5312 | } |
| 5313 | } |
| 5314 | } |
| 5315 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5316 | friend function f_init_with_pcuif() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5317 | f_init(); |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 5318 | map(self:PCU, system:PCU); |
| 5319 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5320 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 5321 | } |
| 5322 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5323 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 5324 | testcase TC_pcu_act_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5325 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5326 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5327 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5328 | } |
| 5329 | |
| 5330 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 5331 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5332 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5333 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5334 | f_TC_pcu_act_req(0, 0, 1, false); |
| 5335 | } |
| 5336 | |
| 5337 | /* PDCH activation via PCU socket on wrong BTS */ |
| 5338 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5339 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5340 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5341 | f_TC_pcu_act_req(23, 0, 7, false); |
| 5342 | } |
| 5343 | |
| 5344 | /* PDCH activation via PCU socket on wrong TRX */ |
| 5345 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5346 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5347 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5348 | f_TC_pcu_act_req(0, 23, 7, false); |
| 5349 | } |
| 5350 | |
| 5351 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 5352 | testcase TC_pcu_deact_req() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5353 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5354 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5355 | /* Activate PDCH */ |
| 5356 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5357 | f_sleep(1.0); |
| 5358 | /* and De-Activate again */ |
| 5359 | f_TC_pcu_deact_req(0, 0, 7); |
| 5360 | } |
| 5361 | |
| 5362 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 5363 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5364 | f_init_with_pcuif(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5365 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5366 | f_TC_pcu_deact_req(0, 0, 1); |
| 5367 | } |
| 5368 | |
| 5369 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5370 | 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] | 5371 | var PCUIF_send_data sd; |
| 5372 | timer T:= 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5373 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5374 | |
| 5375 | /* Set SI13 via RSL */ |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5376 | f_rsl_bcch_fill_raw(rsl_si_type, si); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5377 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5378 | T.start; |
| 5379 | alt { |
| 5380 | [] 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] | 5381 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5382 | setverdict(pass); |
| 5383 | } else { |
| 5384 | repeat; |
| 5385 | } |
| 5386 | } |
| 5387 | [] PCU.receive { repeat; } |
| 5388 | [] T.timeout { |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5389 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5390 | } |
| 5391 | } |
| 5392 | } |
| 5393 | |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 5394 | /* Test the PCU->BTS Version and BTS->PCU SI1 handshake */ |
| 5395 | testcase TC_pcu_ver_si1() runs on test_CT { |
| 5396 | const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O; |
| 5397 | f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1); |
| 5398 | } |
| 5399 | |
| 5400 | /* Test the PCU->BTS Version and BTS->PCU SI3 handshake */ |
| 5401 | testcase TC_pcu_ver_si3() runs on test_CT { |
| 5402 | const octetstring si3 := '49012223242526272929AABBCC'O; |
| 5403 | f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3); |
| 5404 | } |
| 5405 | |
| 5406 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 5407 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 5408 | const octetstring si13 := '01010203040506070909'O; |
| 5409 | f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13); |
| 5410 | } |
| 5411 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5412 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 5413 | |
| 5414 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5415 | 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] | 5416 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 5417 | runs on test_CT |
| 5418 | { |
| 5419 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 5420 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 5421 | } |
| 5422 | |
| 5423 | /* 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] | 5424 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 5425 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5426 | runs on test_CT |
| 5427 | { |
| 5428 | var PCUIF_send_data sd; |
| 5429 | |
| 5430 | timer T := 3.0; |
| 5431 | T.start; |
| 5432 | alt { |
| 5433 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 5434 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 5435 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 5436 | sd.data.u.rts_req.fn, sapi, data); |
| 5437 | } |
| 5438 | [] PCU.receive { repeat; } |
| 5439 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5440 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5441 | } |
| 5442 | } |
| 5443 | } |
| 5444 | |
| 5445 | /* Send DATA.req on invalid BTS */ |
| 5446 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5447 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5448 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5449 | |
| 5450 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5451 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5452 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5453 | f_TfiUsfArrSet(tua, 7, 0); |
| 5454 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5455 | f_sleep(1.0); |
| 5456 | |
| 5457 | 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] | 5458 | } |
| 5459 | |
| 5460 | /* Send DATA.req on invalid TRX */ |
| 5461 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5462 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5463 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5464 | |
| 5465 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5466 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5467 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5468 | f_TfiUsfArrSet(tua, 7, 0); |
| 5469 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5470 | f_sleep(1.0); |
| 5471 | |
| 5472 | 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] | 5473 | } |
| 5474 | |
| 5475 | /* Send DATA.req on invalid timeslot */ |
| 5476 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5477 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5478 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5479 | |
| 5480 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5481 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5482 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5483 | f_TfiUsfArrSet(tua, 7, 0); |
| 5484 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5485 | f_sleep(1.0); |
| 5486 | |
| 5487 | 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] | 5488 | } |
| 5489 | |
| 5490 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 5491 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5492 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5493 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5494 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5495 | f_virtphy_common(); |
| 5496 | |
| 5497 | f_TfiUsfArrSet(tua, 7, 0); |
| 5498 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5499 | f_sleep(1.0); |
| 5500 | |
| 5501 | 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] | 5502 | } |
| 5503 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5504 | 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] | 5505 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 5506 | boolean wait_rts := true) |
| 5507 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5508 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5509 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5510 | |
| 5511 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5512 | if (wait_rts) { |
| 5513 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 5514 | } else { |
| 5515 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 5516 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5517 | |
| 5518 | T.start; |
| 5519 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5520 | [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] | 5521 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 5522 | setverdict(pass); |
| 5523 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5524 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 5525 | setverdict(fail, "Received unexpected ", rx_dl); |
| 5526 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5527 | [] L1CTL.receive { |
| 5528 | repeat; |
| 5529 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5530 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5531 | setverdict(fail, "Timeout waiting for ", data); |
| 5532 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 5533 | [not expect_data] T.timeout { |
| 5534 | setverdict(pass); |
| 5535 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5536 | } |
| 5537 | } |
| 5538 | |
| 5539 | private function f_disable_dynamic_ts() runs on test_CT |
| 5540 | { |
| 5541 | f_init_vty_bsc(); |
| 5542 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 5543 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 5544 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 5545 | 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] | 5546 | f_init_with_pcuif(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5547 | } |
| 5548 | |
| 5549 | private function f_virtphy_common() runs on test_CT { |
| 5550 | f_disable_dynamic_ts(); |
| 5551 | f_init_l1ctl(); |
| 5552 | f_l1_tune(L1CTL); |
| 5553 | } |
| 5554 | |
| 5555 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 5556 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5557 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5558 | |
| 5559 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5560 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5561 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5562 | f_TfiUsfArrSet(tua, 7, 0); |
| 5563 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5564 | f_sleep(1.0); |
| 5565 | |
| 5566 | 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] | 5567 | } |
| 5568 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5569 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5570 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5571 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 5572 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 5573 | |
| 5574 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 5575 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5576 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 5577 | f_TfiUsfArrSet(tua, 7, 0); |
| 5578 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 5579 | f_sleep(1.0); |
| 5580 | |
| 5581 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5582 | } |
| 5583 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5584 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 5585 | runs on test_CT { |
| 5586 | var template PCUIF_Message pcu_rach_ind; |
| 5587 | var PCUIF_send_data sd; |
| 5588 | var GsmFrameNumber fn; |
| 5589 | timer T; |
| 5590 | |
| 5591 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 5592 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 5593 | chan_nr := ts_RslChanNr_PDCH(7), |
| 5594 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 5595 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5596 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 5597 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5598 | |
| 5599 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 5600 | T.start(52.0 * 4.615 / 1000.0); |
| 5601 | alt { |
| 5602 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 5603 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 5604 | setverdict(pass); |
| 5605 | T.stop; |
| 5606 | } |
| 5607 | [] PCU.receive { repeat; } |
| 5608 | [] T.timeout { |
| 5609 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 5610 | /* Keep going, that's not the end of the world */ |
| 5611 | } |
| 5612 | } |
| 5613 | } |
| 5614 | |
| 5615 | testcase TC_pcu_ptcch() runs on test_CT { |
| 5616 | var L1ctlDlMessage dl; |
| 5617 | var octetstring data; |
| 5618 | timer T; |
| 5619 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5620 | f_init_with_pcuif(); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5621 | f_init_l1ctl(); |
| 5622 | f_l1_tune(L1CTL); |
| 5623 | |
| 5624 | /* Activate PDCH channel on TS7 */ |
| 5625 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5626 | |
| 5627 | /* Tune trxcon to that PDCH channel */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5628 | 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] | 5629 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5630 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5631 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 5632 | |
| 5633 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 5634 | for (var integer i := 0; i < 16; i := i + 1) { |
| 5635 | log("Sending an Access Burst towards the L1CTL interface"); |
| 5636 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 5637 | } |
| 5638 | |
| 5639 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 5640 | data := f_rnd_octstring(23); |
| 5641 | |
| 5642 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 5643 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 5644 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 5645 | |
| 5646 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 5647 | * let's give it more time in case if we miss the beginning. */ |
| 5648 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 5649 | alt { |
| 5650 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 5651 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5652 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5653 | frame := data)) -> value dl { |
| 5654 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 5655 | setverdict(pass); |
| 5656 | T.stop; |
| 5657 | } |
| 5658 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 5659 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 5660 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 5661 | l2_data := data)) -> value dl { |
| 5662 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 5663 | setverdict(pass); |
| 5664 | T.stop; |
| 5665 | } |
| 5666 | [] L1CTL.receive { repeat; } |
| 5667 | [] T.timeout { |
| 5668 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 5669 | } |
| 5670 | } |
| 5671 | } |
| 5672 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5673 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5674 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 5675 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5676 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5677 | f_init_l1ctl(); |
| 5678 | f_l1_tune(L1CTL); |
| 5679 | |
| 5680 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5681 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 5682 | |
| 5683 | T.start; |
| 5684 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5685 | [] 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] | 5686 | setverdict(pass); |
| 5687 | } |
| 5688 | [] L1CTL.receive { repeat; } |
| 5689 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5690 | 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] | 5691 | } |
| 5692 | } |
| 5693 | } |
| 5694 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5695 | /* Send AGCH from PCU; check it appears on Um side */ |
| 5696 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 5697 | timer T := 3.0; |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5698 | f_init_with_pcuif(); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 5699 | f_init_l1ctl(); |
| 5700 | f_l1_tune(L1CTL); |
| 5701 | |
| 5702 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5703 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 5704 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 5705 | |
| 5706 | T.start; |
| 5707 | alt { |
| 5708 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 5709 | setverdict(pass); |
| 5710 | } |
| 5711 | [] L1CTL.receive { repeat; } |
| 5712 | [] T.timeout { |
| 5713 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 5714 | } |
| 5715 | } |
| 5716 | } |
| 5717 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5718 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 5719 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 5720 | var octetstring imm_ass := f_rnd_octstring(23); |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5721 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5722 | f_init_l1ctl(); |
| 5723 | f_l1_tune(L1CTL); |
| 5724 | |
| 5725 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 5726 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 5727 | |
| 5728 | timer T := 0.5; |
| 5729 | T.start; |
| 5730 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 5731 | [] 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] | 5732 | /* TODO: verify paging group */ |
| 5733 | setverdict(pass); |
| 5734 | } |
| 5735 | [] L1CTL.receive { repeat; } |
| 5736 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5737 | 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] | 5738 | } |
| 5739 | } |
| 5740 | } |
| 5741 | |
| 5742 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 5743 | testcase TC_pcu_rach_content() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5744 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5745 | f_init_l1ctl(); |
| 5746 | f_l1_tune(L1CTL); |
| 5747 | |
| 5748 | var GsmFrameNumber fn_last := 0; |
| 5749 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5750 | var OCT1 ra := f_rnd_ra_ps(); |
| 5751 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 5752 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5753 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5754 | } |
| 5755 | fn_last := fn; |
| 5756 | |
| 5757 | timer T := 2.0; |
| 5758 | T.start; |
| 5759 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5760 | [] 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] | 5761 | T.stop; |
| 5762 | } |
| 5763 | [] 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] | 5764 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5765 | } |
| 5766 | [] PCU.receive { repeat; } |
| 5767 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5768 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5769 | } |
| 5770 | } |
| 5771 | } |
| 5772 | setverdict(pass); |
| 5773 | } |
| 5774 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5775 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 5776 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 5777 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 5778 | var template PCUIF_Message pcu_rach_ind; |
| 5779 | var GsmFrameNumber fn_last := 0; |
| 5780 | var L1ctlRachSynchSeq synch_seq; |
| 5781 | var PCUIF_BurstType pcu_bt; |
| 5782 | var GsmFrameNumber fn; |
| 5783 | var BIT11 ra11; |
| 5784 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5785 | f_init_with_pcuif(); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5786 | f_init_l1ctl(); |
| 5787 | f_l1_tune(L1CTL); |
| 5788 | |
| 5789 | for (var integer i := 0; i < 1000; i := i+1) { |
| 5790 | /* We need to test both TS1 & TS2 */ |
| 5791 | if (i rem 2 == 0) { |
| 5792 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 5793 | pcu_bt := BURST_TYPE_1; |
| 5794 | } else { |
| 5795 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 5796 | pcu_bt := BURST_TYPE_2; |
| 5797 | } |
| 5798 | |
| 5799 | ra11 := f_rnd_ra11_ps(); |
| 5800 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 5801 | if (fn == fn_last) { |
| 5802 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5803 | "Two RACH in same FN?!?"); |
| 5804 | } |
| 5805 | fn_last := fn; |
| 5806 | |
| 5807 | /* Compose the expected message */ |
| 5808 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 5809 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 5810 | ra := bit2int(ra11), |
| 5811 | is_11bit := 1, |
| 5812 | burst_type := pcu_bt, |
| 5813 | fn := fn); |
| 5814 | |
| 5815 | timer T := 2.0; |
| 5816 | T.start; |
| 5817 | alt { |
| 5818 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 5819 | T.stop; |
| 5820 | } |
| 5821 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 5822 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 5823 | } |
| 5824 | [] PCU.receive { repeat; } |
| 5825 | [] T.timeout { |
| 5826 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 5827 | } |
| 5828 | } |
| 5829 | } |
| 5830 | setverdict(pass); |
| 5831 | } |
| 5832 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5833 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 5834 | runs on test_CT { |
| 5835 | var template PCUIF_send_data sdt; |
| 5836 | var PCUIF_send_data sd; |
| 5837 | var int16_t lqual_cb; |
| 5838 | timer T := 1.0; |
| 5839 | |
| 5840 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 5841 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 5842 | |
| 5843 | /* Send a random PDTCH frame over Um */ |
| 5844 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 5845 | '0000'O & f_rnd_octstring(21))); |
| 5846 | |
| 5847 | T.start; |
| 5848 | alt { |
| 5849 | /* If expected link quality is above the threshold */ |
| 5850 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 5851 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 5852 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 5853 | |
| 5854 | /* Make sure the actual link quality matches the expected value */ |
| 5855 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 5856 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 5857 | "expected value ", lqual_cb_exp)); |
| 5858 | } else { |
| 5859 | setverdict(pass); |
| 5860 | } |
| 5861 | } |
| 5862 | /* If expected link quality is below the threshold */ |
| 5863 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 5864 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5865 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 5866 | } |
| 5867 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 5868 | [] PCU.receive { repeat; } |
| 5869 | [lqual_cb_exp < thresh] T.timeout { |
| 5870 | log("Rx nothing, as expected"); |
| 5871 | setverdict(pass); |
| 5872 | } |
| 5873 | [lqual_cb_exp >= thresh] T.timeout { |
| 5874 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5875 | "Timeout waiting for PCUIF_DATA.ind"); |
| 5876 | } |
| 5877 | } |
| 5878 | } |
| 5879 | |
| 5880 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 5881 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5882 | f_init_with_pcuif(); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5883 | PCU.clear; |
| 5884 | |
| 5885 | f_init_l1ctl(); |
| 5886 | f_l1_tune(L1CTL); |
| 5887 | |
| 5888 | /* Activate a PDCH channel on TS7 */ |
| 5889 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5890 | |
| 5891 | /* Tune trxcon to that PDCH channel on TS7 */ |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5892 | 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] | 5893 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 5894 | { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); } |
Vadim Yanitskiy | 1d55dee | 2020-07-14 21:19:09 +0700 | [diff] [blame] | 5895 | f_l1ctl_est_dchan(L1CTL, pars); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 5896 | |
| 5897 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 5898 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 5899 | var TrxcMessage ret; |
| 5900 | |
Vadim Yanitskiy | 418066a | 2021-10-03 14:04:17 +0600 | [diff] [blame] | 5901 | 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] | 5902 | |
| 5903 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 5904 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 5905 | } |
| 5906 | } |
| 5907 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5908 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 5909 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5910 | f_init_with_pcuif(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5911 | |
| 5912 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5913 | var MobileIdentityLV mi_lv; |
| 5914 | var octetstring mi_lv_enc; |
| 5915 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5916 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5917 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5918 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5919 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5920 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5921 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5922 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5923 | |
| 5924 | /* Fancy encoding for PCUIF */ |
| 5925 | mi_lv := valueof(ts_MI_LV(mi)); |
| 5926 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 5927 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5928 | |
| 5929 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 5930 | 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] | 5931 | T.start; |
| 5932 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 5933 | [] 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] | 5934 | } |
| 5935 | [] 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] | 5936 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5937 | } |
| 5938 | [] PCU.receive { repeat; } |
| 5939 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5940 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 5941 | } |
| 5942 | } |
| 5943 | } |
| 5944 | setverdict(pass); |
| 5945 | } |
| 5946 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5947 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 5948 | testcase TC_pcu_time_ind() runs on test_CT { |
| 5949 | var PCUIF_send_data pcu_sd; |
| 5950 | var integer num_time_ind := 0; |
| 5951 | var integer first_fn, last_fn; |
| 5952 | var float test_duration := 5.0; |
| 5953 | timer T; |
| 5954 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 5955 | f_init_with_pcuif(); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5956 | f_TC_pcu_act_req(0, 0, 7, true); |
| 5957 | |
| 5958 | PCU.clear; |
| 5959 | T.start(test_duration); |
| 5960 | alt { |
| 5961 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 5962 | num_time_ind := num_time_ind + 1; |
| 5963 | if (not isbound(first_fn)) { |
| 5964 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 5965 | } |
| 5966 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 5967 | repeat; |
| 5968 | } |
| 5969 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 5970 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 5971 | repeat; |
| 5972 | } |
| 5973 | [] PCU.receive { |
| 5974 | repeat; |
| 5975 | } |
| 5976 | [] T.timeout {} |
| 5977 | } |
| 5978 | var integer fn_expired := last_fn - first_fn; |
| 5979 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 5980 | |
| 5981 | /* verify the number of frames expired matches our expectation */ |
| 5982 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 5983 | 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] | 5984 | 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] | 5985 | if (not match(fn_expired, t_fn_expected)) { |
| 5986 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 5987 | } |
| 5988 | |
| 5989 | /* There are three TIME.ind in every fn MOD 13 */ |
| 5990 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 5991 | /* Add some tolerance */ |
| 5992 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 5993 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 5994 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 5995 | } |
| 5996 | |
| 5997 | setverdict(pass); |
| 5998 | } |
| 5999 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6000 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 6001 | testcase TC_pcu_rts_req() runs on test_CT { |
| 6002 | var PCUIF_send_data pcu_sd; |
| 6003 | var integer first_fn, last_fn; |
| 6004 | var integer num_rts_pdtch := 0; |
| 6005 | var integer num_rts_ptcch := 0; |
| 6006 | var float test_duration := 5.0; |
| 6007 | timer T; |
| 6008 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6009 | f_init_with_pcuif(); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6010 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6011 | |
| 6012 | PCU.clear; |
| 6013 | T.start(test_duration); |
| 6014 | alt { |
| 6015 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 6016 | -> value pcu_sd { |
| 6017 | num_rts_pdtch := num_rts_pdtch + 1; |
| 6018 | if (not isbound(first_fn)) { |
| 6019 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 6020 | } |
| 6021 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 6022 | repeat; |
| 6023 | } |
| 6024 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 6025 | -> value pcu_sd { |
| 6026 | num_rts_ptcch := num_rts_ptcch + 1; |
| 6027 | if (not isbound(first_fn)) { |
| 6028 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 6029 | } |
| 6030 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 6031 | repeat; |
| 6032 | } |
| 6033 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 6034 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 6035 | repeat; |
| 6036 | } |
| 6037 | [] PCU.receive { |
| 6038 | repeat; |
| 6039 | } |
| 6040 | [] T.timeout {} |
| 6041 | } |
| 6042 | var integer fn_expired := last_fn - first_fn; |
| 6043 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 6044 | ", num_rts_ptcch=", num_rts_ptcch); |
| 6045 | |
| 6046 | /* verify the number of frames expired matches our expectation */ |
| 6047 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 6048 | 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] | 6049 | 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] | 6050 | if (not match(fn_expired, t_fn_expected)) { |
| 6051 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 6052 | } |
| 6053 | |
| 6054 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 6055 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 6056 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 6057 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 6058 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 6059 | t_ptcch_exp); |
| 6060 | } |
| 6061 | |
| 6062 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 6063 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 6064 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 6065 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 6066 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 6067 | t_pdtch_exp); |
| 6068 | } |
| 6069 | |
| 6070 | setverdict(pass); |
| 6071 | } |
| 6072 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6073 | /* test for generating Abis side OML ALERT from the PCU */ |
| 6074 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 6075 | var PCUIF_send_data pcu_sd; |
| 6076 | var integer num_time_ind := 0; |
| 6077 | var integer first_fn, last_fn; |
| 6078 | var float test_duration := 5.0; |
| 6079 | timer T; |
| 6080 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6081 | f_init_with_pcuif(); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6082 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6083 | |
| 6084 | /* re-connect CTRL port from BTS to BSC */ |
| 6085 | f_ipa_ctrl_stop(); |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 6086 | 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] | 6087 | |
| 6088 | /* Send that OML Alert */ |
| 6089 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 6090 | |
| 6091 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 6092 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 6093 | setverdict(pass); |
| 6094 | } |
| 6095 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6096 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 6097 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 6098 | var PCUIF_Message first_info; |
| 6099 | var integer pcu_conn_id := -1; |
| 6100 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6101 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 6102 | var OCT4 tlli := '01020304'O; |
| 6103 | var OCT1 cause := '23'O; |
| 6104 | timer T := 5.0; |
| 6105 | |
| 6106 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6107 | |
| 6108 | f_l1_tune(L1CTL); |
| 6109 | RSL.clear; |
| 6110 | |
| 6111 | f_est_dchan(); |
| 6112 | L1CTL.clear; |
| 6113 | |
| 6114 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6115 | |
| 6116 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 6117 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 6118 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 6119 | |
| 6120 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 6121 | T.start; |
| 6122 | alt { |
| 6123 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 6124 | setverdict(pass); |
| 6125 | } |
| 6126 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 6127 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 6128 | } |
| 6129 | [] PCU.receive { |
| 6130 | repeat; |
| 6131 | } |
| 6132 | [] T.timeout { |
| 6133 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 6134 | } |
| 6135 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 6136 | |
| 6137 | /* release the channel */ |
| 6138 | f_rsl_chan_deact(); |
| 6139 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6140 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6141 | } |
| 6142 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 6143 | var ConnHdlrPars pars; |
| 6144 | var ConnHdlr vc_conn; |
| 6145 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6146 | f_init_with_pcuif(); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6147 | |
| 6148 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 6149 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 6150 | vc_conn.done; |
| 6151 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6152 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6153 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 6154 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6155 | var boolean connected := false; |
| 6156 | var UD_connect_result cr; |
| 6157 | var integer cid; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6158 | timer T := 5.0; |
| 6159 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6160 | var template UD_Result tr_ok := { result_code := SUCCESS, err := omit }; |
| 6161 | var template UD_Result tr_err := { result_code := ERROR, err := ? }; |
| 6162 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6163 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6164 | f_init_with_pcuif(); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6165 | |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6166 | /* try to establish a second connection */ |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6167 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 6168 | T.start; |
| 6169 | alt { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6170 | /* the IUT will first accept() the new connection, and close() it immediately */ |
| 6171 | [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr { |
| 6172 | log("BTS has accept()ed connection"); |
| 6173 | connected := true; |
| 6174 | cid := cr.id; |
| 6175 | repeat; |
| 6176 | } |
| 6177 | [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) { |
| 6178 | log("BTS has close()d connection"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6179 | setverdict(pass); |
| 6180 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6181 | /* ignore other messages related to the first connection */ |
| 6182 | [] PCU.receive { repeat; } |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6183 | [] T.timeout { |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6184 | setverdict(fail, "Timeout waiting for connection result"); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6185 | } |
| 6186 | } |
Vadim Yanitskiy | 94bbe99 | 2021-03-23 07:23:34 +0100 | [diff] [blame] | 6187 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6188 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6189 | } |
| 6190 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6191 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 6192 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 6193 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6194 | f_init_with_pcuif(); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6195 | |
| 6196 | f_sleep(1.0); |
| 6197 | |
| 6198 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6199 | g_pcu_conn_id := -1; |
| 6200 | |
| 6201 | f_sleep(1.0); |
| 6202 | |
| 6203 | /* re-connect */ |
| 6204 | PCU.clear; |
| 6205 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6206 | setverdict(pass); |
| 6207 | |
| 6208 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6209 | } |
| 6210 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6211 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6212 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 6213 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6214 | var L1ctlDlMessage l1_dl; |
| 6215 | var SystemInformation si; |
Vadim Yanitskiy | cb478ec | 2020-07-11 02:37:17 +0700 | [diff] [blame] | 6216 | var integer rc; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6217 | timer T := 5.0; |
| 6218 | T.start; |
| 6219 | alt { |
| 6220 | [] 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] | 6221 | rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si); |
| 6222 | if (rc != 0 or si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6223 | repeat; |
| 6224 | } |
| 6225 | } |
| 6226 | [] pt.receive { |
| 6227 | repeat; |
| 6228 | } |
| 6229 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6230 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6231 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6232 | } |
| 6233 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 6234 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6235 | } |
| 6236 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6237 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 6238 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 6239 | runs on test_CT return boolean { |
| 6240 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 6241 | |
| 6242 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6243 | return si.payload.si3.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6244 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
Neels Hofmeyr | a5f0ed2 | 2020-07-06 02:39:40 +0200 | [diff] [blame] | 6245 | return si.payload.si4.rest_octets.gprs_ind.presence == '1'B; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6246 | } |
| 6247 | |
| 6248 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 6249 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6250 | } |
| 6251 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6252 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 6253 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 6254 | runs on test_CT { |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6255 | f_init(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6256 | f_init_l1ctl(); |
| 6257 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6258 | f_sleep(2.0); |
| 6259 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6260 | |
| 6261 | if (f_si_has_gprs_indicator(si_type)) { |
| 6262 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6263 | } else { |
| 6264 | setverdict(pass); |
| 6265 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6266 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6267 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6268 | } |
| 6269 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6270 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 6271 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6272 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6273 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6274 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 6275 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6276 | } |
| 6277 | |
| 6278 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 6279 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 6280 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6281 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6282 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6283 | f_init_l1ctl(); |
| 6284 | f_l1_tune(L1CTL); |
| 6285 | |
| 6286 | f_sleep(2.0); |
| 6287 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6288 | |
| 6289 | if (not f_si_has_gprs_indicator(si_type)) { |
| 6290 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6291 | } else { |
| 6292 | setverdict(pass); |
| 6293 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6294 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6295 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6296 | } |
| 6297 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6298 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 6299 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 6300 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6301 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6302 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 6303 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 6304 | } |
| 6305 | |
| 6306 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 6307 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 6308 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6309 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6310 | f_init_with_pcuif(); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6311 | f_init_l1ctl(); |
| 6312 | f_l1_tune(L1CTL); |
| 6313 | |
| 6314 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 6315 | g_pcu_conn_id := -1; |
| 6316 | |
| 6317 | f_sleep(1.0); |
| 6318 | |
| 6319 | /* re-connect */ |
| 6320 | PCU.clear; |
| 6321 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 6322 | |
| 6323 | f_sleep(2.0); |
| 6324 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6325 | |
| 6326 | if (f_si_has_gprs_indicator(si_type)) { |
| 6327 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6328 | } else { |
| 6329 | setverdict(pass); |
| 6330 | } |
| 6331 | |
| 6332 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6333 | } |
| 6334 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6335 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 6336 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 6337 | } |
| 6338 | |
| 6339 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 6340 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 6341 | } |
| 6342 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6343 | /* 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) */ |
| 6344 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 6345 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 6346 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6347 | f_init_with_pcuif(); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6348 | |
Harald Welte | 7622022 | 2020-10-11 20:32:44 +0200 | [diff] [blame] | 6349 | /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct |
| 6350 | * information */ |
| 6351 | timer T := 2.0; |
| 6352 | T.start; |
| 6353 | alt { |
| 6354 | [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; } |
| 6355 | [] T.timeout {} |
| 6356 | } |
| 6357 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6358 | /* Verify cell_id */ |
| 6359 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 6360 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 6361 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 6362 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 6363 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 6364 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6365 | } |
| 6366 | |
| 6367 | /* Verify LAC */ |
| 6368 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 6369 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 6370 | if (lac_si3 != lac_pcu) { |
| 6371 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 6372 | } |
| 6373 | |
| 6374 | setverdict(pass); |
| 6375 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6376 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6377 | /* Verify hopping parameters in the INFO.ind message (version >= 10) */ |
| 6378 | testcase TC_pcu_info_ind_fh_params() runs on test_CT { |
| 6379 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6380 | var FreqHopPars fhp; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6381 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6382 | f_init_with_pcuif(); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6383 | |
| 6384 | info_ind := g_pcu_last_info.u.info_ind; |
| 6385 | |
| 6386 | for (var integer i := 0; i < mp_transceiver_num; i := i + 1) { |
| 6387 | for (var integer tn := 0; tn < 8; tn := tn + 1) { |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6388 | if (info_ind.trx[i].pdch_mask[tn] != '1'B) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6389 | /* Skip inactive timeslots */ |
| 6390 | continue; |
| 6391 | } |
| 6392 | |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6393 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) |
Vadim Yanitskiy | 7e1d0a2 | 2020-09-17 19:48:11 +0700 | [diff] [blame] | 6394 | { f_resolve_fh_params(fhp, tn, trx_nr := i); } |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6395 | else |
| 6396 | { fhp.enabled := false; } |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6397 | |
| 6398 | var template PCUIF_InfoTrxTs tr_ts; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6399 | if (fhp.enabled) { |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6400 | tr_ts := tr_PCUIF_InfoTrxTsH1( |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 6401 | hsn := fhp.maio_hsn.hsn, |
| 6402 | maio := fhp.maio_hsn.maio, |
| 6403 | ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B), |
Vadim Yanitskiy | aa553ed | 2020-09-17 19:44:32 +0700 | [diff] [blame] | 6404 | ma_bit_len := mp_transceiver_num); |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6405 | } else { |
| 6406 | tr_ts := tr_PCUIF_InfoTrxTsH0; |
| 6407 | } |
| 6408 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6409 | var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn]; |
Vadim Yanitskiy | 7faef07 | 2020-08-03 04:22:04 +0700 | [diff] [blame] | 6410 | log("Checking timeslot #", tn, " of trx#", i, ": ", ts); |
| 6411 | if (not match(ts, tr_ts)) { |
| 6412 | setverdict(fail, "Hopping parameters do not match: ", |
| 6413 | "received ", ts, " vs expected ", tr_ts); |
| 6414 | } else { |
| 6415 | setverdict(pass); |
| 6416 | } |
| 6417 | } |
| 6418 | } |
| 6419 | } |
| 6420 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6421 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6422 | testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT { |
| 6423 | f_init_vty_bsc(); |
| 6424 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6425 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6426 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6427 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6428 | |
| 6429 | 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] | 6430 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6431 | addr_type := { PCUIF_ADDR_TYPE_IPV4, ? }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6432 | 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] | 6433 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6434 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6435 | if (not match(remote_addr, tr_remote_addr)) { |
| 6436 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6437 | } |
| 6438 | |
| 6439 | setverdict(pass); |
| 6440 | } |
| 6441 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6442 | /* Verify IPv4 NSVC address in the INFO.ind message */ |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6443 | testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT { |
| 6444 | f_init_vty_bsc(); |
| 6445 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee"); |
| 6446 | |
Vadim Yanitskiy | ec9e981 | 2021-03-21 23:02:44 +0100 | [diff] [blame] | 6447 | f_init_with_pcuif(); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6448 | |
| 6449 | 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] | 6450 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6451 | addr_type := { PCUIF_ADDR_TYPE_IPV6, ? }, |
| 6452 | addr := { f_inet6_addr("fd00::ca:ff:ee"), ? } |
| 6453 | }; |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6454 | |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 6455 | if (not match(remote_addr, tr_remote_addr)) { |
| 6456 | setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); |
Alexander Couzens | 5283f55 | 2020-07-28 15:39:04 +0200 | [diff] [blame] | 6457 | } |
| 6458 | |
| 6459 | setverdict(pass); |
| 6460 | } |
| 6461 | |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6462 | /* Verify coding of two NSVCs in the INFO.ind message */ |
| 6463 | testcase TC_pcu_socket_two_nsvc() runs on test_CT { |
| 6464 | f_init_vty_bsc(); |
| 6465 | |
| 6466 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234"); |
| 6467 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234"); |
| 6468 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127"); |
| 6469 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234"); |
| 6470 | |
| 6471 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678"); |
| 6472 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678"); |
| 6473 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee"); |
| 6474 | f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678"); |
| 6475 | |
Vadim Yanitskiy | c1981b7 | 2021-03-23 03:01:49 +0100 | [diff] [blame] | 6476 | f_init_with_pcuif(); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6477 | |
| 6478 | var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind; |
| 6479 | var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr; |
| 6480 | var template PCUIF_RemoteAddr tr_remote_addr := { |
| 6481 | addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 }, |
Vadim Yanitskiy | 216021a | 2021-03-24 15:51:06 +0100 | [diff] [blame] | 6482 | addr := { |
| 6483 | f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), |
| 6484 | f_inet6_addr("fd00::ca:ff:ee") |
| 6485 | } |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 6486 | }; |
| 6487 | |
| 6488 | if (not match(info_ind.nsvci, { 1234, 5678 })) |
| 6489 | { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); } |
| 6490 | if (not match(remote_addr, tr_remote_addr)) |
| 6491 | { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); } |
| 6492 | if (not match(info_ind.local_port, { 1234, 5678 })) |
| 6493 | { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); } |
| 6494 | if (not match(info_ind.remote_port, { 1234, 5678 })) |
| 6495 | { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); } |
| 6496 | |
| 6497 | setverdict(pass); |
| 6498 | } |
| 6499 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6500 | /* Verify periodic interference reports on PDCH */ |
| 6501 | testcase TC_pcu_interf_ind() runs on test_CT { |
| 6502 | var template PCUIF_Message tr_interf_ind; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6503 | var integer interf_ind_num := 0; |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6504 | var boolean first := true; |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6505 | var PCUIF_send_data sd; |
| 6506 | timer T; |
| 6507 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6508 | /* Set the averaging/reporting period to 480ms */ |
| 6509 | f_init_vty_bsc(); |
| 6510 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 1" }); |
| 6511 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 6512 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6513 | f_init_with_pcuif(); |
| 6514 | f_TC_pcu_act_req(0, 0, 7, true); |
| 6515 | |
| 6516 | /* We need trxcon for NOPE indications */ |
| 6517 | f_init_l1ctl(); |
| 6518 | f_l1_tune(L1CTL); |
| 6519 | |
| 6520 | /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */ |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6521 | tr_interf_ind := tr_PCUIF_INTERF_IND( |
| 6522 | bts_nr := 0, |
| 6523 | trx_nr := 0, |
| 6524 | fn := ?, |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 6525 | interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) } |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6526 | ); |
| 6527 | |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6528 | T.start(0.480 * 1.5); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6529 | alt { |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6530 | /* The first interference report may contain unreliable values, so we ignore it */ |
| 6531 | [first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) { |
| 6532 | /* 4 SACCH periods => 4 reports (plus some guard time) */ |
| 6533 | T.start(0.480 * 4.0 + 0.480 / 2.0); |
| 6534 | first := false; |
| 6535 | repeat; |
| 6536 | } |
| 6537 | /* Subsequent interference reports shall match our expectations */ |
| 6538 | [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] | 6539 | /* Check TDMA frame number period */ |
| 6540 | if (sd.data.u.interf_ind.fn mod 104 != 0) { |
| 6541 | setverdict(fail, "Odd TDMA frame number := ", |
| 6542 | sd.data.u.interf_ind.fn); |
| 6543 | } |
| 6544 | interf_ind_num := interf_ind_num + 1; |
| 6545 | if (interf_ind_num < 4) |
| 6546 | { repeat; } |
| 6547 | } |
Vadim Yanitskiy | 3b868cb | 2021-11-10 04:10:48 +0300 | [diff] [blame] | 6548 | [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] | 6549 | setverdict(fail, "Received unexpected interference report: ", sd.data); |
| 6550 | } |
| 6551 | [] PCU.receive { repeat; } |
| 6552 | [] T.timeout { |
| 6553 | setverdict(fail, "Timeout waiting for interference reports"); |
| 6554 | } |
| 6555 | } |
| 6556 | |
Vadim Yanitskiy | d9b60e6 | 2021-11-10 03:58:31 +0300 | [diff] [blame] | 6557 | /* Reset the averaging/reporting period back to default */ |
| 6558 | f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 6" }); |
| 6559 | |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 6560 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 6561 | } |
| 6562 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6563 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6564 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6565 | ***********************************************************************/ |
| 6566 | |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6567 | private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp, |
| 6568 | integer bts_nr, integer trx_nr) |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6569 | runs on ConnHdlr { |
| 6570 | var PCUIF_send_data sd; |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6571 | |
| 6572 | [] 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] | 6573 | 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] | 6574 | if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) { |
| 6575 | repeat; |
| 6576 | } |
| 6577 | } |
| 6578 | } |
| 6579 | |
| 6580 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6581 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6582 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6583 | PCU.clear; |
| 6584 | f_rsl_chan_act(g_pars.chan_mode); |
| 6585 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6586 | timer T_wait := 2.0; |
| 6587 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6588 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6589 | [] 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] | 6590 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6591 | [] T_wait.timeout { |
| 6592 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6593 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6594 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6595 | } |
| 6596 | /* try to activate this PDCH from the PCU point of view */ |
| 6597 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6598 | /* FIXME: is there a response? */ |
| 6599 | } |
| 6600 | |
| 6601 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6602 | runs on ConnHdlr { |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6603 | /* Send RSL CHAN REL (deactivate) */ |
| 6604 | PCU.clear; |
| 6605 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6606 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6607 | timer T_wait := 2.0; |
| 6608 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6609 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6610 | [] 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] | 6611 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 6612 | [] T_wait.timeout { |
| 6613 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6614 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6615 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6616 | } |
| 6617 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6618 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6619 | alt { |
| 6620 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 6621 | setverdict(pass); |
| 6622 | } |
| 6623 | [] RSL.receive { repeat; } |
| 6624 | } |
| 6625 | } |
| 6626 | |
| 6627 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6628 | 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] | 6629 | var PCUIF_Message first_info; |
| 6630 | var integer ts_nr := g_chan_nr.tn; |
| 6631 | var integer trx_nr := 0; |
| 6632 | var integer bts_nr := 0; |
| 6633 | var integer pcu_conn_id := -1; |
| 6634 | |
| 6635 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6636 | |
| 6637 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6638 | f_sleep(3.0); |
| 6639 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6640 | setverdict(pass); |
| 6641 | } |
| 6642 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 6643 | var ConnHdlrPars pars; |
| 6644 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6645 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6646 | |
| 6647 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6648 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 6649 | vc_conn.done; |
| 6650 | } |
| 6651 | |
| 6652 | /* 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] | 6653 | 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] | 6654 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6655 | var integer pcu_conn_id := -1; |
| 6656 | |
| 6657 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6658 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 6659 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 6660 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 6661 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6662 | setverdict(pass); |
| 6663 | } |
| 6664 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 6665 | var ConnHdlrPars pars; |
| 6666 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6667 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6668 | |
| 6669 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6670 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 6671 | vc_conn.done; |
| 6672 | } |
| 6673 | |
| 6674 | /* 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] | 6675 | 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] | 6676 | var PCUIF_Message first_info; |
| 6677 | var integer ts_nr := g_chan_nr.tn; |
| 6678 | var integer trx_nr := 0; |
| 6679 | var integer bts_nr := 0; |
| 6680 | var integer pcu_conn_id := -1; |
| 6681 | |
| 6682 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6683 | |
| 6684 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 6685 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 6686 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 6687 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6688 | setverdict(pass); |
| 6689 | } |
| 6690 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 6691 | var ConnHdlrPars pars; |
| 6692 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6693 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6694 | |
| 6695 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6696 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 6697 | vc_conn.done; |
| 6698 | } |
| 6699 | |
| 6700 | /* 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] | 6701 | 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] | 6702 | var PCUIF_Message first_info; |
| 6703 | var integer ts_nr := g_chan_nr.tn; |
| 6704 | var integer trx_nr := 0; |
| 6705 | var integer bts_nr := 0; |
| 6706 | var integer pcu_conn_id := -1; |
| 6707 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 6708 | |
| 6709 | /* register for the TCH/F channel number */ |
| 6710 | f_rslem_register(0, chan_nr); |
| 6711 | |
| 6712 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6713 | |
| 6714 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 6715 | "RSL CHAN ACT"); |
| 6716 | setverdict(pass); |
| 6717 | } |
| 6718 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 6719 | var ConnHdlrPars pars; |
| 6720 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6721 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6722 | |
| 6723 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6724 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 6725 | vc_conn.done; |
| 6726 | } |
| 6727 | |
| 6728 | /* 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] | 6729 | 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] | 6730 | var PCUIF_Message first_info; |
| 6731 | var integer ts_nr := g_chan_nr.tn; |
| 6732 | var integer trx_nr := 0; |
| 6733 | var integer bts_nr := 0; |
| 6734 | var integer pcu_conn_id := -1; |
| 6735 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 6736 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 6737 | |
| 6738 | /* register for the TCH/H channel numbers */ |
| 6739 | f_rslem_register(0, chan_nr[0]); |
| 6740 | f_rslem_register(0, chan_nr[1]); |
| 6741 | |
| 6742 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6743 | |
| 6744 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 6745 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 6746 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 6747 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 6748 | setverdict(pass); |
| 6749 | } |
| 6750 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 6751 | var ConnHdlrPars pars; |
| 6752 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6753 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6754 | |
| 6755 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6756 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 6757 | vc_conn.done; |
| 6758 | } |
| 6759 | |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 6760 | /* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */ |
| 6761 | private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr { |
| 6762 | var PCUIF_Message first_info; |
| 6763 | var integer ts_nr := g_chan_nr.tn; |
| 6764 | var integer trx_nr := 0; |
| 6765 | var integer bts_nr := 0; |
| 6766 | var integer pcu_conn_id := -1; |
| 6767 | var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)), |
| 6768 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)), |
| 6769 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)), |
| 6770 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)), |
| 6771 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)), |
| 6772 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)), |
| 6773 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)), |
| 6774 | valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) }; |
| 6775 | |
| 6776 | /* register for the TCH/H channel numbers */ |
| 6777 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6778 | f_rslem_register(0, chan_nr[i]); |
| 6779 | } |
| 6780 | |
| 6781 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6782 | |
| 6783 | for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) { |
| 6784 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode), |
| 6785 | tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]"); |
| 6786 | } |
| 6787 | setverdict(pass); |
| 6788 | } |
| 6789 | testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT { |
| 6790 | var ConnHdlrPars pars; |
| 6791 | var ConnHdlr vc_conn; |
| 6792 | f_init(); |
| 6793 | |
| 6794 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 6795 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true); |
| 6796 | vc_conn.done; |
| 6797 | } |
| 6798 | |
Vadim Yanitskiy | 64043d8 | 2021-10-03 15:00:20 +0600 | [diff] [blame] | 6799 | /* Reproduce a race condition described in OS#5245 */ |
| 6800 | private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr { |
| 6801 | f_rsl_chan_act(g_pars.chan_mode); |
| 6802 | f_sleep(1.0); |
| 6803 | f_rsl_chan_deact(); |
| 6804 | setverdict(pass); |
| 6805 | } |
| 6806 | testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT { |
| 6807 | var ConnHdlrPars pars[2]; |
| 6808 | var ConnHdlr vc_conn[2]; |
| 6809 | var TrxcMessage rsp; |
| 6810 | |
| 6811 | f_init(); |
| 6812 | |
| 6813 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6814 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6815 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6816 | |
| 6817 | /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second |
| 6818 | * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */ |
| 6819 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6820 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */ |
| 6821 | pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN)); |
| 6822 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6823 | pars[i], l1ctl := false); |
| 6824 | } |
| 6825 | |
| 6826 | /* Wait for all components to finish */ |
| 6827 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6828 | vc_conn[i].done; |
| 6829 | } |
| 6830 | |
| 6831 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6832 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6833 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6834 | } |
| 6835 | testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT { |
| 6836 | var ConnHdlrPars pars[8]; |
| 6837 | var ConnHdlr vc_conn[8]; |
| 6838 | var TrxcMessage rsp; |
| 6839 | |
| 6840 | f_init(); |
| 6841 | |
| 6842 | /* Configure an artificial delay of 200 ms for TRXC RSP messages */ |
| 6843 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6844 | ts_TRXC_FAKE_TRXC_DELAY(200)); |
| 6845 | |
| 6846 | /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent |
| 6847 | * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */ |
| 6848 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6849 | /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */ |
| 6850 | pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN)); |
| 6851 | vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact), |
| 6852 | pars[i], l1ctl := false); |
| 6853 | } |
| 6854 | |
| 6855 | /* Wait for all components to finish */ |
| 6856 | for (var integer i := 0; i < sizeof(pars); i := i + 1) { |
| 6857 | vc_conn[i].done; |
| 6858 | } |
| 6859 | |
| 6860 | /* Disable the artificial delay for TRXC RSP messages */ |
| 6861 | rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 6862 | ts_TRXC_FAKE_TRXC_DELAY(0)); |
| 6863 | } |
| 6864 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6865 | /*********************************************************************** |
| 6866 | * IPA Style Dynamic Timeslot Support |
| 6867 | ***********************************************************************/ |
| 6868 | |
| 6869 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6870 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6871 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 6872 | PCU.clear; |
| 6873 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6874 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6875 | timer T_wait := 2.0; |
| 6876 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6877 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6878 | [] 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] | 6879 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6880 | [] T_wait.timeout { |
| 6881 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6882 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 6883 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6884 | } |
| 6885 | /* try to activate this PDCH from the PCU point of view */ |
| 6886 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6887 | /* FIXME: is there a response? */ |
| 6888 | |
| 6889 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 6890 | } |
| 6891 | |
| 6892 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 6893 | runs on ConnHdlr { |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6894 | /* Send RSL CHAN REL (deactivate) */ |
| 6895 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 6896 | PCU.clear; |
| 6897 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6898 | timer T_wait := 2.0; |
| 6899 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6900 | alt { |
Vadim Yanitskiy | b1ebcc0 | 2020-07-19 17:43:02 +0700 | [diff] [blame] | 6901 | [] 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] | 6902 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 6903 | [] T_wait.timeout { |
| 6904 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 6905 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 6906 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6907 | } |
| 6908 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 6909 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 6910 | alt { |
| 6911 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 6912 | setverdict(pass); |
| 6913 | } |
| 6914 | [] RSL.receive { repeat; } |
| 6915 | } |
| 6916 | } |
| 6917 | |
| 6918 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 6919 | 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] | 6920 | var PCUIF_Message first_info; |
| 6921 | var integer ts_nr := g_chan_nr.tn; |
| 6922 | var integer trx_nr := 0; |
| 6923 | var integer bts_nr := 0; |
| 6924 | var integer pcu_conn_id := -1; |
| 6925 | |
| 6926 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6927 | |
| 6928 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 6929 | f_sleep(3.0); |
| 6930 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 6931 | |
| 6932 | setverdict(pass); |
| 6933 | |
| 6934 | } |
| 6935 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 6936 | var ConnHdlrPars pars; |
| 6937 | var ConnHdlr vc_conn; |
| 6938 | f_init(); |
| 6939 | |
| 6940 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6941 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 6942 | vc_conn.done; |
| 6943 | } |
| 6944 | |
| 6945 | /* 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] | 6946 | 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] | 6947 | var PCUIF_Message first_info; |
| 6948 | var integer ts_nr := g_chan_nr.tn; |
| 6949 | var integer trx_nr := 0; |
| 6950 | var integer bts_nr := 0; |
| 6951 | var integer pcu_conn_id := -1; |
| 6952 | |
| 6953 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6954 | |
| 6955 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6956 | "RSL CHAN ACT"); |
| 6957 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6958 | "RF CHAN REL", true); |
| 6959 | setverdict(pass); |
| 6960 | } |
| 6961 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 6962 | var ConnHdlrPars pars; |
| 6963 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6964 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6965 | |
| 6966 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 6967 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 6968 | vc_conn.done; |
| 6969 | } |
| 6970 | |
| 6971 | /* 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] | 6972 | 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] | 6973 | var PCUIF_Message first_info; |
| 6974 | var integer ts_nr := g_chan_nr.tn; |
| 6975 | var integer trx_nr := 0; |
| 6976 | var integer bts_nr := 0; |
| 6977 | var integer pcu_conn_id := -1; |
| 6978 | |
| 6979 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 6980 | |
| 6981 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 6982 | "RSL CHAN ACT"); |
| 6983 | |
| 6984 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 6985 | alt { |
| 6986 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 6987 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6988 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6989 | } |
| 6990 | [] RSL.receive { repeat; } |
| 6991 | } |
| 6992 | |
| 6993 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 6994 | "RF CHAN REL", true); |
| 6995 | setverdict(pass); |
| 6996 | } |
| 6997 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 6998 | var ConnHdlrPars pars; |
| 6999 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7000 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7001 | |
| 7002 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 7003 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 7004 | vc_conn.done; |
| 7005 | } |
| 7006 | |
| 7007 | /* 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] | 7008 | 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] | 7009 | var PCUIF_Message first_info; |
| 7010 | var integer ts_nr := g_chan_nr.tn; |
| 7011 | var integer trx_nr := 0; |
| 7012 | var integer bts_nr := 0; |
| 7013 | var integer pcu_conn_id := -1; |
| 7014 | |
| 7015 | /* register for the TCH/F channel number */ |
| 7016 | f_rslem_register(0, g_chan_nr); |
| 7017 | |
| 7018 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 7019 | |
| 7020 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 7021 | |
| 7022 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 7023 | "RSL CHAN ACT"); |
| 7024 | |
| 7025 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 7026 | |
| 7027 | setverdict(pass); |
| 7028 | } |
| 7029 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 7030 | var ConnHdlrPars pars; |
| 7031 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7032 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 7033 | |
| 7034 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 7035 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 7036 | vc_conn.done; |
| 7037 | } |
| 7038 | |
| 7039 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7040 | /*********************************************************************** |
| 7041 | * LAPDm / RLL related |
| 7042 | ***********************************************************************/ |
| 7043 | |
| 7044 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 7045 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 7046 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7047 | var template (value) SacchL1Header l1h; |
| 7048 | |
| 7049 | /* 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] | 7050 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7051 | /* Compose dummy L1 header */ |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 7052 | 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] | 7053 | 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] | 7054 | } else { |
| 7055 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 7056 | 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] | 7057 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7058 | } |
| 7059 | |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7060 | friend type record RllTestCase { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7061 | uint3_t sapi, |
| 7062 | RslLinkId link_id, |
| 7063 | octetstring l3, |
| 7064 | boolean exp |
| 7065 | } |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7066 | friend type record of RllTestCase RllTestCases; |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7067 | friend template RllTestCase t_EITC(template (present) uint3_t sapi, |
| 7068 | template (present) RslLinkId id, |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7069 | octetstring l3, boolean exp) := { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7070 | sapi := sapi, |
| 7071 | link_id := id, |
| 7072 | l3 := l3, |
| 7073 | exp := exp |
| 7074 | } |
| 7075 | |
| 7076 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 7077 | * variety of logical channels */ |
| 7078 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) 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 | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7082 | |
| 7083 | /* test on each of the channels we have */ |
| 7084 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 7085 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 7086 | |
| 7087 | /* test each of the test cases on the current channel */ |
| 7088 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 7089 | pars.spec.rll := tcs[j]; |
| 7090 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 7091 | vc_conn := f_start_handler(fn, pars); |
| 7092 | vc_conn.done; |
| 7093 | } |
| 7094 | } |
| 7095 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7096 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7097 | } |
| 7098 | |
| 7099 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 7100 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 7101 | var RllTestCase tc := g_pars.spec.rll; |
| 7102 | timer T := 3.0; |
| 7103 | |
| 7104 | f_l1_tune(L1CTL); |
| 7105 | RSL.clear; |
| 7106 | |
| 7107 | /* activate the logical channel */ |
| 7108 | f_est_dchan(); |
| 7109 | L1CTL.clear; |
| 7110 | |
| 7111 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 7112 | T.start; |
| 7113 | alt { |
| 7114 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7115 | if (tc.exp) { |
| 7116 | setverdict(pass); |
| 7117 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7118 | 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] | 7119 | } |
| 7120 | } |
| 7121 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 7122 | if (tc.exp) { |
| 7123 | setverdict(pass); |
| 7124 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7125 | 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] | 7126 | } |
| 7127 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7128 | /* We also expect to receive the measurements */ |
| 7129 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7130 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7131 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7132 | } |
| 7133 | [not tc.exp] T.timeout { |
| 7134 | setverdict(pass); |
| 7135 | } |
| 7136 | } |
| 7137 | |
| 7138 | f_rsl_chan_deact(); |
| 7139 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7140 | f_rslem_unregister(0, g_chan_nr); |
| 7141 | } |
| 7142 | testcase TC_rll_est_ind() runs on test_CT { |
| 7143 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7144 | /* SAPI0 establishment (contention resolution) */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7145 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 7146 | /* normal SAPI0 establishment */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7147 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7148 | /* SAPI 3 doesn't support contention resolution */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7149 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)), |
| 7150 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7151 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7152 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7153 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7154 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7155 | }; |
| 7156 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 7157 | } |
| 7158 | |
| 7159 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 7160 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 7161 | var RllTestCase tc := g_pars.spec.rll; |
| 7162 | var L1ctlDlMessage dl; |
| 7163 | timer T := 3.0; |
| 7164 | |
| 7165 | f_l1_tune(L1CTL); |
| 7166 | RSL.clear; |
| 7167 | |
| 7168 | /* activate the logical channel */ |
| 7169 | f_est_dchan(); |
| 7170 | L1CTL.clear; |
| 7171 | |
| 7172 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 7173 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 7174 | T.start; |
| 7175 | alt { |
Vadim Yanitskiy | 0310f63 | 2021-06-01 01:22:24 +0200 | [diff] [blame] | 7176 | [] 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] | 7177 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7178 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7179 | } |
| 7180 | } |
| 7181 | |
| 7182 | f_rsl_chan_deact(); |
| 7183 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7184 | f_rslem_unregister(0, g_chan_nr); |
| 7185 | } |
| 7186 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 7187 | var RllTestCases tcs := { |
| 7188 | /* normal SAPI3 establishment on main DCCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7189 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7190 | }; |
| 7191 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7192 | } |
| 7193 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 7194 | var RllTestCases tcs := { |
| 7195 | /* normal SAPI3 establishment on SACCH */ |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7196 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7197 | } |
| 7198 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 7199 | } |
| 7200 | |
| 7201 | /* altstep to receive a LAPDm frame matching the given template */ |
Vadim Yanitskiy | 7368a10 | 2021-06-01 01:25:08 +0200 | [diff] [blame] | 7202 | friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7203 | var L1ctlDlMessage dl; |
| 7204 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 7205 | var LapdmFrame lapdm; |
| 7206 | var octetstring l2 := dl.payload.data_ind.payload; |
| 7207 | if (dl.dl_info.link_id.c == SACCH) { |
| 7208 | /* remove L1 header */ |
| 7209 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 7210 | } |
| 7211 | if (ischosen(exp.ab)) { |
| 7212 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 7213 | } else if (ischosen(exp.b4)) { |
| 7214 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 7215 | } else if (ischosen(exp.bbis)) { |
| 7216 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 7217 | } |
| 7218 | log("Rx LAPDm ", lapdm); |
| 7219 | if (match(lapdm, exp)) { |
| 7220 | setverdict(pass); |
| 7221 | } else { |
| 7222 | repeat; |
| 7223 | } |
| 7224 | } |
| 7225 | [] L1CTL.receive { repeat; } |
| 7226 | } |
| 7227 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 7228 | timer T := t; |
| 7229 | T.start; |
| 7230 | alt { |
| 7231 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7232 | 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] | 7233 | } |
| 7234 | [] as_l1_exp_lapdm(exp); |
| 7235 | } |
| 7236 | } |
| 7237 | |
| 7238 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 7239 | 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] | 7240 | timer T := 2.0; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7241 | /* send SABM from MS -> BTS */ |
| 7242 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 7243 | /* expect RLL EST IND on Abis */ |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7244 | T.start; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7245 | alt { |
| 7246 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 7247 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 7248 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7249 | 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] | 7250 | } |
| 7251 | [] RSL.receive { repeat; } |
Vadim Yanitskiy | 2534135 | 2022-07-25 06:13:12 +0700 | [diff] [blame] | 7252 | [] T.timeout { |
| 7253 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RLL EST IND"); |
| 7254 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7255 | } |
| 7256 | /* expect UA from BTS -> MS */ |
| 7257 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 7258 | } |
| 7259 | |
| 7260 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 7261 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 7262 | var RllTestCase tc := g_pars.spec.rll; |
| 7263 | |
| 7264 | f_l1_tune(L1CTL); |
| 7265 | RSL.clear; |
| 7266 | |
| 7267 | /* activate the logical channel */ |
| 7268 | f_est_dchan(); |
| 7269 | L1CTL.clear; |
| 7270 | |
| 7271 | /* first establish the link-layer */ |
| 7272 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7273 | |
| 7274 | /* then send the DISC */ |
| 7275 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 7276 | /* ... and expect the REL IND on the RSL side */ |
| 7277 | alt { |
| 7278 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 7279 | setverdict(pass); |
| 7280 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 7281 | /* We also expect to receive the measurements */ |
| 7282 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7283 | } |
| 7284 | |
| 7285 | /* release the channel */ |
| 7286 | f_rsl_chan_deact(); |
| 7287 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7288 | f_rslem_unregister(0, g_chan_nr); |
| 7289 | } |
| 7290 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 7291 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7292 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7293 | }; |
| 7294 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7295 | } |
| 7296 | |
| 7297 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 7298 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7299 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7300 | }; |
| 7301 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7302 | } |
| 7303 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 7304 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7305 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7306 | }; |
| 7307 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7308 | } |
| 7309 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 7310 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7311 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7312 | }; |
| 7313 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 7314 | } |
| 7315 | |
| 7316 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 7317 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 7318 | var RllTestCase tc := g_pars.spec.rll; |
| 7319 | f_l1_tune(L1CTL); |
| 7320 | RSL.clear; |
| 7321 | |
| 7322 | /* activate the logical channel */ |
| 7323 | f_est_dchan(); |
| 7324 | L1CTL.clear; |
| 7325 | |
| 7326 | /* first establish the link-layer */ |
| 7327 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 7328 | |
| 7329 | /* then send the REL REQ via RSL */ |
| 7330 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 7331 | /* ... and expect the DISC on the Um side */ |
| 7332 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 7333 | [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7334 | /* FIXME: send a UA in resposne to the DISC */ |
| 7335 | } |
| 7336 | } |
| 7337 | |
| 7338 | /* release the channel */ |
| 7339 | f_rsl_chan_deact(); |
| 7340 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7341 | f_rslem_unregister(0, g_chan_nr); |
| 7342 | } |
| 7343 | testcase TC_rll_rel_req() runs on test_CT { |
| 7344 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7345 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)), |
| 7346 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)), |
| 7347 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)), |
| 7348 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''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_req)); |
| 7351 | } |
| 7352 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7353 | /* 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] | 7354 | testcase TC_rll_data_req() runs on test_CT { |
| 7355 | } |
| 7356 | |
Vadim Yanitskiy | 89be060 | 2020-07-04 21:20:57 +0700 | [diff] [blame] | 7357 | /* 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] | 7358 | testcase TC_rll_data_ind() runs on test_CT { |
| 7359 | } |
| 7360 | |
| 7361 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 7362 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 7363 | var RllTestCase tc := g_pars.spec.rll; |
| 7364 | |
| 7365 | f_l1_tune(L1CTL); |
| 7366 | RSL.clear; |
| 7367 | |
| 7368 | f_est_dchan(); |
| 7369 | L1CTL.clear; |
| 7370 | |
| 7371 | /* Send UNITDATA REQ on RSL side */ |
| 7372 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 7373 | /* Expect it to arrive on the other side */ |
| 7374 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7375 | 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] | 7376 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7377 | 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] | 7378 | } |
| 7379 | |
| 7380 | /* release the channel */ |
| 7381 | f_rsl_chan_deact(); |
| 7382 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7383 | f_rslem_unregister(0, g_chan_nr); |
| 7384 | } |
| 7385 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 7386 | var octetstring l3 := f_rnd_octstring(15); |
| 7387 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7388 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7389 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7390 | }; |
| 7391 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7392 | } |
| 7393 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 7394 | var octetstring l3 := f_rnd_octstring(19); |
| 7395 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7396 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7397 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7398 | }; |
| 7399 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 7400 | } |
| 7401 | |
| 7402 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 7403 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 7404 | var RllTestCase tc := g_pars.spec.rll; |
| 7405 | |
| 7406 | f_l1_tune(L1CTL); |
| 7407 | RSL.clear; |
| 7408 | |
| 7409 | f_est_dchan(); |
| 7410 | L1CTL.clear; |
| 7411 | |
| 7412 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7413 | 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] | 7414 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 7415 | alt { |
| 7416 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 7417 | setverdict(pass); |
| 7418 | } |
| 7419 | [] RSL.receive { repeat; } |
| 7420 | } |
| 7421 | |
| 7422 | /* release the channel */ |
| 7423 | f_rsl_chan_deact(); |
| 7424 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7425 | f_rslem_unregister(0, g_chan_nr); |
| 7426 | } |
| 7427 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 7428 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7429 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7430 | valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)), |
| 7431 | valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7432 | }; |
| 7433 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7434 | } |
| 7435 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 7436 | var octetstring l3 := f_rnd_octstring(18); |
| 7437 | var RllTestCases tcs := { |
Vadim Yanitskiy | 1b9a7f6 | 2021-06-01 01:56:37 +0200 | [diff] [blame] | 7438 | valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)), |
| 7439 | valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true)) |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7440 | }; |
| 7441 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 7442 | } |
| 7443 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7444 | /*********************************************************************** |
| 7445 | * Encryption Related |
| 7446 | ***********************************************************************/ |
| 7447 | |
| 7448 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
Vadim Yanitskiy | 8239dd9 | 2020-07-04 20:31:35 +0700 | [diff] [blame] | 7449 | 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] | 7450 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 7451 | if (link_id.c == SACCH) { |
| 7452 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7453 | } else { |
| 7454 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 7455 | } |
| 7456 | } |
| 7457 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7458 | /* Expect (or not expect) other kinds of messages */ |
| 7459 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 7460 | [exp_any] RSL.receive { repeat; } |
| 7461 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7462 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7463 | } |
| 7464 | } |
| 7465 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7466 | /* 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] | 7467 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7468 | RslLinkId link_id, |
| 7469 | octetstring l3, |
| 7470 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7471 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 7472 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7473 | timer T := 3.0; |
| 7474 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 7475 | T.start; |
| 7476 | /* Expect RLL UNITDATA IND on RSL side */ |
| 7477 | alt { |
| 7478 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 7479 | setverdict(pass); |
| 7480 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7481 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 7482 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7483 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7484 | 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] | 7485 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7486 | } |
| 7487 | } |
| 7488 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7489 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 7490 | private function f_data_mo( |
| 7491 | RslLinkId link_id, |
| 7492 | boolean p, uint3_t nr, uint3_t ns, |
| 7493 | octetstring l3, |
| 7494 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 7495 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7496 | ) runs on ConnHdlr { |
| 7497 | timer T := 3.0; |
| 7498 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 7499 | T.start; |
| 7500 | /* Expect RLL DATA IND on RSL side */ |
| 7501 | alt { |
| 7502 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 7503 | setverdict(pass); |
| 7504 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 7505 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7506 | [] as_rsl_any_ind(exp_any); |
| 7507 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7508 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7509 | } |
| 7510 | } |
| 7511 | } |
| 7512 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7513 | /* 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] | 7514 | private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7515 | f_l1_tune(L1CTL); |
| 7516 | f_est_dchan(true); |
| 7517 | |
| 7518 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7519 | var L1ctlDlMessage dl; |
| 7520 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 7521 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7522 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7523 | |
| 7524 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7525 | f_unitdata_mt(link_id, l3); |
| 7526 | |
| 7527 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7528 | f_unitdata_mo(link_id, l3); |
| 7529 | |
| 7530 | /* release the channel */ |
| 7531 | f_rsl_chan_deact(); |
| 7532 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7533 | f_rslem_unregister(0, g_chan_nr); |
| 7534 | } |
| 7535 | testcase TC_chan_act_a51() runs on test_CT { |
| 7536 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7537 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7538 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7539 | } |
| 7540 | testcase TC_chan_act_a52() runs on test_CT { |
| 7541 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7542 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7543 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7544 | } |
| 7545 | testcase TC_chan_act_a53() runs on test_CT { |
| 7546 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7547 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7548 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7549 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7550 | testcase TC_chan_act_a54() runs on test_CT { |
| 7551 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7552 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7553 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 7554 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7555 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7556 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 7557 | 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] | 7558 | private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 7559 | f_l1_tune(L1CTL); |
| 7560 | f_est_dchan(true); |
| 7561 | |
| 7562 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 7563 | var L1ctlDlMessage dl; |
| 7564 | |
| 7565 | var octetstring l3 := f_rnd_octstring(20); |
| 7566 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7567 | |
| 7568 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 7569 | f_unitdata_mt(link_id, l3); |
| 7570 | |
| 7571 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 7572 | f_unitdata_mo(link_id, l3); |
| 7573 | |
| 7574 | var RSL_Message rsl; |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7575 | 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] | 7576 | |
| 7577 | /* modify key to break proper encryption */ |
| 7578 | g_pars.encr.key := f_rnd_octstring(8); |
| 7579 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 7580 | rsl.ies := rsl.ies & { ei }; |
| 7581 | RSL.send(rsl); |
| 7582 | |
| 7583 | timer T0 := 1.0; |
| 7584 | T0.start; |
| 7585 | /* Expect RSL MODIFY ACK */ |
| 7586 | alt { |
| 7587 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 7588 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 7589 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 7590 | } |
| 7591 | [] T0.timeout { |
| 7592 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 7593 | } |
| 7594 | } |
| 7595 | |
| 7596 | var octetstring l3msg := f_rnd_octstring(15); |
| 7597 | timer T1 := 3.0; |
| 7598 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 7599 | due to broken encryption */ |
| 7600 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 7601 | T1.start; |
| 7602 | alt { |
| 7603 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 7604 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 7605 | } |
| 7606 | [] T1.timeout { |
| 7607 | setverdict(pass); |
| 7608 | } |
| 7609 | } |
| 7610 | |
| 7611 | /* release the channel */ |
| 7612 | f_rsl_chan_deact(); |
| 7613 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7614 | f_rslem_unregister(0, g_chan_nr); |
| 7615 | } |
| 7616 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 7617 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7618 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7619 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 7620 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7621 | |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 7622 | /* Verify RF RESource INDication messages (periodically sent over the RSL) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 7623 | 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] | 7624 | runs on test_CT { |
| 7625 | const IpaStreamId sid := IPAC_PROTO_RSL_TRX0; |
| 7626 | var ASP_RSL_Unitdata ud; |
| 7627 | timer T; |
| 7628 | |
| 7629 | /* Intave is 6 SACCH periods by default */ |
| 7630 | var float Tval := int2float(6 * 480) / 1000.0 + 0.5; |
| 7631 | |
| 7632 | T.start(Tval); |
| 7633 | alt { |
| 7634 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) { |
| 7635 | setverdict(pass); |
| 7636 | } |
| 7637 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud { |
| 7638 | setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl); |
| 7639 | } |
| 7640 | [] RSL_CCHAN.receive { repeat; } |
| 7641 | [] T.timeout { |
| 7642 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 7643 | "Timeout waiting for RF RESource INDication"); |
| 7644 | } |
| 7645 | } |
| 7646 | } |
| 7647 | testcase TC_rsl_rf_resource_ind() runs on test_CT { |
| 7648 | var RSL_ResourceInfo info := { }; |
| 7649 | |
| 7650 | f_init(trx_nr := 0); |
| 7651 | |
| 7652 | f_init_l1ctl(); |
| 7653 | f_l1_tune(L1CTL); |
| 7654 | |
| 7655 | /* g_AllChannels contains all logical channels */ |
| 7656 | for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) { |
| 7657 | var RslChannelNr chan_nr := g_AllChannels[i]; |
| 7658 | |
| 7659 | /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */ |
| 7660 | if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH) |
| 7661 | { continue; } |
| 7662 | |
| 7663 | info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) }; |
| 7664 | } |
| 7665 | |
| 7666 | /* Align to the first interference report */ |
| 7667 | f_TC_rsl_rf_resource_ind(?); |
| 7668 | |
| 7669 | /* Test 4 consecutive messages */ |
| 7670 | for (var integer i := 0; i < 4; i := i + 1) { |
| 7671 | f_TC_rsl_rf_resource_ind(info); |
| 7672 | } |
| 7673 | |
| 7674 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7675 | } |
| 7676 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7677 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7678 | private function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7679 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 7680 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 7681 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 7682 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 7683 | |
| 7684 | f_l1_tune(L1CTL); |
| 7685 | |
| 7686 | /* first establish a dedicated channel in the clear */ |
| 7687 | f_est_dchan(false); |
| 7688 | |
| 7689 | /* Establish ABM */ |
| 7690 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 7691 | |
| 7692 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 7693 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 7694 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 7695 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 7696 | |
| 7697 | /* configure L1 to apply ciphering */ |
| 7698 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 7699 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 7700 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 7701 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 7702 | 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] | 7703 | |
| 7704 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 7705 | * and hence enable encryption also on the downlink */ |
| 7706 | |
| 7707 | /* expect bi-directional communication work in encrypted mode */ |
| 7708 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 7709 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 7710 | |
| 7711 | /* release the channel */ |
| 7712 | f_rsl_chan_deact(); |
| 7713 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 7714 | f_rslem_unregister(0, g_chan_nr); |
| 7715 | } |
| 7716 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 7717 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7718 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 7719 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7720 | } |
| 7721 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 7722 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7723 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 7724 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7725 | } |
| 7726 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 7727 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7728 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 7729 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7730 | } |
Eric Wild | b926039 | 2021-05-15 19:48:22 +0200 | [diff] [blame] | 7731 | testcase TC_encr_cmd_a54() runs on test_CT { |
| 7732 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 7733 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16))); |
| 7734 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 7735 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7736 | |
| 7737 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 7738 | var LapdmFrame lf; |
| 7739 | var octetstring reenc; |
| 7740 | |
| 7741 | /* decode the LAPDm frame */ |
| 7742 | if (ischosen(exp_match.ab)) { |
| 7743 | lf.ab := dec_LapdmFrameAB(enc); |
| 7744 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7745 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 7746 | } |
| 7747 | |
| 7748 | /* check if decoder result matches expectation */ |
| 7749 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7750 | 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] | 7751 | } else { |
| 7752 | log(name, ": matched"); |
| 7753 | setverdict(pass); |
| 7754 | } |
| 7755 | |
| 7756 | /* test if re-encoded frame equals original input */ |
| 7757 | reenc := enc_LapdmFrame(lf); |
| 7758 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7759 | 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] | 7760 | } else { |
| 7761 | setverdict(pass); |
| 7762 | } |
| 7763 | } |
| 7764 | |
| 7765 | testcase TC_lapdm_selftest() runs on test_CT { |
| 7766 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 7767 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 7768 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 7769 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 7770 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 7771 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 7772 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 7773 | } |
| 7774 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7775 | /*********************************************************************** |
| 7776 | * DTX Related (see GSM 05.08, section 8.3) |
| 7777 | ***********************************************************************/ |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7778 | 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] | 7779 | var L1ctlDlMessage dl; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7780 | var GsmFrameNumber first_fn; |
| 7781 | var boolean is_first_frame := true; |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7782 | var integer nfill_frames := 0; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7783 | 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] | 7784 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 7785 | 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] | 7786 | const integer frame_dtx_tchf_mod := 104; |
| 7787 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 7788 | * which operates in terms of blocks rather than frames. */ |
| 7789 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 7790 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7791 | timer T := 5.0; |
| 7792 | |
| 7793 | f_l1_tune(L1CTL); |
| 7794 | RSL.clear; |
| 7795 | L1CTL.clear; |
| 7796 | |
| 7797 | /* activate TCHF signalling channel */ |
| 7798 | f_est_dchan(false); |
| 7799 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7800 | /* A template for matching dummy LAPDm func=UA frames */ |
| 7801 | var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND( |
| 7802 | chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?), |
| 7803 | l2_data := f_pad_oct('030301'O, 23, '2B'O)); |
| 7804 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7805 | T.start; |
| 7806 | alt { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7807 | [] L1CTL.receive(tr_fill_frame) -> value dl { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7808 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7809 | |
| 7810 | if (is_first_frame) { |
| 7811 | is_first_frame := false; |
| 7812 | first_fn := dl.dl_info.frame_nr; |
| 7813 | } |
| 7814 | |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7815 | if (g_pars.chan_mode.dtx_d) { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7816 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7817 | T.stop; |
| 7818 | f_rsl_chan_deact(); |
| 7819 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7820 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7821 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */ |
| 7822 | expected_fill_frames := 2; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7823 | |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7824 | if (nfill_frames < expected_fill_frames) { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7825 | setverdict(fail, "Not enough fill frames received: ", |
| 7826 | nfill_frames, " out of ", expected_fill_frames); |
| 7827 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7828 | } else { |
| 7829 | setverdict(pass); |
| 7830 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7831 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7832 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 7833 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 7834 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 7835 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 7836 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 7837 | 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] | 7838 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7839 | repeat; |
| 7840 | } |
| 7841 | } |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7842 | setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn, |
| 7843 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 7844 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7845 | f_rsl_chan_deact(); |
| 7846 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7847 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7848 | } else { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7849 | nfill_frames := nfill_frames + 1; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 7850 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7851 | T.stop; |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7852 | |
| 7853 | select (g_chan_nr) { |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7854 | /* TCH/F: we expect 24 fill frames for every 104 frames. */ |
| 7855 | case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7856 | /* TCH/H: we expect 2 fill frames for every 104 frames. */ |
| 7857 | case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; } |
| 7858 | /* SDCCH: we expect 5 fill frames for every 104 frames. */ |
Vadim Yanitskiy | 080a17d | 2020-10-25 01:06:48 +0700 | [diff] [blame] | 7859 | case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; } |
| 7860 | case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; } |
Vadim Yanitskiy | 34ed228 | 2020-10-24 23:18:42 +0700 | [diff] [blame] | 7861 | case else { |
| 7862 | /* This shall not happen, just to be sure */ |
| 7863 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 7864 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7865 | } |
| 7866 | |
| 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 | if (nfill_frames >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7871 | setverdict(pass); |
| 7872 | } else { |
Vadim Yanitskiy | 76dc4d0 | 2020-10-24 22:56:46 +0700 | [diff] [blame] | 7873 | setverdict(fail, "Not enough fill frames received: ", |
| 7874 | nfill_frames, " out of ", expected_fill_frames); |
| 7875 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7876 | } |
| 7877 | } else { |
| 7878 | repeat; |
| 7879 | } |
| 7880 | } |
| 7881 | } |
| 7882 | [] L1CTL.receive { repeat; } |
| 7883 | [] T.timeout { |
| 7884 | f_rsl_chan_deact(); |
| 7885 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 7886 | 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] | 7887 | } |
| 7888 | } |
| 7889 | } |
| 7890 | |
Vadim Yanitskiy | 71c39ea | 2020-07-04 20:44:42 +0700 | [diff] [blame] | 7891 | 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] | 7892 | var template RSL_IE_ChannelMode ch_mode; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7893 | var ConnHdlr vc_conn; |
| 7894 | var ConnHdlrPars pars; |
| 7895 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 7896 | f_init(); |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7897 | ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7898 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
Vadim Yanitskiy | 8fc43df | 2020-10-20 02:11:05 +0700 | [diff] [blame] | 7899 | pars := valueof(t_Pars(g_AllChannels[i], ch_mode)); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7900 | if (dtxd) { |
| 7901 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 7902 | break; |
| 7903 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 7904 | } |
Vadim Yanitskiy | 28a03ef | 2020-10-25 01:50:40 +0700 | [diff] [blame] | 7905 | 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] | 7906 | vc_conn.done; |
| 7907 | } |
| 7908 | } |
| 7909 | |
| 7910 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 7911 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 7912 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 7913 | f_tch_sign_l2_fill_frame(false); |
| 7914 | } |
| 7915 | |
| 7916 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 7917 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 7918 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 7919 | f_tch_sign_l2_fill_frame(true); |
| 7920 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 7921 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 7922 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 7923 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7924 | } |
| 7925 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 7926 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 7927 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 7928 | } |
| 7929 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7930 | |
| 7931 | /* Callback function to be called by as_TC_ms_pwr_ctrl_constant(). |
| 7932 | * Return value: Measurement Report to be sent (encoded octetstring). */ |
| 7933 | type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks) |
| 7934 | runs on ConnHdlr return octetstring; |
| 7935 | |
| 7936 | private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks) |
| 7937 | runs on ConnHdlr { |
| 7938 | var L1ctlDlMessage l1_dl; |
| 7939 | var SacchL1Header l1h; |
| 7940 | var octetstring l2; |
| 7941 | |
| 7942 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 7943 | /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */ |
| 7944 | l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2)); |
| 7945 | log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h); |
| 7946 | |
| 7947 | /* Pass it to the user specified call-back function */ |
| 7948 | l2 := cb.apply(l1h, num_blocks); |
| 7949 | /* Send a Measurement Report generated by the call-back */ |
| 7950 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr, |
| 7951 | l1_dl.dl_info.link_id, |
| 7952 | l1h, l2)); |
| 7953 | |
| 7954 | /* Shall we keep going? */ |
| 7955 | num_blocks := num_blocks - 1; |
| 7956 | log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining"); |
| 7957 | if (num_blocks > 0) { repeat; } |
| 7958 | } |
| 7959 | [] L1CTL.receive { repeat; } |
| 7960 | } |
| 7961 | |
| 7962 | private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks) |
| 7963 | runs on ConnHdlr return octetstring { |
| 7964 | /* Command the L1 to apply received parameters */ |
| 7965 | f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl); |
| 7966 | |
| 7967 | /* Dummy measurement report (the results are invalid) */ |
| 7968 | return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O); |
| 7969 | } |
| 7970 | |
| 7971 | private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks) |
| 7972 | runs on ConnHdlr return octetstring { |
| 7973 | if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) { |
| 7974 | setverdict(fail, "Unexpected MS Power level change: ", |
| 7975 | g_pars.l1_pars.ms_power_level, " -> ", |
| 7976 | l1h.ms_power_lvl); |
| 7977 | } |
| 7978 | |
| 7979 | return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks); |
| 7980 | } |
| 7981 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 7982 | private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks) |
| 7983 | runs on ConnHdlr return octetstring { |
| 7984 | /* UL RSSI oscillation driven by SACCH block number */ |
| 7985 | if (num_blocks rem 2 == 0) { |
| 7986 | f_trxc_fake_rssi(-100); |
| 7987 | } else { |
| 7988 | f_trxc_fake_rssi(-50); |
| 7989 | } |
| 7990 | |
| 7991 | /* Make sure that MS power level remains constant */ |
| 7992 | return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks); |
| 7993 | } |
| 7994 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 7995 | /* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */ |
| 7996 | private function f_TC_ms_pwr_ctrl_constant(charstring id) |
| 7997 | runs on ConnHdlr { |
| 7998 | var integer num_blocks := 8; |
| 7999 | timer T := int2float(num_blocks); |
| 8000 | |
| 8001 | f_l1_tune(L1CTL); |
| 8002 | RSL.clear; |
| 8003 | |
| 8004 | /* These IEs are needed for autonomous MS power control */ |
| 8005 | var template (value) RSL_IE_List ies := { |
| 8006 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8007 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 8008 | }), |
| 8009 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 8010 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 8011 | }) |
| 8012 | }; |
| 8013 | |
| 8014 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 8015 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 8016 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8017 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 8018 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8019 | |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8020 | /* Establish a dedicated channel */ |
| 8021 | f_est_dchan(more_ies := valueof(ies)); |
| 8022 | |
| 8023 | L1CTL.clear; |
| 8024 | T.start; |
| 8025 | alt { |
| 8026 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks); |
| 8027 | [] T.timeout { |
| 8028 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 8029 | num_blocks, " were not handled"); |
| 8030 | } |
| 8031 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 8032 | |
| 8033 | /* Release the channel */ |
| 8034 | f_rsl_chan_deact(); |
| 8035 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8036 | } |
| 8037 | testcase TC_ms_pwr_ctrl_constant() runs on test_CT { |
| 8038 | var ConnHdlr vc_conn; |
| 8039 | var ConnHdlrPars pars; |
| 8040 | |
| 8041 | f_init(); |
| 8042 | |
| 8043 | /* Explicitly configure the Uplink power target (in dBm) */ |
| 8044 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)); |
| 8045 | |
| 8046 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 8047 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 8048 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 8049 | |
| 8050 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant), |
| 8051 | pars, trxc_comp := true); |
| 8052 | vc_conn.done; |
| 8053 | } |
| 8054 | |
| 8055 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 8056 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8057 | } |
| 8058 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8059 | /* Test Exponentially Weighted Moving Average (EWMA) power filtering */ |
| 8060 | private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id) |
| 8061 | runs on ConnHdlr { |
| 8062 | var integer num_blocks := 16; |
| 8063 | timer T := int2float(num_blocks); |
| 8064 | |
| 8065 | f_l1_tune(L1CTL); |
| 8066 | RSL.clear; |
| 8067 | |
| 8068 | /* These IEs are needed for autonomous MS power control */ |
| 8069 | var template (value) RSL_IE_List ies := { |
| 8070 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8071 | ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level) |
| 8072 | }), |
| 8073 | t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ |
| 8074 | ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O) |
| 8075 | }) |
| 8076 | }; |
| 8077 | |
| 8078 | /* Ensure that 'rx-current' equals 'rx-target' */ |
| 8079 | f_trxc_fake_rssi(mp_uplink_power_target); |
| 8080 | |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8081 | /* Populate SACCH cache with a Measurement Report */ |
Vadim Yanitskiy | e2003d0 | 2022-08-10 17:38:07 +0700 | [diff] [blame] | 8082 | f_send_meas_rep(ts_MeasurementResults); |
Vadim Yanitskiy | 8a1685d | 2022-07-30 23:56:18 +0700 | [diff] [blame] | 8083 | |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8084 | /* Establish a dedicated channel */ |
| 8085 | f_est_dchan(more_ies := valueof(ies)); |
| 8086 | |
| 8087 | L1CTL.clear; |
| 8088 | T.start; |
| 8089 | alt { |
| 8090 | [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks); |
| 8091 | [] T.timeout { |
| 8092 | setverdict(fail, "Not all SACCH blocks were processed in time, ", |
| 8093 | num_blocks, " were not handled"); |
| 8094 | } |
| 8095 | } |
Vadim Yanitskiy | 6b4404a | 2021-06-17 17:22:56 +0200 | [diff] [blame] | 8096 | |
| 8097 | /* Release the channel */ |
| 8098 | f_rsl_chan_deact(); |
| 8099 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8100 | } |
| 8101 | testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT { |
| 8102 | var ConnHdlr vc_conn; |
| 8103 | var ConnHdlrPars pars; |
| 8104 | |
| 8105 | f_init(); |
| 8106 | |
| 8107 | /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */ |
| 8108 | f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80"); |
| 8109 | /* Explicitly configure the Uplink power range (target and delte) */ |
| 8110 | f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target) |
| 8111 | & " hysteresis " & int2str(mp_uplink_power_hysteresis)); |
| 8112 | |
| 8113 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) { |
| 8114 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 8115 | log(testcasename(), ": starting on ", pars.chan_nr); |
| 8116 | |
| 8117 | vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma), |
| 8118 | pars, trxc_comp := true); |
| 8119 | vc_conn.done; |
| 8120 | } |
| 8121 | |
| 8122 | /* No need to reset Uplink power parameters - the IUT restarts anyway */ |
| 8123 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8124 | } |
| 8125 | |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8126 | private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr { |
| 8127 | var template L1ctlDlMessage tr_bad_frame; |
| 8128 | var L1ctlDlMessage l1_dl; |
| 8129 | timer T := 8.0; |
| 8130 | |
| 8131 | f_l1_tune(L1CTL); |
| 8132 | RSL.clear; |
| 8133 | |
| 8134 | f_est_dchan(); |
| 8135 | |
| 8136 | /* There may be a few errors right after the channel activation */ |
| 8137 | f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */ |
| 8138 | L1CTL.clear; |
| 8139 | |
| 8140 | /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */ |
| 8141 | tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0)); |
| 8142 | tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND); |
| 8143 | tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */ |
| 8144 | tr_bad_frame.payload := ?; |
| 8145 | |
| 8146 | T.start; |
| 8147 | alt { |
| 8148 | /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that |
| 8149 | * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */ |
| 8150 | [] L1CTL.receive(tr_bad_frame) -> value l1_dl { |
| 8151 | setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl); |
| 8152 | } |
| 8153 | [] as_l1_sacch(); |
| 8154 | [] L1CTL.receive { repeat; } |
| 8155 | [] T.timeout { |
| 8156 | /* We're done, break the loop */ |
| 8157 | setverdict(pass); |
| 8158 | } |
| 8159 | } |
| 8160 | |
| 8161 | f_rsl_chan_deact(); |
| 8162 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8163 | } |
| 8164 | testcase TC_speech_no_rtp_tchf() runs on test_CT { |
| 8165 | var ConnHdlr vc_conn; |
| 8166 | var ConnHdlrPars pars; |
| 8167 | |
| 8168 | f_init(); |
| 8169 | |
| 8170 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8171 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8172 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8173 | vc_conn.done; |
| 8174 | } |
| 8175 | testcase TC_speech_no_rtp_tchh() runs on test_CT { |
| 8176 | var ConnHdlr vc_conn; |
| 8177 | var ConnHdlrPars pars; |
| 8178 | |
| 8179 | f_init(); |
| 8180 | |
| 8181 | /* TS5, TCH/H, V1 (HR codec) */ |
| 8182 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8183 | vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars); |
| 8184 | vc_conn.done; |
| 8185 | } |
| 8186 | |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8187 | /* Verify handling of Downlink and Uplink speech frames */ |
| 8188 | private function f_TC_speech_rtp(charstring id) runs on ConnHdlr { |
| 8189 | var L1ctlDlMessage l1_dl; |
| 8190 | var PDU_RTP rtp_pdu; |
| 8191 | var octetstring pl; |
| 8192 | timer Td, Tu; |
| 8193 | |
| 8194 | f_l1_tune(L1CTL); |
| 8195 | f_est_dchan(); |
| 8196 | |
| 8197 | /* Activate the RTP emulation */ |
| 8198 | pl := f_rnd_octstring(6); |
| 8199 | f_rtpem_activate(pl); |
| 8200 | |
| 8201 | /* Give the scheduler some time to fill up the buffers */ |
| 8202 | f_sleep(2.0); |
| 8203 | L1CTL.clear; |
| 8204 | RSL.clear; |
| 8205 | |
| 8206 | /* Make sure that Downlink frames are received at the UE */ |
| 8207 | Td.start(2.0); |
| 8208 | alt { |
| 8209 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl { |
| 8210 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8211 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8212 | l1_dl.payload.traffic_ind.data)); |
| 8213 | setverdict(pass); |
| 8214 | } |
| 8215 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8216 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8217 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8218 | "expected (", pl, ")"); |
| 8219 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8220 | } |
| 8221 | [] as_l1_sacch(); |
| 8222 | [] L1CTL.receive { repeat; } |
| 8223 | [] Td.timeout { |
| 8224 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8225 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8226 | } |
| 8227 | } |
| 8228 | |
| 8229 | /* Make sure that Uplink frames are received at the BTS */ |
| 8230 | RTPEM_DATA.clear; |
| 8231 | Tu.start(2.0); |
| 8232 | alt { |
| 8233 | [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu { |
| 8234 | if (rtp_pdu.data != pl) |
| 8235 | { repeat; } |
| 8236 | } |
| 8237 | [] RTPEM_DATA.receive { repeat; } |
| 8238 | [] Tu.timeout { |
| 8239 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8241 | } |
| 8242 | } |
| 8243 | |
| 8244 | f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE); |
| 8245 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8246 | f_rsl_chan_deact(); |
| 8247 | f_rslem_unregister(0, g_chan_nr); |
| 8248 | } |
| 8249 | testcase TC_speech_rtp_tchf() runs on test_CT { |
| 8250 | var ConnHdlr vc_conn; |
| 8251 | var ConnHdlrPars pars; |
| 8252 | |
| 8253 | f_init(); |
| 8254 | |
| 8255 | /* TS1, TCH/F, V1 (FR codec) */ |
| 8256 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))); |
| 8257 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8258 | vc_conn.done; |
| 8259 | |
| 8260 | /* TS1, TCH/F, V2 (EFR codec) */ |
| 8261 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))); |
| 8262 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8263 | vc_conn.done; |
| 8264 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8265 | /* TS1, TCH/F, V3 (AMR codec) */ |
| 8266 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))); |
| 8267 | pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */)); |
| 8268 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8269 | vc_conn.done; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8270 | |
| 8271 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8272 | } |
| 8273 | testcase TC_speech_rtp_tchh() runs on test_CT { |
| 8274 | var ConnHdlr vc_conn; |
| 8275 | var ConnHdlrPars pars; |
| 8276 | |
| 8277 | f_init(); |
| 8278 | |
| 8279 | /* TS5, TCH/H0, V1 (HR codec) */ |
| 8280 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))); |
| 8281 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8282 | vc_conn.done; |
| 8283 | |
Pau Espin Pedrol | 091c530 | 2022-09-02 18:11:12 +0200 | [diff] [blame] | 8284 | /* TS1, TCH/H0, V3 (AMR codec) */ |
| 8285 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))); |
| 8286 | pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */)); |
| 8287 | vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars); |
| 8288 | vc_conn.done; |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 8289 | |
| 8290 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8291 | } |
| 8292 | |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 8293 | |
| 8294 | /* Verify handling of Downlink and Uplink Osmux speech frames */ |
| 8295 | private function f_TC_speech_osmux(charstring id) runs on ConnHdlr { |
| 8296 | var L1ctlDlMessage l1_dl; |
| 8297 | var OSMUX_PDU osmux_pdu; |
| 8298 | var octetstring pl; |
| 8299 | var octetstring exp_rtp_pl; |
| 8300 | timer Td, Tu; |
| 8301 | |
| 8302 | f_l1_tune(L1CTL); |
| 8303 | f_est_dchan(); |
| 8304 | |
| 8305 | /* Activate the RTP emulation */ |
| 8306 | pl := f_rnd_octstring(6); |
| 8307 | f_osmuxem_activate(pl); |
| 8308 | |
| 8309 | /* Give the scheduler some time to fill up the buffers */ |
| 8310 | f_sleep(2.0); |
| 8311 | L1CTL.clear; |
| 8312 | RSL.clear; |
| 8313 | |
| 8314 | /* we transmit using AMR_FT_2 (5.90), see t_TxHandleAMR590 in f_osmuxem_activate() */ |
| 8315 | var integer amr_ft := get_start_amr_ft(); |
| 8316 | var integer amr_pl_len := f_amrft_payload_len(amr_ft); |
| 8317 | var octetstring hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B))); |
| 8318 | pl := f_osmux_gen_expected_rx_rtp_payload(amr_ft, pl); |
| 8319 | exp_rtp_pl := hdr & pl; |
| 8320 | |
| 8321 | /* Make sure that Downlink frames are received at the UE */ |
| 8322 | Td.start(2.0); |
| 8323 | alt { |
| 8324 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := exp_rtp_pl)) -> value l1_dl { |
| 8325 | log("TCH received: ", l1_dl.payload.traffic_ind.data); |
| 8326 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id, |
| 8327 | l1_dl.payload.traffic_ind.data)); |
| 8328 | setverdict(pass); |
| 8329 | } |
| 8330 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl { |
| 8331 | setverdict(fail, "Rx unexpected Downlink speech frame ", |
| 8332 | "(", l1_dl.payload.traffic_ind.data, ") ", |
| 8333 | "expected (", exp_rtp_pl, ")"); |
| 8334 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8335 | } |
| 8336 | [] as_l1_sacch(); |
| 8337 | [] L1CTL.receive { repeat; } |
| 8338 | [] Td.timeout { |
| 8339 | setverdict(fail, "Timeout waiting for Downlink speech frames"); |
| 8340 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8341 | } |
| 8342 | } |
| 8343 | |
| 8344 | /* Make sure that Uplink frames are received at the BTS */ |
| 8345 | OsmuxEM_DATA.clear; |
| 8346 | var template (present) OSMUX_PDU osmux_pdu_exp := tr_PDU_Osmux_AMR(cid := g_pars.loc_osmux_cid, |
| 8347 | amr_ft := amr_ft, |
| 8348 | amr_cmr := amr_ft); |
| 8349 | Tu.start(2.0); |
| 8350 | alt { |
| 8351 | [] OsmuxEM_DATA.receive(osmux_pdu_exp) -> value osmux_pdu { |
| 8352 | var boolean matched := false; |
| 8353 | for (var integer i := 0; i < osmux_pdu.osmux_amr.header.ctr + 1; i := i + 1) { |
| 8354 | var octetstring rx_pl; |
| 8355 | rx_pl := f_osmux_amr_get_nth_amr_payload(osmux_pdu.osmux_amr, i); |
| 8356 | log("got ", rx_pl, " vs exp ", pl); |
| 8357 | if (rx_pl == pl) { |
| 8358 | matched := true; |
| 8359 | break; |
| 8360 | } |
| 8361 | } |
| 8362 | if (not matched) { |
| 8363 | repeat; |
| 8364 | } |
| 8365 | } |
| 8366 | [] OsmuxEM_DATA.receive { repeat; } |
| 8367 | [] Tu.timeout { |
| 8368 | setverdict(fail, "Timeout waiting for Uplink speech frames"); |
| 8369 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8370 | } |
| 8371 | } |
| 8372 | |
| 8373 | f_osmuxem_mode(OsmuxEM_CTRL, OSMUXEM_MODE_NONE); |
| 8374 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8375 | f_rsl_chan_deact(); |
| 8376 | f_rslem_unregister(0, g_chan_nr); |
| 8377 | } |
| 8378 | testcase TC_speech_osmux_tchf() runs on test_CT { |
| 8379 | var ConnHdlr vc_conn; |
| 8380 | var ConnHdlrPars pars; |
| 8381 | |
| 8382 | f_init(); |
| 8383 | |
| 8384 | /* TS5, TCH/H0, V3 (AMR codec) */ |
| 8385 | pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))); |
| 8386 | pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */)); |
| 8387 | vc_conn := f_start_handler(refers(f_TC_speech_osmux), pars); |
| 8388 | vc_conn.done; |
| 8389 | |
| 8390 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8391 | } |
| 8392 | testcase TC_speech_osmux_tchh() runs on test_CT { |
| 8393 | var ConnHdlr vc_conn; |
| 8394 | var ConnHdlrPars pars; |
| 8395 | |
| 8396 | f_init(); |
| 8397 | |
| 8398 | /* TS5, TCH/H0, V3 (AMR codec) */ |
| 8399 | pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))); |
| 8400 | pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */)); |
| 8401 | vc_conn := f_start_handler(refers(f_TC_speech_osmux), pars); |
| 8402 | vc_conn.done; |
| 8403 | |
| 8404 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8405 | } |
| 8406 | |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 8407 | private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr { |
| 8408 | var GsmFrameNumber fn; |
| 8409 | var ChannelDescription ch_desc; |
| 8410 | var integer ra := 23; |
| 8411 | |
| 8412 | f_l1_tune(L1CTL); |
| 8413 | RSL.clear; |
| 8414 | |
| 8415 | /* Send RACH request and wait for ChanReq */ |
| 8416 | fn := f_rach_req_wait_chan_rqd(ra); |
| 8417 | |
| 8418 | /* The BSC already sends the Immediate Assignment, before the channel is active. |
| 8419 | * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM |
| 8420 | * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the |
| 8421 | * IMM ASS. So move the IMM ASS even before the Chan Activ.) */ |
| 8422 | if (g_pars.fhp.enabled) { |
| 8423 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8424 | } else { |
| 8425 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8426 | } |
| 8427 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8428 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8429 | |
| 8430 | /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC |
| 8431 | * requests Chan Activ, to make sure the RR IMM ASS is held back. */ |
| 8432 | var L1ctlDlMessage dl; |
| 8433 | var GsmRrMessage rr; |
| 8434 | |
| 8435 | var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn); |
| 8436 | rr_imm_ass.payload.imm_ass.ded_or_tbf := ?; |
| 8437 | rr_imm_ass.payload.imm_ass.pkt_chan_desc := *; |
| 8438 | rr_imm_ass.payload.imm_ass.chan_desc := *; |
| 8439 | |
| 8440 | timer T := 1.0; |
| 8441 | T.start; |
| 8442 | alt { |
| 8443 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 8444 | rr := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 8445 | if (match(rr, rr_imm_ass)) { |
| 8446 | setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately"); |
| 8447 | mtc.stop; |
| 8448 | } else { |
| 8449 | repeat; |
| 8450 | } |
| 8451 | } |
| 8452 | [] L1CTL.receive { repeat; } |
| 8453 | [] T.timeout; |
| 8454 | } |
| 8455 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA)); |
| 8456 | RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)); |
| 8457 | |
| 8458 | /* Now expect the IMM ASS on Um */ |
| 8459 | f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8460 | setverdict(pass); |
| 8461 | |
| 8462 | /* Release the channel */ |
| 8463 | f_rsl_chan_deact(); |
| 8464 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8465 | } |
| 8466 | |
| 8467 | testcase TC_early_immediate_assignment() runs on test_CT { |
| 8468 | var ConnHdlr vc_conn; |
| 8469 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 8470 | f_init(); |
| 8471 | vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars); |
| 8472 | vc_conn.done; |
| 8473 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8474 | } |
| 8475 | |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8476 | private function f_TC_est_dchan(charstring id) runs on ConnHdlr { |
| 8477 | var integer ra := oct2int(f_rnd_ra_cs()); |
| 8478 | var ChannelDescription ch_desc; |
| 8479 | |
| 8480 | /* Tune the MS to BCCH */ |
| 8481 | f_l1_tune(L1CTL); |
| 8482 | |
| 8483 | /* Send RACH request and wait for ChanReq */ |
| 8484 | var GsmFrameNumber fn := f_rach_req_wait_chan_rqd(ra); |
| 8485 | |
| 8486 | /* Activate channel on the BTS side */ |
| 8487 | f_rsl_chan_act(g_pars.chan_mode); |
| 8488 | |
| 8489 | /* Craft channel description (with or without frequency hopping parameters) */ |
| 8490 | if (g_pars.fhp.enabled) { |
| 8491 | ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc)); |
| 8492 | } else { |
| 8493 | ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc)); |
| 8494 | } |
| 8495 | |
| 8496 | /* Send IMM.ASS via CCHAN */ |
| 8497 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map)); |
| 8498 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 8499 | |
| 8500 | /* Receive IMM.ASS on the MS side */ |
| 8501 | var ImmediateAssignment imm_ass := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 8502 | |
| 8503 | /* Match the Channel Description IE in received IMM.ASS */ |
| 8504 | if (not match(imm_ass.chan_desc, ch_desc)) { |
| 8505 | setverdict(fail, "Channel Description IE does not match"); |
| 8506 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8507 | } |
| 8508 | |
| 8509 | /* Tune the MS to a dedicated channel indicated in the IMM.ASS */ |
| 8510 | f_L1CTL_DM_EST_REQ_IA(L1CTL, imm_ass, g_pars.fhp.ma); |
| 8511 | |
| 8512 | /* Expect SACCH frames on Downlink */ |
| 8513 | L1CTL.clear; |
| 8514 | f_exp_sacch(true); |
| 8515 | |
| 8516 | /* We're done, deactivate and release */ |
| 8517 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 8518 | f_rsl_chan_deact(); |
| 8519 | } |
| 8520 | testcase TC_est_dchan() runs on test_CT { |
| 8521 | var ConnHdlr vc_conn; |
| 8522 | var ConnHdlrPars pars; |
| 8523 | |
| 8524 | f_init(); |
| 8525 | |
| 8526 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 8527 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 8528 | vc_conn := f_start_handler(refers(f_TC_est_dchan), pars); |
| 8529 | vc_conn.done; |
| 8530 | } |
| 8531 | |
| 8532 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8533 | } |
| 8534 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8535 | private type record TopTestCase { |
| 8536 | RSL_IE_BS_Power bs_power, |
| 8537 | RSL_IE_OSMO_TopAcchCap top_cap, |
| 8538 | record of TopTestStep steps |
| 8539 | }; |
| 8540 | private type record TopTestStep { |
| 8541 | MeasurementResults meas_res optional, |
| 8542 | GsmRxLev overpower_sacch, |
| 8543 | GsmRxLev overpower_facch |
| 8544 | }; |
| 8545 | |
| 8546 | private function f_rxlev_match(template (present) RslLinkId link_id, |
| 8547 | template (present) GsmRxLev rxlev) |
| 8548 | runs on ConnHdlr { |
| 8549 | var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id); |
| 8550 | if (not match(dl.dl_info.rx_level, rxlev)) { |
| 8551 | setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level, |
| 8552 | " does not match expected RxLev := ", rxlev); |
| 8553 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8554 | } |
| 8555 | } |
| 8556 | |
| 8557 | private function f_TC_acch_overpower(charstring id) runs on ConnHdlr { |
| 8558 | var TopTestCase tc := g_pars.spec.top; |
| 8559 | var GsmRxLev rxlev_dcch; |
| 8560 | var L1ctlDlMessage dl; |
| 8561 | |
| 8562 | /* Wait for Pau ramping to complete */ |
| 8563 | f_sleep(6.0); |
| 8564 | |
| 8565 | f_l1_tune(L1CTL); |
| 8566 | L1CTL.clear; |
| 8567 | RSL.clear; |
| 8568 | |
| 8569 | /* Measure RxLev(BCCH), calculate RxLev(DCCH) */ |
| 8570 | dl := f_L1CTL_rx_data(L1CTL, t_RslChanNr_BCCH(0)); |
| 8571 | rxlev_dcch := dl.dl_info.rx_level - (tc.bs_power.power_level * 2); |
| 8572 | |
| 8573 | log("RxLev(BCCH) := ", dl.dl_info.rx_level); |
| 8574 | log("Expected RxLev(DCCH) := ", rxlev_dcch); |
| 8575 | |
| 8576 | /* Additional IEs for the CHANnel ACTIVation message */ |
| 8577 | var template (value) RSL_IE_List ies := { |
| 8578 | /* Employ BS power control in static mode */ |
| 8579 | t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ |
| 8580 | bs_power := tc.bs_power |
| 8581 | }), |
| 8582 | /* Indicate the given Temporary Overpower capability */ |
| 8583 | t_RSL_IE(RSL_IE_OSMO_TOP_ACCH_CAP, RSL_IE_Body:{ |
| 8584 | top_acch_cap := tc.top_cap |
| 8585 | }) |
| 8586 | }; |
| 8587 | |
| 8588 | /* Establish a dedicated channel */ |
| 8589 | f_est_dchan(more_ies := valueof(ies)); |
| 8590 | |
| 8591 | /* Give it some time to stabilize */ |
| 8592 | f_sleep(0.480 * 2.0); |
| 8593 | L1CTL.clear; |
| 8594 | RSL.clear; |
| 8595 | |
| 8596 | for (var integer i := 0; i < lengthof(tc.steps); i := i + 1) { |
| 8597 | var TopTestStep step := tc.steps[i]; |
| 8598 | var GsmRxLev rxlev_facch := rxlev_dcch + step.overpower_facch; |
| 8599 | var GsmRxLev rxlev_sacch := rxlev_dcch + step.overpower_sacch; |
| 8600 | |
| 8601 | log("Executing step[", i, "] := ", step); |
| 8602 | |
| 8603 | /* Send RR Measurement Report (if present) */ |
| 8604 | if (ispresent(step.meas_res)) { |
| 8605 | f_transceive_meas_rep(step.meas_res); |
| 8606 | f_sleep(0.480 * 2.0); |
| 8607 | L1CTL.clear; |
| 8608 | } |
| 8609 | |
| 8610 | /* Check RxLev on both FACCH and SACCH */ |
| 8611 | f_rxlev_match(tr_RslLinkID_DCCH(?), rxlev_facch); |
| 8612 | f_rxlev_match(tr_RslLinkID_SACCH(?), rxlev_sacch); |
| 8613 | |
| 8614 | setverdict(pass); |
| 8615 | } |
| 8616 | } |
| 8617 | testcase TC_acch_overpower_rxqual_thresh() runs on test_CT { |
| 8618 | var ConnHdlrPars pars; |
| 8619 | var ConnHdlr vc_conn; |
| 8620 | |
| 8621 | f_init(); |
| 8622 | |
| 8623 | /* Verify lower and upper RxQual thresholds */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8624 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8625 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8626 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8627 | steps := { |
| 8628 | /* Channel established, no overpower */ |
| 8629 | { meas_res := omit, |
| 8630 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8631 | |
| 8632 | /* Worst possible RxQual value, overpower of 4dB */ |
| 8633 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8634 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8635 | /* Worst possible RxQual value, disabling overpower */ |
| 8636 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8637 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8638 | |
| 8639 | /* Lower threshold not reached, no overpower */ |
| 8640 | { meas_res := ts_MeasurementResults(rxq_f := 1), |
| 8641 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8642 | /* Lower threshold not reached, no overpower */ |
| 8643 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8644 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8645 | /* Lower threshold reached, overpower of 4dB */ |
| 8646 | { meas_res := ts_MeasurementResults(rxq_f := 4), |
| 8647 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8648 | /* Upper threshold not reached, keeping overpower */ |
| 8649 | { meas_res := ts_MeasurementResults(rxq_f := 3), |
| 8650 | overpower_sacch := 4, overpower_facch := 4 }, |
| 8651 | /* Upper threshold reached, disabling overpower */ |
| 8652 | { meas_res := ts_MeasurementResults(rxq_f := 2), |
| 8653 | overpower_sacch := 0, overpower_facch := 0 } |
| 8654 | } |
| 8655 | }; |
| 8656 | |
| 8657 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8658 | spec := { top := top }, trx_nr := 1)); |
| 8659 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8660 | vc_conn.done; |
| 8661 | |
| 8662 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8663 | } |
| 8664 | testcase TC_acch_overpower_rxqual_thresh_dtx() runs on test_CT { |
| 8665 | var ConnHdlrPars pars; |
| 8666 | var ConnHdlr vc_conn; |
| 8667 | |
| 8668 | f_init(); |
| 8669 | |
| 8670 | /* Verify handling of FULL and SUB values */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8671 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8672 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8673 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */ |
| 8674 | steps := { |
| 8675 | /* Channel established, no overpower */ |
| 8676 | { meas_res := omit, |
| 8677 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8678 | |
| 8679 | /* Invalid measurement results, no overpower */ |
| 8680 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8681 | rxq_s := 7, |
| 8682 | valid := false), |
| 8683 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8684 | |
| 8685 | /* DTXu was in use, no overpower */ |
| 8686 | { meas_res := ts_MeasurementResults(rxq_f := 7, |
| 8687 | rxq_s := 0, |
| 8688 | dtx_used := true), |
| 8689 | overpower_sacch := 0, overpower_facch := 0 }, |
| 8690 | /* DTXu was in use, overpower of 4 dB */ |
| 8691 | { meas_res := ts_MeasurementResults(rxq_f := 0, |
| 8692 | rxq_s := 7, |
| 8693 | dtx_used := true), |
| 8694 | overpower_sacch := 4, overpower_facch := 4 } |
| 8695 | } |
| 8696 | }; |
| 8697 | |
| 8698 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8699 | spec := { top := top }, trx_nr := 1)); |
| 8700 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8701 | vc_conn.done; |
| 8702 | |
| 8703 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8704 | } |
| 8705 | testcase TC_acch_overpower_always_on_facch() runs on test_CT { |
| 8706 | var ConnHdlrPars pars; |
| 8707 | var ConnHdlr vc_conn; |
| 8708 | |
| 8709 | f_init(); |
| 8710 | |
| 8711 | /* Overpower is always on, SACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8712 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8713 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8714 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8715 | rxqual := 0, /* always on */ |
| 8716 | sacch_enable := false), |
| 8717 | steps := { |
| 8718 | /* Channel established, FACCH overpower */ |
| 8719 | { meas_res := omit, |
| 8720 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8721 | /* MS indicates good RxQual, no difference */ |
| 8722 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8723 | overpower_sacch := 0, overpower_facch := 4 }, |
| 8724 | /* MS indicates bad RxQual, no difference */ |
| 8725 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8726 | overpower_sacch := 0, overpower_facch := 4 } |
| 8727 | } |
| 8728 | }; |
| 8729 | |
| 8730 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8731 | spec := { top := top }, trx_nr := 1)); |
| 8732 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8733 | vc_conn.done; |
| 8734 | |
| 8735 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8736 | } |
| 8737 | testcase TC_acch_overpower_always_on_sacch() runs on test_CT { |
| 8738 | var ConnHdlrPars pars; |
| 8739 | var ConnHdlr vc_conn; |
| 8740 | |
| 8741 | f_init(); |
| 8742 | |
| 8743 | /* Overpower is always on, FACCH disabled */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8744 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8745 | bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */ |
| 8746 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8747 | rxqual := 0, /* always on */ |
| 8748 | facch_enable := false), |
| 8749 | steps := { |
| 8750 | /* Channel established, SACCH overpower */ |
| 8751 | { meas_res := omit, |
| 8752 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8753 | /* MS indicates good RxQual, no difference */ |
| 8754 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8755 | overpower_sacch := 4, overpower_facch := 0 }, |
| 8756 | /* MS indicates bad RxQual, no difference */ |
| 8757 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8758 | overpower_sacch := 4, overpower_facch := 0 } |
| 8759 | } |
| 8760 | }; |
| 8761 | |
| 8762 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8763 | spec := { top := top }, trx_nr := 1)); |
| 8764 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8765 | vc_conn.done; |
| 8766 | |
| 8767 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8768 | } |
| 8769 | testcase TC_acch_overpower_limit() runs on test_CT { |
| 8770 | var ConnHdlrPars pars; |
| 8771 | var ConnHdlr vc_conn; |
| 8772 | |
| 8773 | f_init(); |
| 8774 | |
| 8775 | /* Overpower higher than current power reduction level (2dB) */ |
Vadim Yanitskiy | d12db41 | 2022-03-12 18:05:18 +0300 | [diff] [blame] | 8776 | var template (value) TopTestCase top := { |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 8777 | bs_power := ts_RSL_IE_BS_Power(1), /* 1 x 2dB = 2dB */ |
| 8778 | top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */ |
| 8779 | rxqual := 0 /* always on */), |
| 8780 | steps := { |
| 8781 | /* Channel established, ACCH overpower of 2dB */ |
| 8782 | { meas_res := omit, |
| 8783 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8784 | /* MS indicates good RxQual, no difference */ |
| 8785 | { meas_res := ts_MeasurementResults(rxq_f := 0), |
| 8786 | overpower_sacch := 2, overpower_facch := 2 }, |
| 8787 | /* MS indicates bad RxQual, no difference */ |
| 8788 | { meas_res := ts_MeasurementResults(rxq_f := 7), |
| 8789 | overpower_sacch := 2, overpower_facch := 2 } |
| 8790 | } |
| 8791 | }; |
| 8792 | |
| 8793 | pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, |
| 8794 | spec := { top := top }, trx_nr := 1)); |
| 8795 | vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars); |
| 8796 | vc_conn.done; |
| 8797 | |
| 8798 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 8799 | } |
| 8800 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8801 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 8802 | /* protocol error as per 44.006 */ |
| 8803 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 8804 | /* repetition of SABM or DISC N200 times without ACK */ |
| 8805 | /* receptiom of SABM in multi-frame established state */ |
| 8806 | |
| 8807 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8808 | /* TODO Areas: |
| 8809 | |
| 8810 | * channel activation |
| 8811 | ** with BS_Power / MS_Power, bypassing power control loop |
| 8812 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8813 | ** with timing advance from initial activation on |
| 8814 | * mode modify |
| 8815 | ** encryption |
| 8816 | ** multirate |
| 8817 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8818 | ** unsupported algorithm |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8819 | * BS Power Control |
| 8820 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8821 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8822 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8823 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8824 | ** DATA_IND from BTS->PCU |
| 8825 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8826 | |
| 8827 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8828 | |
| 8829 | control { |
Vadim Yanitskiy | d0eb659 | 2021-10-08 01:19:29 +0600 | [diff] [blame] | 8830 | execute( TC_est_dchan() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8831 | execute( TC_chan_act_stress() ); |
| 8832 | execute( TC_chan_act_react() ); |
| 8833 | execute( TC_chan_deact_not_active() ); |
| 8834 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 8835 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 8836 | execute( TC_sacch_filling() ); |
| 8837 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 8838 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 8839 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 8840 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 8841 | execute( TC_sacch_chan_act_ho_async() ); |
| 8842 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8843 | execute( TC_rach_content() ); |
Philipp Maier | 16ade78 | 2020-07-08 21:36:00 +0200 | [diff] [blame] | 8844 | execute( TC_rach_content_emerg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 8845 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 8846 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 8847 | execute( TC_ho_rach() ); |
Vadim Yanitskiy | 1ab332f | 2022-03-12 15:31:23 +0300 | [diff] [blame] | 8848 | execute( TC_ho_physical_info() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 8849 | execute( TC_rach_load_idle_thresh0() ); |
| 8850 | execute( TC_rach_load_idle_below_thresh() ); |
| 8851 | execute( TC_rach_load_count() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8852 | execute( TC_meas_res_speech_tchf() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8853 | execute( TC_meas_res_speech_tchf_facch() ); |
Vadim Yanitskiy | 204b98c | 2020-10-19 14:52:48 +0700 | [diff] [blame] | 8854 | execute( TC_meas_res_speech_tchh() ); |
Philipp Maier | 149c392 | 2020-10-22 17:29:36 +0200 | [diff] [blame] | 8855 | execute( TC_meas_res_speech_tchh_facch() ); |
Vadim Yanitskiy | 780bc07 | 2020-10-20 02:16:01 +0700 | [diff] [blame] | 8856 | execute( TC_meas_res_speech_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8857 | execute( TC_meas_res_sign_tchf() ); |
| 8858 | execute( TC_meas_res_sign_tchh() ); |
| 8859 | execute( TC_meas_res_sign_sdcch4() ); |
| 8860 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 8861 | execute( TC_meas_res_sign_tchh_toa256() ); |
Vadim Yanitskiy | 8f6eae0 | 2021-10-26 02:49:21 +0300 | [diff] [blame] | 8862 | execute( TC_meas_res_speech_tchf_sapi3() ); |
| 8863 | execute( TC_meas_res_speech_tchh_sapi3() ); |
Pau Espin Pedrol | a2e079c | 2020-06-03 17:31:04 +0200 | [diff] [blame] | 8864 | execute( TC_tx_power_start_ramp_up_bcch() ); |
Pau Espin Pedrol | b6985f9 | 2020-06-23 14:01:02 +0200 | [diff] [blame] | 8865 | execute( TC_tx_power_start_ramp_down_bcch() ); |
Pau Espin Pedrol | 45fe5e0 | 2020-06-23 19:00:00 +0200 | [diff] [blame] | 8866 | execute( TC_tx_power_ramp_adm_state_change() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 8867 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 8868 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 8869 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 8870 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 8871 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 8872 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 8873 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 8874 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 8875 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 8876 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 8877 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 8878 | execute( TC_rsl_modify_encr() ); |
Vadim Yanitskiy | 98c4a1a | 2021-06-04 18:46:06 +0200 | [diff] [blame] | 8879 | execute( TC_rsl_rf_resource_ind() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 8880 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 8881 | execute( TC_paging_imsi_80percent() ); |
| 8882 | execute( TC_paging_tmsi_80percent() ); |
| 8883 | execute( TC_paging_imsi_200percent() ); |
| 8884 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 8885 | execute( TC_rsl_protocol_error() ); |
| 8886 | execute( TC_rsl_mand_ie_error() ); |
| 8887 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8888 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 8889 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 8890 | execute( TC_si_sched_2bis() ); |
| 8891 | execute( TC_si_sched_2ter() ); |
| 8892 | execute( TC_si_sched_2ter_2bis() ); |
| 8893 | execute( TC_si_sched_2quater() ); |
| 8894 | execute( TC_si_sched_13() ); |
| 8895 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 8896 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 8897 | execute( TC_ipa_crcx_twice_not_active() ); |
| 8898 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 8899 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 8900 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Vadim Yanitskiy | 866afc2 | 2022-05-01 16:08:30 +0300 | [diff] [blame] | 8901 | execute( TC_ipa_crcx_ack_addr() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 8902 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8903 | if (mp_pcu_socket != "") { |
Philipp Maier | ca05827 | 2021-06-23 10:35:23 +0200 | [diff] [blame] | 8904 | execute( TC_paging_imsi_200percent_with_ps() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8905 | execute( TC_pcu_act_req() ); |
| 8906 | execute( TC_pcu_act_req_wrong_ts() ); |
| 8907 | execute( TC_pcu_act_req_wrong_bts() ); |
| 8908 | execute( TC_pcu_act_req_wrong_trx() ); |
| 8909 | execute( TC_pcu_deact_req() ); |
| 8910 | execute( TC_pcu_deact_req_wrong_ts() ); |
Philipp Maier | 94c0848 | 2021-02-01 17:36:05 +0100 | [diff] [blame] | 8911 | execute( TC_pcu_ver_si1() ); |
| 8912 | execute( TC_pcu_ver_si3() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8913 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8914 | if (mp_l1_supports_gprs) { |
| 8915 | execute( TC_pcu_data_req_pdtch() ); |
| 8916 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 8917 | execute( TC_pcu_data_req_wrong_bts() ); |
| 8918 | execute( TC_pcu_data_req_wrong_trx() ); |
| 8919 | execute( TC_pcu_data_req_wrong_ts() ); |
| 8920 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 8921 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 8922 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8923 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 8924 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8925 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 8926 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 8927 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 8928 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8929 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 8930 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 8931 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 8932 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 8933 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 8934 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 8935 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8936 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8937 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8938 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8939 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 8940 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 8941 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 8942 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 8943 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 8944 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 8945 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 8946 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Vadim Yanitskiy | 1da1fef | 2021-03-23 04:28:18 +0100 | [diff] [blame] | 8947 | execute( TC_pcu_info_ind_fh_params() ); |
| 8948 | execute( TC_pcu_socket_nsvc_ipv4() ); |
| 8949 | execute( TC_pcu_socket_nsvc_ipv6() ); |
Vadim Yanitskiy | e2a50a8 | 2021-03-23 05:58:02 +0100 | [diff] [blame] | 8950 | execute( TC_pcu_socket_two_nsvc() ); |
Vadim Yanitskiy | 83852c1 | 2021-06-18 16:18:29 +0200 | [diff] [blame] | 8951 | execute( TC_pcu_interf_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 8952 | } else { |
| 8953 | log("PCU socket path not available, skipping PCU tests"); |
| 8954 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8955 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8956 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 8957 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 8958 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Pau Espin Pedrol | 8e57ac1 | 2021-06-29 17:04:24 +0200 | [diff] [blame] | 8959 | execute( TC_dyn_osmo_pdch_sdcch8_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 8960 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 8961 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 8962 | |
| 8963 | execute( TC_rll_est_ind() ); |
| 8964 | execute( TC_rll_est_req_DCCH_3() ); |
| 8965 | execute( TC_rll_est_req_ACCH_3() ); |
| 8966 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 8967 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 8968 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 8969 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 8970 | execute( TC_rll_rel_req() ); |
| 8971 | execute( TC_rll_unit_data_req_DCCH() ); |
| 8972 | execute( TC_rll_unit_data_req_ACCH() ); |
| 8973 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 8974 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8975 | |
| 8976 | execute( TC_chan_act_a51() ); |
| 8977 | execute( TC_chan_act_a52() ); |
| 8978 | execute( TC_chan_act_a53() ); |
Vadim Yanitskiy | 8b4e046 | 2022-08-27 19:18:17 +0700 | [diff] [blame] | 8979 | execute( TC_chan_act_a54() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8980 | execute( TC_encr_cmd_a51() ); |
| 8981 | execute( TC_encr_cmd_a52() ); |
| 8982 | execute( TC_encr_cmd_a53() ); |
Vadim Yanitskiy | 8b4e046 | 2022-08-27 19:18:17 +0700 | [diff] [blame] | 8983 | execute( TC_encr_cmd_a54() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8984 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 8985 | execute( TC_err_rep_wrong_mdisc() ); |
| 8986 | execute( TC_err_rep_wrong_msg_type() ); |
| 8987 | execute( TC_err_rep_wrong_sequence() ); |
| 8988 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 8989 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 8990 | |
| 8991 | execute( TC_tch_sign_l2_fill_frame() ); |
| 8992 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 8993 | |
| 8994 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 8995 | execute( TC_chopped_ipa_payload() ); |
Vadim Yanitskiy | c7ef030 | 2020-10-18 19:24:18 +0700 | [diff] [blame] | 8996 | |
| 8997 | execute( TC_ms_pwr_ctrl_constant() ); |
Vadim Yanitskiy | 652e60e | 2020-10-18 19:43:27 +0700 | [diff] [blame] | 8998 | execute( TC_ms_pwr_ctrl_pf_ewma() ); |
Vadim Yanitskiy | 5fa8561 | 2020-10-21 03:46:18 +0700 | [diff] [blame] | 8999 | |
| 9000 | execute( TC_speech_no_rtp_tchf() ); |
| 9001 | execute( TC_speech_no_rtp_tchh() ); |
Vadim Yanitskiy | 1868488 | 2021-07-04 04:15:58 +0200 | [diff] [blame] | 9002 | execute( TC_speech_rtp_tchf() ); |
| 9003 | execute( TC_speech_rtp_tchh() ); |
Pau Espin Pedrol | 39bfa02 | 2022-08-12 14:56:12 +0200 | [diff] [blame] | 9004 | execute( TC_speech_osmux_tchf() ); |
| 9005 | execute( TC_speech_osmux_tchh() ); |
Neels Hofmeyr | af9d6ae | 2021-08-15 23:18:47 +0200 | [diff] [blame] | 9006 | |
| 9007 | execute( TC_early_immediate_assignment() ); |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 9008 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 9009 | execute( TC_acch_overpower_rxqual_thresh() ); |
| 9010 | execute( TC_acch_overpower_rxqual_thresh_dtx() ); |
| 9011 | execute( TC_acch_overpower_always_on_facch() ); |
| 9012 | execute( TC_acch_overpower_always_on_sacch() ); |
| 9013 | execute( TC_acch_overpower_limit() ); |
| 9014 | |
Vadim Yanitskiy | 46f1992 | 2021-10-06 02:36:22 +0600 | [diff] [blame] | 9015 | /* BEWARE: these test cases can potentially break the IUT or cause |
| 9016 | * weird/unexpected behavior. Ensure that they are executed last. */ |
| 9017 | execute( TC_dyn_osmo_pdch_tchh_race_act() ); |
| 9018 | execute( TC_dyn_osmo_pdch_sdcch8_race_act() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 9019 | } |
| 9020 | |
| 9021 | |
| 9022 | } |