blob: 68e5cf16b67706e56c56e56e791001095becd90f [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
Harald Welte14906952019-05-27 09:19:49 +02003/* Integration Tests for OsmoBTS
Harald Welte34b5a952019-05-27 11:54:11 +02004 * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org>
Harald Welte14906952019-05-27 09:19:49 +02005 * 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 Welte34b5a952019-05-27 11:54:11 +020011 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
Harald Welte14906952019-05-27 09:19:49 +020013 * 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 Willmann0fcc4d32018-10-23 20:32:19 +020026import from Misc_Helpers all;
Harald Welte70767382018-02-21 12:16:40 +010027import from General_Types all;
28import from GSM_Types all;
29import from GSM_RR_Types all;
30import from Osmocom_Types all;
31import from GSM_Types all;
Vadim Yanitskiy5d2cf442020-05-02 16:49:17 +070032import from GSM_RestOctets all;
Harald Welte82ccef72018-02-25 16:17:33 +010033import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010034import from L1CTL_PortType all;
35import from L1CTL_Types all;
36import from LAPDm_Types all;
Harald Weltead033dc2019-05-25 17:28:16 +020037import from LAPDm_RAW_PT all;
Alexander Couzens5283f552020-07-28 15:39:04 +020038import from Native_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010039import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020040import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010041
42import from RSL_Types all;
Vadim Yanitskiy18684882021-07-04 04:15:58 +020043import from RTP_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010044import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010045import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020046import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010047import from RSL_Emulation all;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +020048import from RTP_Emulation all;
Harald Welte70767382018-02-21 12:16:40 +010049
Pau Espin Pedrol091c5302022-09-02 18:11:12 +020050import from AMR_Types all;
51
Harald Welte70767382018-02-21 12:16:40 +010052import from IPL4asp_Types all;
53import from TRXC_Types all;
54import from TRXC_CodecPort all;
55import from TRXC_CodecPort_CtrlFunct all;
56
Harald Welte883340c2018-02-28 18:59:29 +010057import from PCUIF_Types all;
58import from PCUIF_CodecPort all;
Harald Weltea2e0e942019-05-27 18:12:53 +020059import from UD_Types all;
Harald Welte883340c2018-02-28 18:59:29 +010060
Harald Welte7484fc42018-02-24 14:09:45 +010061import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010062import from MobileL3_RRM_Types all;
63import from MobileL3_Types all;
64import from L3_Templates all;
Harald Welteeaa9a862019-05-26 23:01:08 +020065import from L3_Common all;
66import from MobileL3_GMM_SM_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010067
Harald Welte8da48242018-02-27 20:41:32 +010068import from Osmocom_VTY_Functions all;
69import from TELNETasp_PortType all;
Harald Welte2f2b2b72019-05-31 22:24:57 +020070import from BTS_Tests_LAPDm all;
Harald Welte8da48242018-02-27 20:41:32 +010071
Harald Welte505cf9b2018-09-15 17:47:23 +030072friend module BTS_Tests_SMSCB;
Vadim Yanitskiy73878132021-05-05 02:22:45 +020073friend module BTS_Tests_VAMOS;
Harald Weltead033dc2019-05-25 17:28:16 +020074friend module BTS_Tests_virtphy;
Harald Welte2f2b2b72019-05-31 22:24:57 +020075friend module BTS_Tests_LAPDm;
Pau Espin Pedrol5a012ee2020-02-06 19:33:22 +010076friend module BTS_Tests_perf;
Pau Espin Pedrol65d712e2021-06-25 13:55:38 +020077friend module BTS_Tests_OML;
Harald Welte505cf9b2018-09-15 17:47:23 +030078
Harald Welte70767382018-02-21 12:16:40 +010079/* The tests assume a BTS with the following timeslot configuration:
80 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020081 * TS1 : TCH/F
82 * TS2 : TCH/F
83 * TS3 : TCH/F_PDCH (IPA Style)
84 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010085 * TS5 : TCH/H
86 * TS6 : SDCCH/8
87 * TS7 : PDCH
88 */
89
90modulepar {
91 charstring mp_rsl_ip := "127.0.0.2";
92 integer mp_rsl_port := 3003;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070093 charstring mp_bts_trxc_ip := "127.0.0.1";
94 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010095 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020096 charstring mp_ctrl_ip := "127.0.0.1";
97 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020098 charstring mp_bsc_ctrl_ip := "127.0.0.1";
99 integer mp_bsc_ctrl_port := 4249;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +0200100 charstring mp_rtpem_bind_ip := "127.0.0.1";
101 integer mp_rtpem_bind_port := 6766;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200102 integer mp_tolerance_rxqual := 1;
103 integer mp_tolerance_rxlev := 3;
104 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200105 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200106 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200107 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +0200108 integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */
109 integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200110 integer mp_ms_actual_ta_exp := 0;
111 integer mp_timing_offset_256syms_exp := 512;
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +0700112 integer mp_uplink_power_target := -75;
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +0700113 integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100114 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +0200115 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200116 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200117 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
118 boolean mp_l1_supports_gprs := false;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700119 /* how many transceivers do we expect to connect */
120 integer mp_transceiver_num := 1;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700121 /* frequency hopping status */
122 boolean mp_freq_hop_enabled := false;
123 /* frequency hopping parameters */
124 FreqHopConfig mp_fh_config;
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700125 /* configuration for each individual transceiver */
126 TrxPars mp_trx_pars; /* see BTS_Tests.default */
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700127 /* default Training Sequence Code */
128 GsmTsc mp_tsc_def := 7;
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +0200129 /* Default interference boundaries in osmo-bsc (in dBm):
130 * 0(-85) X1(-91) X2(-97) X3(-103) X4(-109) X5(-115)
131 * Default interference level reported by fake_trx.py:
132 * 0: -109 >= -85 dBm (no)
133 * X1: -109 >= -91 dBm (no)
134 * X2: -109 >= -97 dBm (no)
135 * X3: -109 >= -103 dBm (no)
136 * X4: -109 >= -109 dBm (yes)
137 * X5: -109 >= -115 dBm (no)
138 * So all channels should be in band 4. */
139 uint3_t mp_interf_band := 4;
Vadim Yanitskiy1ab332f2022-03-12 15:31:23 +0300140 /* T3105 timer (see 3GPP TS 44.018, section 11.1.2) */
141 integer mp_ho_t3105_ms := 100;
142 /* Ny1 counter (see 3GPP TS 44.018, section 11.1.3) */
143 integer mp_ho_ny1 := 10;
Harald Welte70767382018-02-21 12:16:40 +0100144}
145
Harald Welte629cc6b2018-03-11 17:19:05 +0100146type record of RslChannelNr ChannelNrs;
147
Harald Welte70767382018-02-21 12:16:40 +0100148type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100149 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100150 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100151 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100152 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100153 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100154 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100155
156 /* L1CTL port (for classic tests) */
157 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100158
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700159 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700160 port TRXC_CODEC_PT BTS_TRXC;
161 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100162
Harald Weltef50e3ae2018-09-10 10:27:56 +0200163 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100164 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200165 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100166
Harald Welte883340c2018-02-28 18:59:29 +0100167 /* PCU Interface of BTS */
168 port PCUIF_CODEC_PT PCU;
169 var integer g_pcu_conn_id;
170 /* Last PCU INFO IND we received */
171 var PCUIF_Message g_pcu_last_info;
172
Harald Welte48494ca2018-02-25 16:59:50 +0100173 /* SI configuration */
174 var SystemInformationConfig si_cfg := {
175 bcch_extended := false,
176 si1_present := false,
177 si2bis_present := false,
178 si2ter_present := false,
179 si2quater_present := false,
180 si7_present := false,
181 si8_present := false,
182 si9_present := false,
183 si13_present := false,
184 si13alt_present := false,
185 si15_present := false,
186 si16_present := false,
187 si17_present := false,
188 si2n_present := false,
189 si21_present := false,
190 si22_present := false
191 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100192
193 /* all logical channels available on the BTS */
194 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100195 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100196}
197
198/* an individual call / channel */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200199type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100200 port L1CTL_PT L1CTL;
201
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700202 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700203 port TRXC_CODEC_PT BTS_TRXC;
204 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100205
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200206 /* port to be initialized optionally to access BSC VTY */
207 port TELNETasp_PT BSCVTY;
208
Harald Welte70767382018-02-21 12:16:40 +0100209 timer g_Tguard;
210 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
211
212 var ConnHdlrPars g_pars;
213 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100214 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200215
216 /* PCU Interface of BTS */
217 port PCUIF_CODEC_PT PCU;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +0200218
219 var RTP_Emulation_CT vc_RTPEM;
220 port RTPEM_CTRL_PT RTPEM_CTRL;
221 port RTPEM_DATA_PT RTPEM_DATA;
Harald Welte70767382018-02-21 12:16:40 +0100222}
223
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700224private function f_init_rsl(charstring id) runs on test_CT {
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700225 var bitstring trx_mask := '00000000'B;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200226 var bitstring rfind_mask := '00000000'B;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700227 var integer trx_count := 0;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200228 var integer rfind_count := 0;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700229 var RSLEm_Event ev;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200230 var ASP_RSL_Unitdata rx_ud;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700231 timer T;
232
Harald Welte70767382018-02-21 12:16:40 +0100233 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
234 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
235
236 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
237 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
238 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
239
240 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
241 vc_RSL.start(RSL_Emulation.main(false));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700242
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700243 /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here.
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700244 * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700245 T.start(mp_ipa_up_timeout);
246 alt {
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700247 /* These events are sent by the RSL_Emulation_CT */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700248 [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev {
249 /* Make sure that all transceivers use unique stream ID */
250 if (trx_mask[enum2int(ev.sid)] == '1'B) {
251 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
252 log2str("Duplicate RSL stream ID (", ev.sid, ")"));
253 }
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700254
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700255 trx_mask[enum2int(ev.sid)] := '1'B;
256 trx_count := trx_count + 1;
257
258 log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected");
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200259 repeat;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700260 }
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200261 /* This message (RF RESource INDication) is sent by the IUT itself */
262 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud {
263 if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) {
264 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
265 log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")"));
266 }
267 if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) {
268 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
269 log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")"));
270 }
271
272 rfind_mask[enum2int(rx_ud.streamId)] := '1'B;
273 rfind_count := rfind_count + 1;
274 log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received");
275 if (rfind_count < mp_transceiver_num) { repeat; }
276 }
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700277 /* osmo-bts may send us CCCH LOAD INDication or whatever else */
278 [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; }
279 [] T.timeout {
280 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
281 "Timeout waiting for RSL bring up");
282 }
283 }
Harald Welte70767382018-02-21 12:16:40 +0100284}
285
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700286friend type record length(1 .. 256) of TrxParsItem TrxPars;
287friend type record TrxParsItem {
288 GsmArfcn arfcn,
289 TrxTsPars ts
290};
291
292friend type record length(8) of TrxTsParsItem TrxTsPars;
293friend type record TrxTsParsItem {
294 PchanConfig config
295};
296
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700297friend type record FreqHopPars {
298 /* Whether frequency hopping is in use */
299 boolean enabled,
300 /* Mobile Allocation Index Offset / Hopping Sequence Number */
301 MaioHsn maio_hsn,
302 /* MA bitmap to be indicated in RR Immediate Assignment */
303 MobileAllocationLV ma_map,
304 /* The actual Mobile Allocation (ARFCN list) to be used */
305 L1ctlMA ma
306};
307
Harald Welte70767382018-02-21 12:16:40 +0100308type record ConnHdlrPars {
Vadim Yanitskiyf54db112020-11-16 18:00:15 +0700309 uint8_t trx_nr,
Harald Welte70767382018-02-21 12:16:40 +0100310 RslChannelNr chan_nr,
311 RSL_IE_ChannelMode chan_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200312 RSL_IE_MultirateCfg mr_conf optional,
Harald Welte70767382018-02-21 12:16:40 +0100313 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100314 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200315 TestSpecUnion spec optional,
Eric Wild61edb7e2019-06-03 12:38:31 +0200316 RSL_IE_EncryptionInfo encr optional,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700317 BtsBand bts0_band optional,
318
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700319 /* Training Sequence Code */
320 GsmTsc tsc,
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700321 /* Frequency hopping parameters */
322 FreqHopPars fhp
323};
Harald Welte0472ab42018-03-12 15:02:26 +0100324
325/* Test-specific parameters */
Vadim Yanitskiy7368a102021-06-01 01:25:08 +0200326friend type union TestSpecUnion {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +0300327 RllTestCase rll,
328 TopTestCase top
Harald Welte70767382018-02-21 12:16:40 +0100329}
330
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700331private template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100332 max_retrans := RACH_MAX_RETRANS_7,
333 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100334 cell_barr_access := false,
335 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100336 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100337};
338
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700339private template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100340 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200341 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100342 acs := '0'B,
343 neci := true,
344 rxlev_access_min := 0
345}
346
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700347private template (value) LocationAreaIdentification ts_LAI_default := {
Harald Weltef10153f2018-02-25 16:34:05 +0100348 mcc_mnc := '262F42'H,
349 lac := 42
350}
351
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700352private template (value) GPRSIndicator ts_GPRSIndicator_def := {
353 ra_colour := 0,
354 si13_pos := '0'B
355}
356
357private template (value) SI3RestOctets ts_SI3RestOctets_def
358modifies ts_SI3RestOctets := {
359 gprs_ind := {
360 presence := CSN1_H,
361 ind := ts_GPRSIndicator_def
362 }
363}
364
365private template (value) SI4RestOctets ts_SI4RestOctets_def
366modifies ts_SI4RestOctets := {
367 gprs_ind := {
Vadim Yanitskiyab5363f2020-05-05 00:30:22 +0700368 presence := CSN1_H,
369 ind := ts_GPRSIndicator_def
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700370 }
371}
372
Harald Welte7484fc42018-02-24 14:09:45 +0100373/* Default SYSTEM INFORMATION 3 */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700374private template (value) SystemInformation ts_SI3_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100375 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100376 payload := {
377 si3 := {
378 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100379 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100380 ctrl_chan_desc := {
381 msc_r99 := true,
382 att := true,
383 bs_ag_blks_res := 1,
384 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100385 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100386 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
387 spare := '00'B,
388 bs_pa_mfrms := 0, /* 2 multiframes */
389 t3212 := 1 /* 6 minutes */
390 },
Harald Welte82ccef72018-02-25 16:17:33 +0100391 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100392 dn_ind := false,
393 pwrc := false,
394 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100395 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100396 },
Harald Weltef10153f2018-02-25 16:34:05 +0100397 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100398 rach_control := ts_RachCtrl_default,
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +0200399 rest_octets := valueof(ts_SI3RestOctets_def)
Harald Welte7484fc42018-02-24 14:09:45 +0100400 }
401 }
402}
Harald Welte70767382018-02-21 12:16:40 +0100403
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700404private template (value) SystemInformation ts_SI2_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100405 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100406 payload := {
407 si2 := {
408 bcch_freq_list := '00000000000000000000000000000000'O,
409 ncc_permitted := '11111111'B,
410 rach_control := ts_RachCtrl_default
411 }
412 }
413}
414
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700415private template (value) SystemInformation ts_SI4_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100416 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100417 payload := {
418 si4 := {
419 lai := ts_LAI_default,
420 cell_sel_par := ts_CellSelPar_default,
421 rach_control := ts_RachCtrl_default,
422 cbch_chan_desc := omit,
423 cbch_mobile_alloc := omit,
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +0200424 rest_octets := valueof(ts_SI4RestOctets_def)
Harald Weltef10153f2018-02-25 16:34:05 +0100425 }
426 }
427}
428
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700429private function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
Harald Weltef10153f2018-02-25 16:34:05 +0100430runs on test_CT {
431 log("Setting ", rsl_si_type, ": ", si_enc);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +0700432 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
Harald Weltef10153f2018-02-25 16:34:05 +0100433}
434
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700435private function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
Harald Weltef10153f2018-02-25 16:34:05 +0100436runs on test_CT {
437 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
438 log("Setting ", rsl_si_type, ": ", si_dec);
439 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
440}
441
Harald Welte505cf9b2018-09-15 17:47:23 +0300442friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100443 map(self:BTSVTY, system:BTSVTY);
444 f_vty_set_prompts(BTSVTY);
445 f_vty_transceive(BTSVTY, "enable");
446}
447
Harald Welte505cf9b2018-09-15 17:47:23 +0300448friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200449 map(self:BSCVTY, system:BSCVTY);
450 f_vty_set_prompts(BSCVTY, "OsmoBSC");
451 f_vty_transceive(BSCVTY, "enable");
452}
453
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200454friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr {
455 map(self:BSCVTY, system:BSCVTY);
456 f_vty_set_prompts(BSCVTY, "OsmoBSC");
457 f_vty_transceive(BSCVTY, "enable");
458}
459
Harald Welte883340c2018-02-28 18:59:29 +0100460/* PCU socket may at any time receive a new INFO.ind */
Pau Espin Pedrol65d712e2021-06-25 13:55:38 +0200461friend altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
Harald Weltef26de0b2018-04-04 20:28:05 +0200462 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100463 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200464 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
465 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100466 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200467 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200468 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100469 }
470}
471
Harald Weltef26de0b2018-04-04 20:28:05 +0200472private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
473 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100474 timer T := 2.0;
475 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100476 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200477 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100478 return;
479 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200480 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100481
482 T.start;
483 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200484 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100485 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200486 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100487 }
488 }
489}
490
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700491private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
492 out integer trxc_conn_id) {
493 var Result res;
494
495 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
496 "", -1, -1, { udp := {} }, {});
497 if (not ispresent(res.connId)) {
498 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
499 "Could not connect to the control (TRXC) interface " &
500 "of FakeTRX, check your configuration");
501 }
502 trxc_conn_id := res.connId;
503}
504
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +0100505/* global init function (without PCUIF connection) */
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700506friend function f_init(uint8_t trx_nr := 0)
507runs on test_CT
508{
509 var TrxParsItem trx_pars := mp_trx_pars[trx_nr];
Harald Welte10474062019-05-30 16:48:17 +0200510 var charstring id := testcasename();
Harald Welte629cc6b2018-03-11 17:19:05 +0100511
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700512 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653.
513 * TODO: also generate this list dynamically from module parameters. */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700514 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200515 g_AllChanTypes := {
516 /* TS 1..4: TCH/F */
517 valueof(ts_RslChanNr_Bm(1)),
518 /* TS 5: TCH/H */
519 valueof(ts_RslChanNr_Lm(5,1)),
520 /* TS 0: SDCCH/4 */
521 valueof(ts_RslChanNr_SDCCH4(0,2)),
522 /* TS 6: SDCCH/8 */
523 valueof(ts_RslChanNr_SDCCH8(6,4))
524 };
525 } else {
526 g_AllChanTypes := {
527 /* TS 1..4: TCH/F */
528 valueof(ts_RslChanNr_Bm(1)),
529 /* TS 0: SDCCH/4 */
530 valueof(ts_RslChanNr_SDCCH4(0,2)),
531 /* TS 6: SDCCH/8 */
532 valueof(ts_RslChanNr_SDCCH8(6,4))
533 };
534 }
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700535
536 g_AllChannels := { };
537
538 /* Generate list of all logical channels from module parameters */
539 for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) {
540 select (trx_pars.ts[tn].config) {
541 case (GSM_PCHAN_CCCH_SDCCH4) {
542 g_AllChannels := g_AllChannels &
543 { valueof(ts_RslChanNr_SDCCH4(tn, 0)),
544 valueof(ts_RslChanNr_SDCCH4(tn, 1)),
545 valueof(ts_RslChanNr_SDCCH4(tn, 2)),
546 valueof(ts_RslChanNr_SDCCH4(tn, 3)) };
547 }
548 case (GSM_PCHAN_SDCCH8) {
549 g_AllChannels := g_AllChannels &
550 { valueof(ts_RslChanNr_SDCCH8(tn, 0)),
551 valueof(ts_RslChanNr_SDCCH8(tn, 1)),
552 valueof(ts_RslChanNr_SDCCH8(tn, 2)),
553 valueof(ts_RslChanNr_SDCCH8(tn, 3)),
554 valueof(ts_RslChanNr_SDCCH8(tn, 4)),
555 valueof(ts_RslChanNr_SDCCH8(tn, 5)),
556 valueof(ts_RslChanNr_SDCCH8(tn, 6)),
557 valueof(ts_RslChanNr_SDCCH8(tn, 7)) };
558 }
559 case (GSM_PCHAN_TCHH_TCHF_PDCH) {
560 g_AllChannels := g_AllChannels &
561 { valueof(ts_RslChanNr_Lm(tn, 0)),
562 valueof(ts_RslChanNr_Lm(tn, 1)),
563 valueof(ts_RslChanNr_Bm(tn)) };
564 }
565 case (GSM_PCHAN_TCHH) {
566 g_AllChannels := g_AllChannels &
567 { valueof(ts_RslChanNr_Lm(tn, 0)),
568 valueof(ts_RslChanNr_Lm(tn, 1)) };
569 }
570 case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) {
571 g_AllChannels := g_AllChannels &
572 { valueof(ts_RslChanNr_Bm(tn)) };
573 }
574 }
575 }
576
Harald Welte70767382018-02-21 12:16:40 +0100577 f_init_rsl(id);
Harald Welte2d142592018-02-25 13:19:44 +0100578 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100579 f_init_vty(id);
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +0100580 f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100581
582 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100583 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
584 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
585 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
586 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100587
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700588 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100589 var TrxcMessage ret;
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700590
591 /* Init TRXC interface to FakeTRX */
592 map(self:BTS_TRXC, system:BTS_TRXC);
593 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
594
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700595 /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600596 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256));
597 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(-60));
Vadim Yanitskiyde535e02019-07-26 16:29:27 +0700598 /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600599 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(60));
Harald Welte84271622018-03-10 17:21:03 +0100600 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200601
602 /* Wait some extra time to make sure the BTS emits a stable carrier.
603 * (this is only relevant when running the tests with a physical BTS.) */
604 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100605}
606
Harald Welte68e495b2018-02-25 00:05:57 +0100607/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700608friend function f_init_l1ctl() runs on test_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100609 map(self:L1CTL, system:L1CTL);
610 f_connect_reset(L1CTL);
611}
612
Vadim Yanitskiy73878132021-05-05 02:22:45 +0200613friend type function void_fn(charstring id) runs on ConnHdlr;
Harald Welte70767382018-02-21 12:16:40 +0100614
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700615private type record length(8) of FreqHopGroups FreqHopConfig;
616
617private type record of FreqHopGroup FreqHopGroups;
618private type record FreqHopGroup {
619 uint6_t hsn,
620 FreqHopGroupItems trx_maio
621};
622
623private type record of FreqHopGroupItem FreqHopGroupItems;
624private type record FreqHopGroupItem {
625 uint8_t trx_nr,
626 uint6_t maio
627};
628
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700629friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn,
630 uint8_t trx_nr := 0)
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700631{
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700632 var FreqHopGroups groups := mp_fh_config[tn];
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700633 var integer i, j;
634
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700635 fhp.enabled := false;
636
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700637 for (i := 0; i < lengthof(groups); i := i + 1) {
638 var FreqHopGroup g := groups[i];
639 for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
640 var FreqHopGroupItem gi := g.trx_maio[j];
641 if (gi.trx_nr == trx_nr) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700642 fhp.maio_hsn.maio := gi.maio;
643 fhp.maio_hsn.hsn := g.hsn;
644 fhp.enabled := true;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700645 break;
646 }
647 }
648
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700649 if (fhp.enabled) {
Vadim Yanitskiy4fa74252020-08-03 15:51:58 +0700650 /* Prepare the Mobile Allocation bitmask (length & padding) */
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700651 fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */
652 fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B);
653 fhp.ma := { }; /* to be composed below */
Vadim Yanitskiy4fa74252020-08-03 15:51:58 +0700654
655 /* Compose the actual Mobile Allocation and the bitmask */
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700656 for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
657 var FreqHopGroupItem gi := g.trx_maio[j];
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700658 var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn;
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700659 fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) };
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700660 fhp.ma_map.ma[gi.trx_nr] := '1'B;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700661 }
662
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700663 log("Freq. hopping parameters: ", fhp);
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700664 break; /* We're done */
665 }
666 }
667}
668
Harald Welte70767382018-02-21 12:16:40 +0100669/* create a new test component */
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700670friend function f_start_handler(void_fn fn, ConnHdlrPars pars,
671 boolean pcu_comp := false,
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200672 boolean trxc_comp := false,
673 boolean l1ctl := true)
Harald Welte70767382018-02-21 12:16:40 +0100674runs on test_CT return ConnHdlr {
675 var charstring id := testcasename();
676 var ConnHdlr vc_conn;
677
678 vc_conn := ConnHdlr.create(id);
679 /* connect to RSL Emulation main component */
680 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
681 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700682
683 /* The ConnHdlr component may want to talk to some ports directly,
684 * so we disconnect it from the test_CT and connect it to the component.
685 * This obviously only works for one component, i.e. no concurrency. */
Harald Weltef26de0b2018-04-04 20:28:05 +0200686 if (pcu_comp) {
Harald Weltef26de0b2018-04-04 20:28:05 +0200687 unmap(self:PCU, system:PCU);
688 map(vc_conn:PCU, system:PCU);
689 }
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700690 if (trxc_comp) {
691 unmap(self:BTS_TRXC, system:BTS_TRXC);
692 map(vc_conn:BTS_TRXC, system:BTS_TRXC);
693 }
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200694 if (l1ctl) {
695 map(vc_conn:L1CTL, system:L1CTL);
696 }
Harald Welte70767382018-02-21 12:16:40 +0100697
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700698 /* Obtain frequency hopping parameters for a given timeslot */
699 if (mp_freq_hop_enabled and mp_transceiver_num > 1) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700700 f_resolve_fh_params(pars.fhp, pars.chan_nr.tn);
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700701 }
702
Harald Welte70767382018-02-21 12:16:40 +0100703 vc_conn.start(f_handler_init(fn, id, pars));
704 return vc_conn;
705}
706
Harald Welte70767382018-02-21 12:16:40 +0100707private altstep as_Tguard() runs on ConnHdlr {
708 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200709 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100710 }
711}
712
Harald Welte990a3612019-05-27 14:02:13 +0200713friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700714 var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn));
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700715 f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100716}
717
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700718private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100719 var TrxcMessage ret;
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600720 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi));
Harald Welte70767382018-02-21 12:16:40 +0100721}
722
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700723private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100724 var TrxcMessage ret;
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600725 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256));
Harald Welte70767382018-02-21 12:16:40 +0100726}
727
728/* first function started in ConnHdlr component */
729private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
730runs on ConnHdlr {
731 g_pars := pars;
732 g_chan_nr := pars.chan_nr;
733
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200734 if (L1CTL.checkstate("Mapped")) {
735 f_connect_reset(L1CTL);
736 }
Harald Welte70767382018-02-21 12:16:40 +0100737
Harald Welted48c0c72019-06-05 10:01:15 +0200738 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700739 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100740 }
Harald Welte70767382018-02-21 12:16:40 +0100741
742 g_Tguard.start(pars.t_guard);
743 activate(as_Tguard());
744
Vadim Yanitskiyf54db112020-11-16 18:00:15 +0700745 f_rslem_register(pars.trx_nr, pars.chan_nr);
Harald Welte70767382018-02-21 12:16:40 +0100746
747 /* call the user-supplied test case function */
748 fn.apply(id);
749}
750
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700751private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx,
752 charstring id, boolean ignore_other := false)
Harald Welteb1726c92018-03-30 11:56:38 +0200753runs on ConnHdlr return RSL_Message {
754 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100755 timer T := 3.0;
756 RSL.send(tx);
757 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100758 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200759 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100760 T.stop;
761 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100762 }
Harald Welte1eba3742018-02-25 12:48:14 +0100763 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200764 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100765 }
Harald Welte21240e62018-03-11 21:43:35 +0100766 [not ignore_other] as_l1_sacch();
767 [not ignore_other] as_meas_res();
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +0700768 [not ignore_other] as_l1_dcch_loop();
Vadim Yanitskiydc008112020-10-19 14:42:04 +0700769 [not ignore_other] as_l1_tch_loop();
Harald Welte21240e62018-03-11 21:43:35 +0100770 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200771 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100772 }
Harald Welte21240e62018-03-11 21:43:35 +0100773 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100774 }
Harald Welteb1726c92018-03-30 11:56:38 +0200775 return rx;
776}
777
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700778friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx,
779 charstring id, boolean ignore_other := false)
Harald Welteb1726c92018-03-30 11:56:38 +0200780runs on ConnHdlr {
781 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100782}
783
Vadim Yanitskiy9dd880f2022-08-01 19:22:18 +0700784/* Send the given measurement results to the IUT over the Um interface */
785friend function f_send_meas_rep(template (value) MeasurementResults meas_res)
786runs on ConnHdlr {
787 var template (value) SacchL1Header l1h;
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +0700788
789 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta);
790 f_send_meas_rep_l1h(meas_res, l1h);
791}
792
793/* Send the given measurement results and L1H to the IUT over the Um interface */
794friend function f_send_meas_rep_l1h(template (value) MeasurementResults meas_res,
795 template (value) SacchL1Header l1h)
796runs on ConnHdlr {
Vadim Yanitskiy9dd880f2022-08-01 19:22:18 +0700797 var octetstring l2;
798
799 /* RR Measurement Report to be sent */
800 var GsmRrL3Message meas_rep := {
801 header := valueof(t_RrL3Header(MEASUREMENT_REPORT)),
802 payload := { meas_rep := { meas_res := valueof(meas_res) } }
803 };
804
805 /* TITAN has weird (and often unusable) padding model, so we pad here manaully */
806 l2 := f_pad_oct(enc_LapdmFrameAB(valueof(ts_LAPDm_AB(0, meas_rep))), 21, '00'O);
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +0700807
808 log(%definitionId, "(): Tx SACCH L1 header: ", l1h);
Vadim Yanitskiy9dd880f2022-08-01 19:22:18 +0700809
810 /* Send RR Measurement Report over the Um interface */
811 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
812}
813
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +0300814/* Send the given measurement results to the IUT over the Um interface,
815 * wait for the IUT to receive then and forward over the A-bis/RSL interface. */
816friend function f_transceive_meas_rep(template (value) MeasurementResults meas_res)
817runs on ConnHdlr {
Vadim Yanitskiy9dd880f2022-08-01 19:22:18 +0700818 var octetstring l3;
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +0300819 timer T;
820
821 /* RR Measurement Report to be sent */
822 var GsmRrL3Message meas_rep := {
823 header := valueof(t_RrL3Header(MEASUREMENT_REPORT)),
824 payload := { meas_rep := { meas_res := valueof(meas_res) } }
825 };
826
827 /* TITAN has weird (and often unusable) padding model, so we pad here manaully */
828 l3 := f_pad_oct(enc_GsmRrL3Message(meas_rep), 18, '00'O);
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +0300829
Vadim Yanitskiy9dd880f2022-08-01 19:22:18 +0700830 f_send_meas_rep(meas_res);
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +0300831
832 /* Expect MEASurement RESult on the A-bis/RSL interface */
833 T.start(2.0);
834 alt {
835 [] RSL.receive(tr_RSL_MEAS_RES_OSMO(g_chan_nr, l3_info := l3)) {
836 setverdict(pass);
837 }
838 [] RSL.receive { repeat; }
839 [] T.timeout {
840 setverdict(fail, "Timeout waiting for RSL MEASurement RESult");
841 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
842 }
843 }
844}
845
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700846friend function f_rsl_chan_act(RSL_IE_ChannelMode mode,
847 boolean encr_enable := false,
848 RSL_IE_List more_ies := {},
849 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA)
850runs on ConnHdlr {
Harald Welte8b01c792019-05-19 22:51:25 +0200851 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200852 if (encr_enable) {
853 /* append encryption related IEs, if requested */
854 var RSL_IE_EncryptionInfo encr_info;
855 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
856 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
857encr_info})) };
858 }
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200859 if (mode.coding_alg_rate == RSL_CMOD_SP_GSM3) {
860 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_MR_CONFIG,
861 RSL_IE_Body:{multirate_cfg := g_pars.mr_conf})) };
862 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200863 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200864 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100865}
866
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700867friend function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100868 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
Harald Welte21240e62018-03-11 21:43:35 +0100869 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100870}
871
Harald Welte2f2b2b72019-05-31 22:24:57 +0200872friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Vadim Yanitskiye6c17552021-06-01 01:20:55 +0200873 template RSL_IE_ChannelMode chan_mode,
874 template (omit) TestSpecUnion spec := omit,
Vadim Yanitskiyf54db112020-11-16 18:00:15 +0700875 uint8_t trx_nr := 0, float t_guard := 20.0) := {
876 trx_nr := trx_nr,
Harald Welte70767382018-02-21 12:16:40 +0100877 chan_nr := valueof(chan_nr),
878 chan_mode := valueof(chan_mode),
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200879 mr_conf := omit,
Harald Welte70767382018-02-21 12:16:40 +0100880 t_guard := t_guard,
881 l1_pars := {
882 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100883 toa256_enabled := false,
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +0100884 meas_valid := true,
Harald Welte70767382018-02-21 12:16:40 +0100885 meas_ul := {
886 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200887 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100888 rxqual := 0
889 },
890 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200891 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100892 rxqual := 0
893 }
894 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200895 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100896 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200897 ms_power_level := mp_ms_power_level_exp,
Philipp Maier149c3922020-10-22 17:29:36 +0200898 ms_actual_ta := mp_ms_actual_ta_exp,
899 facch_enabled := false
Harald Welte0472ab42018-03-12 15:02:26 +0100900 },
Vadim Yanitskiye6c17552021-06-01 01:20:55 +0200901 spec := spec,
Eric Wild61edb7e2019-06-03 12:38:31 +0200902 encr := omit,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700903 bts0_band := omit,
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700904 tsc := mp_tsc_def,
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700905 fhp := {
906 enabled := false,
907 maio_hsn := ts_HsnMaio(0, 0),
908 ma_map := c_MA_null,
Vadim Yanitskiy2b991b62020-11-14 21:40:41 +0700909 ma := { }
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700910 }
Harald Welte70767382018-02-21 12:16:40 +0100911}
912
Vadim Yanitskiyf8a9df52022-03-12 13:29:26 +0300913/* This altstep triggers on receipt of a L1CTL DATA.ind matching the given
914 * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */
915private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg,
916 template (present) octetstring tr_data := ?,
917 template (present) RslChannelNr chan_nr := ?,
918 template (present) RslLinkId link_id := ?)
919runs on ConnHdlr {
920 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg;
921}
922
923/* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt
924 * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */
925private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?,
926 template (present) RslLinkId link_id := ?,
927 template (present) LapdmSapi sapi := ?,
928 boolean do_repeat := true)
929runs on ConnHdlr {
930 template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O);
931 var L1ctlDlMessage dl_msg;
932
933 [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) {
934 if (do_repeat) {
935 repeat;
936 }
937 }
938}
939
940/* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload
941 * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */
942private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame,
943 template (present) LapdmFrameAB tr_frame := ?,
944 template (present) RslLinkId link_id := ?)
945runs on ConnHdlr {
946 var L1ctlDlMessage dl_msg;
947
948 [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) {
949 frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload);
950 }
951}
952
Vadim Yanitskiya144e3c2022-03-14 23:56:40 +0300953/* This altstep triggers on receipt of a Downlink SACCH containing a L2 payload
954 * that matches the given LAPDm frame, as well as the given SACCH L1 header. */
955private altstep as_dl_sacch_lapdm_ab(out SacchL1Header l1h, out LapdmFrameAB frame,
956 template (present) LapdmFrameAB tr_frame := ?,
957 template (present) SacchL1Header tr_l1h := ?,
958 template (present) GsmSapi sapi := ?)
959runs on ConnHdlr {
960 var L1ctlDlMessage dl_msg;
961 template (present) RslLinkId link_id := tr_RslLinkID_SACCH(sapi);
962 template (present) L1ctlDataReq tr_data := {
963 l1header := tr_l1h,
964 l2_payload := decmatch tr_frame
965 };
966
967 [] as_l1ctl_dl_msg(dl_msg, decmatch tr_data, g_chan_nr, link_id) {
968 var octetstring data := dl_msg.payload.data_ind.payload;
969 l1h := dec_SacchL1Header(substr(data, 0, 2));
970 frame := dec_LapdmFrameAB(substr(data, 2, lengthof(data) - 2));
971 }
972}
973
Vadim Yanitskiyf8a9df52022-03-12 13:29:26 +0300974/* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt
975 * of a LAPDm AB frame with a L3 payload matching the given template. The L3
976 * payload is treated as PDU_ML3_NW_MS. */
977private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu,
978 template (present) PDU_ML3_NW_MS tr_pdu := ?,
979 template (present) GsmSapi sapi := 0)
980runs on ConnHdlr {
981 template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu);
982 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi);
983 var LapdmFrameAB lapdm_frame;
984
985 [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) {
986 pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload);
987 }
988}
989
Harald Welte93640c62018-02-25 16:59:33 +0100990/***********************************************************************
991 * Channel Activation / Deactivation
992 ***********************************************************************/
993
Harald Welte70767382018-02-21 12:16:40 +0100994/* Stress test: Do 500 channel activations/deactivations in rapid succession */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700995private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100996 for (var integer i := 0; i < 500; i := i+1) {
997 f_rsl_chan_act(g_pars.chan_mode);
998 f_rsl_chan_deact();
999 }
1000 setverdict(pass);
1001}
1002testcase TC_chan_act_stress() runs on test_CT {
1003 var ConnHdlr vc_conn;
1004 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02001005 f_init();
Harald Welte70767382018-02-21 12:16:40 +01001006 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
1007 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001008 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001009}
1010
1011/* Test if re-activation of an already active channel fails as expected */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001012private function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001013 f_rsl_chan_act(g_pars.chan_mode);
1014 /* attempt to activate the same lchan again -> expect reject */
1015 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
1016 alt {
1017 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001018 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +01001019 }
1020 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
1021 setverdict(pass);
1022 }
1023 }
1024 f_rsl_chan_deact();
1025}
1026testcase TC_chan_act_react() runs on test_CT {
1027 var ConnHdlr vc_conn;
1028 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +01001029 f_init();
Harald Welte70767382018-02-21 12:16:40 +01001030 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
1031 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001032 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001033}
1034
1035/* Attempt to de-activate a channel that's not active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001036private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001037 timer T := 3.0;
1038 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
1039 T.start;
1040 alt {
1041 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
1042 setverdict(pass);
1043 }
1044 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001045 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +01001046 }
1047 }
1048}
1049testcase TC_chan_deact_not_active() runs on test_CT {
1050 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +01001051 f_init();
Harald Welte70767382018-02-21 12:16:40 +01001052 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
1053 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001054 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001055}
1056
1057/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001058private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001059 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
1060 alt {
1061 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001062 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +01001063 }
1064 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
1065 setverdict(pass);
1066 }
1067 }
1068}
1069private type record WrongChanNrCase {
1070 RslChannelNr chan_nr,
1071 charstring description
1072}
1073private type record of WrongChanNrCase WrongChanNrCases;
1074private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
1075 chan_nr := chan_nr,
1076 description := desc
1077}
1078
1079testcase TC_chan_act_wrong_nr() runs on test_CT {
1080 var ConnHdlr vc_conn;
1081 var ConnHdlrPars pars;
1082
Harald Welte294b0a22018-03-10 23:26:48 +01001083 f_init();
Harald Welte70767382018-02-21 12:16:40 +01001084
1085 var WrongChanNrCases wrong := {
1086 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
1087 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
1088 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
1089 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
1090 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
1091 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
1092 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
1093 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
1094 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
1095 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
1096 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
1097 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
1098 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
1099 };
1100
1101 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
1102 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
1103 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
1104 vc_conn.done;
1105 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001106 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001107}
1108
Harald Weltee613f962018-04-18 22:38:16 +02001109/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +02001110friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +02001111 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02001112 f_init();
Harald Weltee613f962018-04-18 22:38:16 +02001113
1114 /* test on each of the channels we have */
1115 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
1116 pars.chan_nr := valueof(g_AllChanTypes[i]);
1117
1118 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
1119 vc_conn := f_start_handler(fn, pars);
1120 vc_conn.done;
1121 }
1122
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001123 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +02001124}
1125
Harald Welte93640c62018-02-25 16:59:33 +01001126/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +01001127 * SACCH handling
1128 ***********************************************************************/
1129
1130private function f_exp_sacch(boolean exp) runs on ConnHdlr {
1131 timer T_sacch := 3.0;
1132 T_sacch.start;
1133 alt {
1134 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001135 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +01001136 }
1137 [not exp] T_sacch.timeout {
1138 setverdict(pass);
1139 }
1140 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
1141 setverdict(pass);
1142 }
1143 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001144 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +01001145 }
1146 [] L1CTL.receive { repeat; }
1147 [] RSL.receive { repeat; }
1148 }
1149}
1150
1151/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
1152private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
1153 f_l1_tune(L1CTL);
1154 RSL.clear;
1155
1156 /* activate the logical channel */
1157 f_est_dchan();
1158 L1CTL.clear;
1159
1160 /* check that SACCH actually are received as expected */
1161 f_exp_sacch(true);
1162
1163 /* deactivate SACCH on the logical channel */
1164 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
1165 f_sleep(1.0);
1166 L1CTL.clear;
1167
1168 /* check that no SACCH are received anymore */
1169 f_exp_sacch(false);
1170
1171 /* release the channel */
1172 f_rsl_chan_deact();
1173 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1174}
1175testcase TC_deact_sacch() runs on test_CT {
1176 var ConnHdlr vc_conn;
1177 var ConnHdlrPars pars;
1178 f_init();
1179 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1180 //for (var integer i := 0; i < 1; i := i+1) {
1181 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1182 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1183 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
1184 vc_conn.done;
1185 }
1186 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001187 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +01001188}
1189
Harald Welte55700662018-03-12 13:15:43 +01001190/* verify that given SACCH payload is present */
Vadim Yanitskiyf9136a12022-03-11 14:04:27 +03001191private function f_sacch_present(template octetstring l3_exp,
1192 boolean do_fail := true)
1193runs on ConnHdlr {
Harald Welteea17b912018-03-11 22:29:31 +01001194 var L1ctlDlMessage dl;
Harald Welteea17b912018-03-11 22:29:31 +01001195 timer T_sacch := 3.0;
1196 L1CTL.clear;
1197 T_sacch.start;
1198 alt {
1199 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
1200 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
1201 if (match(l3, l3_exp)) {
1202 setverdict(pass);
1203 } else {
1204 repeat;
1205 }
1206 }
1207 [] L1CTL.receive { repeat; }
Vadim Yanitskiyf9136a12022-03-11 14:04:27 +03001208 [not do_fail] T_sacch.timeout {
1209 log("Timeout waiting for SACCH ", l3_exp);
1210 }
1211 [do_fail] T_sacch.timeout {
Vadim Yanitskiy77a65f82022-03-11 12:34:47 +03001212 setverdict(fail, "Timeout waiting for SACCH ", l3_exp);
1213 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +01001214 }
1215 }
1216}
1217
Harald Welte55700662018-03-12 13:15:43 +01001218/* verify that given SACCH payload is not present */
1219private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
1220 var L1ctlDlMessage dl;
Harald Welte55700662018-03-12 13:15:43 +01001221 timer T_sacch := 3.0;
1222 L1CTL.clear;
1223 T_sacch.start;
1224 alt {
1225 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
1226 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
1227 if (match(l3, l3_exp)) {
Vadim Yanitskiy77a65f82022-03-11 12:34:47 +03001228 setverdict(fail, "Received unexpected SACCH ", dl);
1229 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001230 } else {
1231 repeat;
1232 }
1233 }
1234 [] L1CTL.receive { repeat; }
1235 [] T_sacch.timeout {
1236 setverdict(pass);
1237 }
1238 }
1239}
1240
Harald Welte629cc6b2018-03-11 17:19:05 +01001241/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +01001242private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
1243 /* Set a known default SACCH filling for SI5 */
1244 var octetstring si5 := f_rnd_octstring(19);
1245 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1246
1247 f_l1_tune(L1CTL);
1248 RSL.clear;
1249
1250 /* activate the logical channel */
1251 f_est_dchan();
1252
1253 /* check that the specified SI5 value is actually sent */
1254 f_sacch_present(si5);
1255
1256 /* release the channel */
1257 RSL.clear;
1258 f_rsl_chan_deact();
1259 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1260}
1261testcase TC_sacch_filling() runs on test_CT {
1262 var ConnHdlr vc_conn;
1263 var ConnHdlrPars pars;
1264 f_init();
1265 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1266 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1267 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1268 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
1269 vc_conn.done;
1270 }
1271 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001272 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +01001273}
1274
Harald Welte629cc6b2018-03-11 17:19:05 +01001275/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +01001276private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
1277 /* Set a known default SACCH filling for SI5 */
1278 var octetstring si5 := f_rnd_octstring(19);
1279 var octetstring si5_diff := f_rnd_octstring(19);
1280 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1281
1282 f_l1_tune(L1CTL);
1283 RSL.clear;
1284
1285 log("Activating channel, expecting standard SI5");
1286 /* activate the logical channel */
1287 f_est_dchan();
1288 /* check that the specified SI5 value is actually sent */
1289 f_sacch_present(si5);
1290
1291 /* set channel-specific different SI5 */
1292 log("Setting channel specific SACCH INFO, expecting it");
1293 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
1294 /* check that the specified lchan-specific value is now used */
1295 f_sacch_present(si5_diff);
1296
1297 /* deactivate the channel and re-activate it, this should result in default SI5 */
1298 log("De-activating and re-activating channel, expecting standard SI5");
1299 f_rsl_chan_deact();
1300 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
1301 /* Verify that the TRX-wide default SACCH filling is present again */
1302 f_sacch_present(si5);
1303
1304 /* release the channel */
1305 RSL.clear;
1306 f_rsl_chan_deact();
1307 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1308}
1309testcase TC_sacch_info_mod() runs on test_CT {
1310 var ConnHdlr vc_conn;
1311 var ConnHdlrPars pars;
1312 f_init();
1313 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1314 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1315 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1316 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
1317 vc_conn.done;
1318 }
1319 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001320 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +01001321}
1322
Harald Welte075d84c2018-03-12 13:07:24 +01001323/* Test SACCH scheduling of multiple different SI message types */
1324private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
1325 var octetstring si5 := f_rnd_octstring(19);
1326 var octetstring si5bis := f_rnd_octstring(19);
1327 var octetstring si5ter := f_rnd_octstring(19);
1328 var octetstring si6 := f_rnd_octstring(19);
1329
1330 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1331 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
1332 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
1333 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1334
1335 f_l1_tune(L1CTL);
1336 RSL.clear;
1337
1338 /* activate the logical channel */
1339 f_est_dchan();
1340 L1CTL.clear;
1341
1342 /* check that SACCH actually are received as expected */
1343 f_sacch_present(si5);
1344 f_sacch_present(si5bis);
1345 f_sacch_present(si5ter);
1346 f_sacch_present(si6);
1347
1348 /* release the channel */
1349 f_rsl_chan_deact();
1350 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1351}
1352testcase TC_sacch_multi() runs on test_CT {
1353 var ConnHdlr vc_conn;
1354 var ConnHdlrPars pars;
1355 f_init();
1356 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1357 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1358 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1359 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
1360 vc_conn.done;
1361 }
1362 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001363 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +01001364}
1365
Harald Welte55700662018-03-12 13:15:43 +01001366/* Test if SACH information is modified as expected */
1367private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
1368 var octetstring si5 := f_rnd_octstring(19);
1369 var octetstring si6 := f_rnd_octstring(19);
1370
1371 /* First, configure both SI5 and SI6 to be transmitted */
1372 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1373 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1374
1375 f_l1_tune(L1CTL);
1376 RSL.clear;
1377
1378 /* activate the logical channel */
1379 f_est_dchan();
1380 L1CTL.clear;
1381
1382 /* check that SACCH actually are received as expected */
1383 f_sacch_present(si5);
1384 f_sacch_present(si6);
1385
1386 /* disable SI6 */
1387 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1388
1389 /* check that SI5 is still transmitted */
1390 f_sacch_present(si5);
1391 /* check if SI6 is now gone */
1392 f_sacch_missing(si6);
1393
1394 /* release the channel */
1395 f_rsl_chan_deact();
1396 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1397}
1398testcase TC_sacch_multi_chg() runs on test_CT {
1399 var ConnHdlr vc_conn;
1400 var ConnHdlrPars pars;
1401 f_init();
1402 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1403 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1404 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1405 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1406 vc_conn.done;
1407 }
1408 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001409 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001410}
1411
Harald Weltec8d363c2019-05-19 20:36:48 +02001412/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1413private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1414 var octetstring si5 := f_rnd_octstring(19);
1415 var octetstring si6 := f_rnd_octstring(19);
1416 var octetstring si5_specific := f_rnd_octstring(19);
1417 var octetstring si6_specific := f_rnd_octstring(19);
1418
1419 /* First, configure both SI5 and SI6 to be transmitted */
1420 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1421 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1422
1423 f_l1_tune(L1CTL);
1424 RSL.clear;
1425
1426 /* activate channel with different SACCH filling */
1427 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1428 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1429 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1430 }));
1431 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1432 RSL_IE_Body:{sacch_info := sacch_info})) };
1433 f_est_dchan(more_ies := addl_ies);
1434
1435 /* check that SACCH actually are received as expected */
1436 f_sacch_present(si5_specific);
1437 f_sacch_present(si6_specific);
1438
1439 /* release the channel */
1440 f_rsl_chan_deact();
1441 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1442}
1443testcase TC_sacch_chan_act() runs on test_CT {
1444 var ConnHdlr vc_conn;
1445 var ConnHdlrPars pars;
1446 f_init();
1447
1448 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1449 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1450 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1451 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1452 vc_conn.done;
1453 }
1454 /* TODO: do the above in parallel, rather than sequentially? */
1455 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1456}
1457
Harald Welte8b01c792019-05-19 22:51:25 +02001458/* verify that SACCH DL transmission is started only if MS power IE present
1459 * see section 4.1.3 of 3GPP TS 48.058 */
1460private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1461 var octetstring si5 := f_rnd_octstring(19);
Neels Hofmeyrdd597412020-11-03 20:35:00 +00001462 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
Harald Welte8b01c792019-05-19 22:51:25 +02001463
1464 f_l1_tune(L1CTL);
1465 RSL.clear;
1466
1467 /* Step 1: Activate ASYNC HO channel without MS power IE */
1468
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001469 var integer ho_ref := oct2int(f_rnd_octstring(1));
1470 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1471 RSL_IE_Body:{ handover_ref := ho_ref }));
1472 var RSL_IE_List addl_ies := {
1473 ho_ref_ie
1474 };
1475
Harald Welte8b01c792019-05-19 22:51:25 +02001476 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001477 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
Harald Welte8b01c792019-05-19 22:51:25 +02001478 /* don't perform immediate assignment here, as we're testing non-IA case */
1479 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001480 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001481
1482 /* Verify that no DL SACCH is being received */
1483 f_sacch_missing(?);
1484
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001485 /* Send handover Access Burst and expect SACCH to start */
1486 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1487
1488 f_sacch_present(si5);
1489
Harald Welte8b01c792019-05-19 22:51:25 +02001490 f_rsl_chan_deact();
1491 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1492
Vadim Yanitskiye3351bb2022-07-29 05:22:51 +07001493 /* Tune back to CCCH/BCCH */
1494 f_l1_tune(L1CTL);
1495
Harald Welte8b01c792019-05-19 22:51:25 +02001496
1497 /* Step 2: Activate ASYNC HO channel with MS power IE */
1498
1499 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001500 addl_ies := {
1501 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001502 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1503 };
1504 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1505 /* don't perform immediate assignment here, as we're testing non-IA case */
1506 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001507 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001508
Vadim Yanitskiyf9136a12022-03-11 14:04:27 +03001509 /* 4.1.3 "If the MS Power IE is present the BTS *may* start transmission
1510 * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */
1511 f_sacch_present(si5, do_fail := false);
Harald Welte8b01c792019-05-19 22:51:25 +02001512
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001513 /* Send handover Access Burst and expect SACCH to remain present */
1514 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1515
1516 f_sacch_present(si5);
1517
Harald Welte8b01c792019-05-19 22:51:25 +02001518 f_rsl_chan_deact();
1519 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1520}
1521testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1522 var ConnHdlr vc_conn;
1523 var ConnHdlrPars pars;
1524 f_init();
1525
Vadim Yanitskiyce96d352022-03-11 15:32:07 +03001526 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
1527 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
1528 log(testcasename(), ": Starting for ", g_AllChanTypes[i]);
Harald Welte8b01c792019-05-19 22:51:25 +02001529 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1530 vc_conn.done;
1531 }
1532 /* TODO: do the above in parallel, rather than sequentially? */
1533 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1534}
1535
1536/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1537 * see section 4.1.4 of 3GPP TS 48.058 */
1538private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1539 var octetstring si5 := f_rnd_octstring(19);
Neels Hofmeyrdd597412020-11-03 20:35:00 +00001540 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1541
Harald Welte8b01c792019-05-19 22:51:25 +02001542 var RSL_IE_List addl_ies;
1543
1544 f_l1_tune(L1CTL);
1545 RSL.clear;
1546
1547 /* Step 1: Activate SYNC HO channel without MS power IE */
1548
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001549 var integer ho_ref := oct2int(f_rnd_octstring(1));
1550 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1551 RSL_IE_Body:{ handover_ref := ho_ref }));
1552 addl_ies := {
1553 ho_ref_ie
1554 };
1555
Harald Welte8b01c792019-05-19 22:51:25 +02001556 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001557 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
Harald Welte8b01c792019-05-19 22:51:25 +02001558 /* don't perform immediate assignment here, as we're testing non-IA case */
1559 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001560 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001561
1562 /* Verify that no DL SACCH is being received */
1563 f_sacch_missing(?);
1564
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001565 /* Send handover Access Burst and expect SACCH to start */
1566 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1567
1568 f_sacch_present(si5);
1569
Harald Welte8b01c792019-05-19 22:51:25 +02001570 f_rsl_chan_deact();
1571 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1572
Vadim Yanitskiye3351bb2022-07-29 05:22:51 +07001573 /* Tune back to CCCH/BCCH */
1574 f_l1_tune(L1CTL);
1575
Harald Welte8b01c792019-05-19 22:51:25 +02001576
1577 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1578
1579 /* Activate channel on BTS side */
1580 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001581 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001582 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1583 };
1584 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1585 /* don't perform immediate assignment here, as we're testing non-IA case */
1586 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001587 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001588
Vadim Yanitskiyf9136a12022-03-11 14:04:27 +03001589 /* 4.1.4 "If only the MS Power IE is present the BTS *may* start transmission
1590 * also on the SACCH". "May" does not mean "shall", so osmo-bts does not. */
1591 f_sacch_present(si5, do_fail := false);
Harald Welte8b01c792019-05-19 22:51:25 +02001592
Neels Hofmeyrd55a3ac2020-11-09 00:54:34 +00001593 /* Send handover Access Burst and expect SACCH to remain present */
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001594 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1595
1596 f_sacch_present(si5);
1597
Harald Welte8b01c792019-05-19 22:51:25 +02001598 f_rsl_chan_deact();
1599 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1600
Vadim Yanitskiye3351bb2022-07-29 05:22:51 +07001601 /* Tune back to CCCH/BCCH */
1602 f_l1_tune(L1CTL);
1603
Harald Welte8b01c792019-05-19 22:51:25 +02001604
1605 /* Step 2b: Activate SYNC HO channel with TA IE */
1606
1607 /* Activate channel on BTS side */
1608 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001609 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001610 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1611 };
1612 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1613 /* don't perform immediate assignment here, as we're testing non-IA case */
1614 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001615 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001616
1617 /* Verify that no DL SACCH is being received */
1618 f_sacch_missing(?);
1619
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001620 /* Send handover Access Burst and expect SACCH to start */
1621 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1622
1623 f_sacch_present(si5);
1624
Harald Welte8b01c792019-05-19 22:51:25 +02001625 f_rsl_chan_deact();
1626 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1627
Vadim Yanitskiye3351bb2022-07-29 05:22:51 +07001628 /* Tune back to CCCH/BCCH */
1629 f_l1_tune(L1CTL);
1630
Harald Welte8b01c792019-05-19 22:51:25 +02001631
1632 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1633
1634 /* Activate channel on BTS side */
1635 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001636 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001637 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1638 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1639 };
1640 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1641 /* don't perform immediate assignment here, as we're testing non-IA case */
1642 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001643 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001644
1645 /* Verify that DL SACCH is being received */
1646 f_sacch_present(si5);
1647
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001648 /* Send handover Access Burst and expect SACCH to remain present */
1649 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1650
1651 f_sacch_present(si5);
1652
Harald Welte8b01c792019-05-19 22:51:25 +02001653 f_rsl_chan_deact();
1654 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1655}
1656testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1657 var ConnHdlr vc_conn;
1658 var ConnHdlrPars pars;
1659 f_init();
1660
Vadim Yanitskiyce96d352022-03-11 15:32:07 +03001661 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
1662 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
1663 log(testcasename(), ": Starting for ", g_AllChanTypes[i]);
Harald Welte8b01c792019-05-19 22:51:25 +02001664 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1665 vc_conn.done;
1666 }
1667 /* TODO: do the above in parallel, rather than sequentially? */
1668 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1669}
Harald Welte629cc6b2018-03-11 17:19:05 +01001670
1671
1672/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001673 * RACH Handling
1674 ***********************************************************************/
1675
Harald Welte8c24c2b2018-02-26 08:31:31 +01001676/* Send 1000 RACH requests and check their RA+FN on the RSL side */
Philipp Maier16ade782020-07-08 21:36:00 +02001677private function f_TC_rach_content(boolean emerg) runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001678 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001679 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001680 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001681
Harald Welte8c24c2b2018-02-26 08:31:31 +01001682 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001683 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001684 for (var integer i := 0; i < 1000; i := i+1) {
Neels Hofmeyrc897cfb2020-11-09 00:06:01 +00001685 var OCT1 ra;
Philipp Maier16ade782020-07-08 21:36:00 +02001686 if (emerg == true) {
1687 ra := f_rnd_ra_emerg();
1688 } else {
1689 ra := f_rnd_ra_cs();
1690 }
Harald Welte8c24c2b2018-02-26 08:31:31 +01001691 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1692 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001693 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001694 }
1695 fn_last := fn;
1696
1697 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001698 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001699 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001700 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001701 T.stop;
1702 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001703 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001704 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001705 }
1706 [] RSL_CCHAN.receive { repeat; }
1707 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001708 test_failed := true;
1709 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001710 }
1711 }
1712 }
Maxba06feb2019-03-05 10:52:46 +01001713 if (test_failed) {
1714 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001715 }
Maxba06feb2019-03-05 10:52:46 +01001716 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001717 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001718}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001719
Philipp Maier16ade782020-07-08 21:36:00 +02001720/* Normal variant */
1721testcase TC_rach_content() runs on test_CT {
1722 f_TC_rach_content(emerg := false);
1723}
1724
1725/* Emergency call variant */
1726testcase TC_rach_content_emerg() runs on test_CT {
1727 f_TC_rach_content(emerg := true);
1728}
1729
Harald Welte8c24c2b2018-02-26 08:31:31 +01001730/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1731testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001732 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001733 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001734 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001735 f_l1_tune(L1CTL);
1736
1737 var GsmFrameNumber fn_last := 0;
1738 for (var integer i := 0; i < 1000; i := i+1) {
1739 var OCT1 ra := f_rnd_ra_cs();
1740 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1741 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001742 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001743 }
1744 fn_last := fn;
1745 }
1746 var integer rsl_chrqd := 0;
1747 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001748 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001749 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001750 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001751 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001752 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001753 repeat;
1754 }
1755 [] RSL_CCHAN.receive { repeat; }
1756 [] T.timeout { }
1757 }
1758 if (rsl_chrqd == 1000) {
1759 setverdict(pass);
1760 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001761 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001762 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001763 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001764}
1765
Harald Welte3453ab42019-05-24 21:19:58 +02001766private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1767 var charstring bts_str := "bts " & int2str(bts_nr);
1768 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1769}
1770
1771/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1772private template integer tr_rach_slots_per_interval := (90 .. 130);
1773
1774/* Expect 0 RACH load on an idle BTS that has just started up */
1775testcase TC_rach_load_idle_thresh0() runs on test_CT {
1776 var ASP_RSL_Unitdata rx_ud;
1777
1778 f_init_vty_bsc();
1779 /* send load indications even at 0% load */
1780 f_vty_load_ind_thresh(0);
1781 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1782 f_sleep(2.0);
1783
1784 f_init();
1785
Harald Weltee37f9a52020-10-11 20:45:23 +02001786 /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
1787 alt {
1788 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
1789 [] RSL_CCHAN.receive { repeat }
1790 }
1791
Harald Welte3453ab42019-05-24 21:19:58 +02001792 timer T := 5.0;
1793 T.start;
1794 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001795 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
Harald Welte3453ab42019-05-24 21:19:58 +02001796 setverdict(pass);
1797 repeat;
1798 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001799 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001800 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1801 repeat;
1802 }
1803 [] RSL_CCHAN.receive {
1804 repeat;
1805 }
1806 [] T.timeout { }
1807 }
1808
1809 f_vty_load_ind_thresh(10);
1810 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1811}
1812
1813/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1814testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1815 var ASP_RSL_Unitdata rx_ud;
1816
1817 f_init_vty_bsc();
1818 f_init();
1819
1820 timer T := 5.0;
1821 T.start;
1822 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001823 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001824 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1825 repeat;
1826 }
1827 [] RSL_CCHAN.receive {
1828 repeat;
1829 }
1830 [] T.timeout {
1831 setverdict(pass);
1832 }
1833 }
1834
1835 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1836}
1837
1838/* Expect 0 RACH load on an idle BTS that has just started up */
1839testcase TC_rach_load_count() runs on test_CT {
1840 var ASP_RSL_Unitdata rx_ud;
1841 var integer load_access_count := 0;
1842
1843 f_init_vty_bsc();
1844 /* send load indications even at 0% load */
1845 f_vty_load_ind_thresh(0);
1846 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1847 f_sleep(2.0);
1848 f_init();
1849
1850 f_init_l1ctl();
1851 f_sleep(1.0);
1852 f_l1_tune(L1CTL);
1853
Harald Welte52ae1682020-10-11 20:45:55 +02001854 /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
1855 alt {
1856 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
1857 [] RSL_CCHAN.receive { repeat }
1858 }
1859
Harald Welte3453ab42019-05-24 21:19:58 +02001860 var GsmFrameNumber fn_last := 0;
1861 for (var integer i := 0; i < 1000; i := i+1) {
1862 var OCT1 ra := f_rnd_ra_cs();
1863 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1864 if (fn == fn_last) {
1865 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1866 }
1867 fn_last := fn;
1868 }
1869
1870 timer T := 5.0;
1871 T.start;
1872 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001873 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
Harald Welte3453ab42019-05-24 21:19:58 +02001874 -> value rx_ud {
1875 var RSL_IE_Body ie;
1876 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1877 load_access_count := load_access_count + ie.rach_load.access_count;
1878 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1879 setverdict(fail, "Access count cannot be < Busy count");
1880 }
1881 repeat;
1882 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001883 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001884 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1885 repeat;
1886 }
1887 [] RSL_CCHAN.receive {
1888 repeat;
1889 }
1890 [] T.timeout { }
1891 }
1892 if (load_access_count == 1000) {
1893 setverdict(pass);
1894 } else {
1895 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1896 }
1897
1898 f_vty_load_ind_thresh(10);
1899 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1900}
1901
Harald Welte54a2a2d2018-02-26 09:14:05 +01001902private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001903 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001904 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +06001905 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001906 f_sleep(0.5);
1907
1908 /* Transmit RACH request + wait for confirmation */
1909 var OCT1 ra := f_rnd_ra_cs();
1910 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1911
1912 /* Check for expected result */
1913 timer T := 1.5;
1914 T.start;
1915 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001916 [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welte54a2a2d2018-02-26 09:14:05 +01001917 setverdict(pass);
1918 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001919 [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001920 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001921 }
1922 [] RSL_CCHAN.receive { repeat; }
1923 [not expect_pass] T.timeout {
1924 setverdict(pass);
1925 }
1926 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001927 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001928 }
1929 }
1930}
1931
1932/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1933testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001934 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001935 f_init_l1ctl();
1936 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001937 f_sleep(1.0);
1938
1939 /* default max-ta is 63 (full range of GSM timing advance */
1940
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001941 /* We allow early arrival up to 2 symbols */
1942 f_rach_toffs(-1*256, true);
1943 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001944 f_rach_toffs(-10*256, false);
1945
1946 /* 0 / 32 / 63 bits is legal / permitted */
1947 f_rach_toffs(0, true);
1948 f_rach_toffs(32*256, true);
1949 f_rach_toffs(63*256, true);
1950
1951 /* more than 63 bits is not legal / permitted */
1952 f_rach_toffs(64*256, false);
1953 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001954 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001955}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001956
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001957private function f_TC_ho_rach(charstring id) runs on ConnHdlr {
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001958 var GsmFrameNumber fn;
1959 var RSL_Message rm;
1960
1961 f_l1_tune(L1CTL);
1962 RSL.clear;
1963
1964 /* Generate a random Handover Reference */
1965 var integer ho_ref := oct2int(f_rnd_octstring(1));
1966
1967 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1968 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1969 RSL_IE_Body:{ handover_ref := ho_ref }));
1970
1971 /* Activate a channel on the BTS side (no encryption) */
1972 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1973 act_type := t_RSL_IE_ActType_HO_SYNC);
1974
1975 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1976 * waiting for Immediate Assignment and sending Access Burst */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001977 f_l1ctl_est_dchan(L1CTL, g_pars);
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001978
1979 /* Send handover Access Burst */
1980 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1981
1982 /* TODO: test mismatching Handover Reference, and missing IE */
1983
1984 /* Wait for handover detection */
1985 timer T := 3.0;
1986 T.start;
1987 alt {
1988 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1989 log("Handover RACH has been detected: ", rm);
1990 setverdict(pass);
1991 }
1992 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1993 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1994 log2str("RSL_CHAN_RQD was not expected: ", rm));
1995 }
1996 [] RSL.receive { repeat; }
1997 [] T.timeout {
1998 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1999 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
2000 }
2001 }
2002
2003 /* Release the channel */
2004 f_rsl_chan_deact();
2005 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2006}
2007
2008/* Test handover RACH detection */
2009testcase TC_ho_rach() runs on test_CT {
2010 var ConnHdlrPars pars;
2011 var ConnHdlr vc_conn;
2012
2013 f_init();
2014
2015 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
2016 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
2017 log(testcasename(), ": Starting for ", g_AllChannels[i]);
2018 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
2019 vc_conn.done;
2020 }
2021
2022 /* TODO: do the above in parallel, rather than sequentially? */
2023 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2024}
2025
Vadim Yanitskiy1ab332f2022-03-12 15:31:23 +03002026/* Test sending of the RR Physical Information message on DCCH */
2027private function f_TC_ho_physical_info(charstring id) runs on ConnHdlr {
2028 var PDU_ML3_NW_MS dcch_pdu;
2029 var integer count := 0;
2030 var L1ctlDlMessage dl;
2031 timer T;
2032
2033 f_l1_tune(L1CTL);
2034 RSL.clear;
2035
2036 /* Generate a random Handover Reference */
2037 var integer ho_ref := oct2int(f_rnd_octstring(1));
2038
2039 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
2040 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
2041 RSL_IE_Body:{ handover_ref := ho_ref }));
2042
2043 /* Activate a channel on the BTS side (no encryption) */
2044 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
2045 act_type := t_RSL_IE_ActType_HO_SYNC);
2046
2047 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
2048 * waiting for Immediate Assignment and sending of an Access Burst. */
2049 f_l1ctl_est_dchan(L1CTL, g_pars); /* FIXME: disable Uplink Tx */
2050
2051 /* Expect nothing to be transmitted on Downlink DCCH. Nothing in this
2052 * context means any L2 frames, not only the RR Physical Information. */
2053 T.start(2.0);
2054 L1CTL.clear;
2055 alt {
2056 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value dl {
2057 setverdict(fail, "Rx unexpected Downlink DCCH (before handover RACH): ", dl);
2058 T.stop;
2059 }
2060 [] L1CTL.receive { repeat; }
2061 [] T.timeout { setverdict(pass); }
2062 }
2063
2064 /* Send handover Access Burst */
2065 log("Sending handover Access Burst");
2066 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
2067
2068 /* Expect RR Physical Information being sent on Downlink DCCH Ny1 times */
2069 T.start(int2float(mp_ho_t3105_ms * mp_ho_ny1) / 1000.0 + 1.0);
2070 L1CTL.clear;
2071 alt {
2072 [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */
2073 [] as_dl_dcch_pdu(dcch_pdu, tr_RRM_PhysicalInfo) {
2074 log("Rx RR Physical Information: ", dcch_pdu);
2075 /* Wait until the count reaches Ny1 */
2076 count := count + 1;
2077 if (count < mp_ho_ny1)
2078 { repeat; }
2079 setverdict(pass);
2080 }
2081 [] as_dl_dcch_pdu(dcch_pdu, ?) {
2082 setverdict(fail, "Rx unexpected DCCH PDU: ", dcch_pdu);
2083 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2084 }
2085 [] L1CTL.receive { repeat; }
2086 [] T.timeout {
2087 setverdict(fail, "Timeout waiting for RR Physical Information");
2088 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2089 }
2090 }
2091
2092 /* Release the channel */
2093 f_rsl_chan_deact();
2094 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2095}
2096testcase TC_ho_physical_info() runs on test_CT {
2097 var ConnHdlrPars pars;
2098 var ConnHdlr vc_conn;
2099
2100 f_init();
2101
2102 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) {
2103 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
2104 log(testcasename(), ": Starting for ", g_AllChanTypes[i]);
2105 vc_conn := f_start_handler(refers(f_TC_ho_physical_info), pars);
2106 vc_conn.done;
2107 }
2108
2109 /* TODO: do the above in parallel, rather than sequentially? */
2110 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2111}
2112
Harald Welte93640c62018-02-25 16:59:33 +01002113/***********************************************************************
2114 * Measurement Processing / Reporting
2115 ***********************************************************************/
2116
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002117private template (value) LapdmAddressField
2118ts_LapdmAddr(template (value) LapdmSapi sapi,
2119 template (value) boolean c_r) := {
Harald Welte70767382018-02-21 12:16:40 +01002120 spare := '0'B,
2121 lpd := 0,
2122 sapi := sapi,
2123 c_r := c_r,
2124 ea := true
2125}
2126
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002127private template (value) LapdmFrameAB
2128ts_LAPDm_AB(template (value) LapdmSapi sapi,
2129 template (value) GsmRrL3Message l3,
2130 template (value) boolean c_r := false,
2131 template (value) boolean p := false) := {
Harald Welte70767382018-02-21 12:16:40 +01002132 addr := ts_LapdmAddr(sapi, c_r),
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002133 ctrl := ts_LapdmCtrlUI(valueof(p)),
Harald Welte70767382018-02-21 12:16:40 +01002134 len := 0, /* overwritten */
2135 m := false,
2136 el := 1,
Vadim Yanitskiy16e29912022-03-12 13:26:21 +03002137 payload := enc_GsmRrL3Message(valueof(l3)),
2138 padding := ''O
Harald Welte70767382018-02-21 12:16:40 +01002139}
2140
2141/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002142private altstep as_l1_sacch() runs on ConnHdlr {
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002143 var template (value) LapdmFrameAB lb;
Harald Welte70767382018-02-21 12:16:40 +01002144 var L1ctlDlMessage l1_dl;
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002145
Harald Weltef8df4cb2018-03-10 15:15:08 +01002146 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01002147 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07002148
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +01002149 lb := ts_LAPDm_AB(0, ts_MEAS_REP(g_pars.l1_pars.meas_valid,
Vadim Yanitskiycb57c1b2020-11-11 20:57:15 +07002150 g_pars.l1_pars.meas_ul.full.rxlev,
2151 g_pars.l1_pars.meas_ul.sub.rxlev,
2152 g_pars.l1_pars.meas_ul.full.rxqual,
2153 g_pars.l1_pars.meas_ul.sub.rxqual));
Harald Welte70767382018-02-21 12:16:40 +01002154 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02002155
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07002156 var template (value) SacchL1Header l1h := ts_SacchL1Header(
Vadim Yanitskiy68c4cff2022-07-30 23:45:02 +07002157 g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta);
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07002158
Vadim Yanitskiyf105a5b2020-11-30 14:27:55 +01002159 /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */
2160 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '00'O);
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07002161
2162 log("Sending Measurement Report: ", l1h, l2);
2163 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01002164 repeat;
2165 }
2166}
2167
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002168/* handle incoming downlink SACCH, decode the L1 header into the given record */
2169private altstep as_l1_sacch_l1h(inout SacchL1Header l1h,
2170 boolean do_apply := true)
2171runs on ConnHdlr
2172{
2173 var L1ctlDlMessage l1_dl;
2174
2175 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2176 /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
2177 l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2));
2178 log(%definitionId, "(): Rx SACCH L1 header: ", l1h);
2179
2180 if (do_apply) {
2181 /* Update TA and MS power to follow what BTS requests */
2182 f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl);
2183 }
2184 }
2185}
2186
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +07002187private altstep as_l1_dcch_loop() runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01002188 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002189 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01002190 log("DCCH received: ", l1_dl.payload.data_ind.payload);
2191 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07002192 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
2193 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01002194 repeat;
2195 }
2196}
2197
Vadim Yanitskiydc008112020-10-19 14:42:04 +07002198private altstep as_l1_tch_loop() runs on ConnHdlr {
2199 var L1ctlDlMessage l1_dl;
2200 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl {
2201 log("TCH received: ", l1_dl.payload.traffic_ind.data);
Philipp Maier149c3922020-10-22 17:29:36 +02002202
2203 /* occasionaly inject FACCH frames into the uplink */
2204 if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) {
2205 var octetstring pl := '010301'O;
2206 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
2207 f_pad_oct(pl, 23, '2B'O)));
2208 } else {
2209 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id,
2210 l1_dl.payload.traffic_ind.data));
2211 }
2212
Vadim Yanitskiydc008112020-10-19 14:42:04 +07002213 repeat;
2214 }
2215}
2216
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002217private type record MeasElem {
Harald Welte70767382018-02-21 12:16:40 +01002218 uint6_t rxlev,
2219 uint3_t rxqual
2220}
2221
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002222private type record MeasElemFS {
Harald Welte70767382018-02-21 12:16:40 +01002223 MeasElem full,
2224 MeasElem sub
2225}
2226
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002227private type record ConnL1Pars {
Harald Welte70767382018-02-21 12:16:40 +01002228 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01002229 boolean toa256_enabled,
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +01002230 boolean meas_valid,
Harald Welte70767382018-02-21 12:16:40 +01002231 MeasElemFS meas_ul,
2232 int16_t timing_offset_256syms,
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002233 uint4_t bs_power_level,
Harald Welte70767382018-02-21 12:16:40 +01002234 uint5_t ms_power_level,
Philipp Maier149c3922020-10-22 17:29:36 +02002235 uint8_t ms_actual_ta,
2236 boolean facch_enabled
Harald Welte70767382018-02-21 12:16:40 +01002237}
2238
2239/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
2240private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
2241 return 63 + (toffs256s/256);
2242}
2243
Harald Welted5684392018-03-10 18:22:04 +01002244private function f_max(integer a, integer b) return integer {
2245 if (a > b) {
2246 return a;
2247 } else {
2248 return b;
2249 }
2250}
2251
2252private function f_min(integer a, integer b) return integer {
2253 if (a < b) {
2254 return a;
2255 } else {
2256 return b;
2257 }
2258}
2259
2260/* compute negative tolerance val-tolerance, ensure >= min */
2261private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
2262 val := val - tolerance;
2263 return f_max(val, min);
2264}
2265
2266/* compute positive tolerance val+tolerance, ensure <= max */
2267private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
2268 val := val + tolerance;
2269 return f_min(val, max);
2270}
2271
2272/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
2273private function f_tolerance(integer val, integer min, integer max, integer tolerance)
2274return template integer {
2275 var template integer ret;
2276 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
2277 return ret;
2278}
2279
2280
Harald Welte70767382018-02-21 12:16:40 +01002281/* build a template for matching measurement results against */
2282private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
2283 var ConnL1Pars l1p := g_pars.l1_pars;
2284 var template RSL_IE_UplinkMeas ul_meas := {
2285 len := 3,
2286 rfu := '0'B,
2287 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01002288 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01002289 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01002290 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01002291 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01002292 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
2293 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01002294 supp_meas_info := omit
2295 };
Harald Welte685d5982018-02-27 20:42:05 +01002296 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02002297 ul_meas.len := (3+8);
2298 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002299 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02002300 toa256_min := ?,
2301 toa256_max := ?,
2302 toa256_std_dev := ?
2303 }
Harald Welte685d5982018-02-27 20:42:05 +01002304 }
Harald Welte70767382018-02-21 12:16:40 +01002305 var template RSL_IE_BS_Power bs_power := {
2306 reserved := 0,
2307 epc := false,
2308 fpc := false,
2309 power_level := l1p.bs_power_level
2310 };
2311 var template RSL_IE_L1Info l1_info := {
2312 ms_power_lvl := l1p.ms_power_level,
2313 fpc := false,
2314 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002315 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01002316 };
2317 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002318 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01002319 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
2320 ?, t_toffs);
2321}
2322
Philipp Maierdd841d32019-12-17 14:44:54 +01002323/* build a template for matching measurement results that do not contain any
2324 * MS related measurement (l1_info, l3_info and ms timing offset). */
2325private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
2326 var ConnL1Pars l1p := g_pars.l1_pars;
2327 var template RSL_IE_UplinkMeas ul_meas := {
2328 len := 3,
2329 rfu := '0'B,
2330 dtx_d := l1p.dtx_enabled,
2331 rxlev_f_u := ?,
2332 reserved1 := '00'B,
2333 rxlev_s_u := ?,
2334 reserved2 := '00'B,
2335 rxq_f_u := ?,
2336 rxq_s_u := ?,
2337 supp_meas_info := omit
2338 };
2339 if (l1p.toa256_enabled) {
2340 ul_meas.len := (3+8);
2341 ul_meas.supp_meas_info := {
2342 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
2343 toa256_min := ?,
2344 toa256_max := ?,
2345 toa256_std_dev := ?
2346 }
2347 }
2348 var template RSL_IE_BS_Power bs_power := {
2349 reserved := 0,
2350 epc := false,
2351 fpc := false,
2352 power_level := l1p.bs_power_level
2353 };
2354
2355 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
2356}
2357
Harald Welte70767382018-02-21 12:16:40 +01002358/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002359private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01002360 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01002361 var boolean chan_est := false;
2362
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07002363 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01002364
2365 /* Receive osmocom specific measurement reports. This is the normal
2366 * case. Here we verify that the measurement reports we sent are
2367 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01002368 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
2369 /* increment counter of next to-be-expected meas rep */
2370 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2371 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01002372 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01002373
2374 /* The following two cases may only happen in the beginning
2375 * of the channel establishment phase. Once we have received
2376 * the "our" measurement report the first time, the channel
2377 * is established and empty or hardcoded TRXCON reports must
2378 * not occur anymore. */
2379 chan_est := true;
2380
2381 repeat;
2382 }
2383
2384 /* When the BTS has established the channel, the MS might need slightly
2385 * more time to establish the channel and actually start sending. The
2386 * result is then a measurement report that just lacks the measurement
2387 * information of the MS. This is normal and we tolerate this behavior. */
2388 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
2389 /* increment counter of next to-be-expected meas rep */
2390 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2391 /* Re-start the timer expecting the next MEAS RES */
2392 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01002393 repeat;
2394 }
Philipp Maierdd841d32019-12-17 14:44:54 +01002395
2396 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
2397 * measurements if the TTCN3 side does not supply measurement input in
2398 * time. In those cases TRXCON will either use a cached measurement
2399 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
2400 * report the templates above will not match. We tolerate this
2401 * behavior, but only once. */
2402 [chan_est == false] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01002403 /* increment counter of next to-be-expected meas rep */
2404 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2405 if (g_first_meas_res) {
2406 g_first_meas_res := false;
2407 repeat;
2408 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002409 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01002410 }
Harald Welte70767382018-02-21 12:16:40 +01002411 }
2412 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002413 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01002414 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02002415 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002416 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01002417 }
2418}
2419
Harald Weltee613f962018-04-18 22:38:16 +02002420private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
2421 select (rsl_alg_id) {
2422 case (RSL_ALG_ID_A5_0) { return 0; }
2423 case (RSL_ALG_ID_A5_1) { return 1; }
2424 case (RSL_ALG_ID_A5_2) { return 2; }
2425 case (RSL_ALG_ID_A5_3) { return 3; }
2426 case (RSL_ALG_ID_A5_4) { return 4; }
2427 case (RSL_ALG_ID_A5_5) { return 5; }
2428 case (RSL_ALG_ID_A5_6) { return 6; }
2429 case (RSL_ALG_ID_A5_7) { return 7; }
2430 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002431 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
2432 /* Make compiler happy by calling mtc.stop here. It is already
2433 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02002434 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02002435 }
2436 }
2437}
2438
2439private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
2440 select (rsl_alg_id) {
2441 case (RSL_ALG_ID_A5_1) { return '000'B; }
2442 case (RSL_ALG_ID_A5_2) { return '001'B; }
2443 case (RSL_ALG_ID_A5_3) { return '010'B; }
2444 case (RSL_ALG_ID_A5_4) { return '011'B; }
2445 case (RSL_ALG_ID_A5_5) { return '100'B; }
2446 case (RSL_ALG_ID_A5_6) { return '101'B; }
2447 case (RSL_ALG_ID_A5_7) { return '110'B; }
2448 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002449 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
2450 /* Make compiler happy by calling mtc.stop here. It is already
2451 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02002452 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02002453 }
2454 }
2455}
2456
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02002457/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
2458private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
2459 var GsmFrameNumber fn;
2460 timer T := 8.0;
2461
2462 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
2463 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
2464
2465 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
2466 /* Send the actual RACH */
2467 fn := f_L1CTL_RACH(L1CTL, ra);
2468
2469 T.start;
2470 alt {
2471 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
2472 [] T.timeout {
2473 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
2474 }
2475 }
2476 T.stop
2477 return fn;
2478}
Harald Weltee613f962018-04-18 22:38:16 +02002479
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002480/* Tune to a dedicated channel: L1CTL only */
2481private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002482 if (not pars.fhp.enabled) {
Vadim Yanitskiyf54db112020-11-16 18:00:15 +07002483 var TrxParsItem trx_pars := mp_trx_pars[pars.trx_nr];
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002484 pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc,
Vadim Yanitskiyf54db112020-11-16 18:00:15 +07002485 trx_pars.arfcn));
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002486 } else {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002487 pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc,
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002488 pars.fhp.maio_hsn.hsn,
2489 pars.fhp.maio_hsn.maio,
2490 pars.fhp.ma));
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002491 }
2492}
2493
Harald Welte70767382018-02-21 12:16:40 +01002494/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02002495private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002496 var ChannelDescription ch_desc;
Harald Welte70767382018-02-21 12:16:40 +01002497
2498 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02002499 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01002500
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002501 /* Craft channel description (with or without frequency hopping parameters) */
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002502 if (g_pars.fhp.enabled) {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002503 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002504 } else {
Vadim Yanitskiyf54db112020-11-16 18:00:15 +07002505 var TrxParsItem trx_pars := mp_trx_pars[g_pars.trx_nr];
2506 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, trx_pars.arfcn, g_pars.tsc));
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002507 }
2508
Harald Welte70767382018-02-21 12:16:40 +01002509 /* enable dedicated mode */
Vadim Yanitskiyd0eb6592021-10-08 01:19:29 +06002510 f_l1ctl_est_dchan(L1CTL, g_pars);
2511
Harald Weltee613f962018-04-18 22:38:16 +02002512 /* enable encryption, if requested */
2513 if (encr_enable) {
2514 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
2515 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
2516 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01002517
Vadim Yanitskiy52787bf2020-10-19 17:34:52 +07002518 /* Send TCH Mode Request to the L1 if needed */
2519 if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) {
2520 var L1ctlTchMode tch_mode;
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +02002521 var uint8_t amr_start_codec := 0;
2522 var BIT8 amr_codecs_bitmask := '00000000'B;
Vadim Yanitskiy52787bf2020-10-19 17:34:52 +07002523
2524 select (g_pars.chan_mode.coding_alg_rate) {
2525 case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; }
2526 case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; }
2527 case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; }
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +02002528 case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3;
2529 amr_codecs_bitmask := g_pars.mr_conf.amr_codec_modes;
2530 }
Vadim Yanitskiy52787bf2020-10-19 17:34:52 +07002531 case else {
2532 log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate,
2533 " is not supported by the L1, falling back to signalling");
2534 tch_mode := L1CTL_CHAN_MODE_SIGN;
2535 }
2536 }
2537
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +02002538 f_L1CTL_TCH_MODE(L1CTL,
2539 ts_L1CTL_TCH_MODE_REQ(tch_mode,
2540 amr_start_codec := amr_start_codec,
2541 amr_codecs_bitmask := amr_codecs_bitmask));
Vadim Yanitskiy52787bf2020-10-19 17:34:52 +07002542 }
2543
Harald Weltefa45e9e2018-03-10 18:59:03 +01002544 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01002545}
2546
Pau Espin Pedrol091c5302022-09-02 18:11:12 +02002547private function get_start_amr_ft() runs on ConnHdlr return integer {
2548 var integer start_nth;
2549 if (g_pars.mr_conf.icmi) {
2550 start_nth := 0; /* FIXME: implement 3GPP TS 45.009 3.4.3 */
2551 } else {
2552 start_nth := g_pars.mr_conf.start_mode;
2553 }
2554
2555 var integer n := 0;
2556 for (var integer i:= 7; i >= 0; i := i - 1) {
2557 if (g_pars.mr_conf.amr_codec_modes[i] == '1'B) {
2558 if (n == start_nth) {
2559 return 7 - i;
2560 }
2561 n := n + 1;
2562 }
2563 }
2564 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2565 log2str("mr_conf is wrong! ", g_pars.mr_conf));
2566 return 0;
2567}
2568
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002569/* Initialize and start the RTP emulation component for a ConnHdlr */
2570friend function f_rtpem_activate(inout octetstring payload,
2571 RtpemConfig cfg := c_RtpemDefaultCfg,
2572 RtpemMode mode := RTPEM_MODE_BIDIR)
2573runs on ConnHdlr {
2574 /* Step 0: initialize, connect and start the emulation component */
2575 vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM");
2576 map(vc_RTPEM:RTP, system:RTP);
2577 map(vc_RTPEM:RTCP, system:RTCP);
2578 connect(vc_RTPEM:CTRL, self:RTPEM_CTRL);
2579 connect(vc_RTPEM:DATA, self:RTPEM_DATA);
2580 vc_RTPEM.start(RTP_Emulation.f_main());
2581
2582 /* Step 1: configure the RTP parameters */
2583 var integer payload_len := 0;
2584 var octetstring hdr := ''O;
2585
2586 select (g_pars.chan_mode) {
2587 case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */
2588 { payload_len := 33; hdr := 'D0'O; }
2589 case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */
2590 { payload_len := 15; hdr := '00'O; }
2591 case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */
2592 { payload_len := 31; hdr := 'C0'O; }
Pau Espin Pedrol091c5302022-09-02 18:11:12 +02002593 case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3)) /* TCH/AFS */
2594 {
2595 var integer amr_ft := get_start_amr_ft();
2596 payload_len := f_amrft_payload_len(amr_ft) + 2;
2597 hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B)));
2598 }
2599 case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3)) /* TCH/AHS */
2600 {
2601 var integer amr_ft := get_start_amr_ft();
2602 payload_len := f_amrft_payload_len(amr_ft) + 2;
2603 hdr := enc_RTP_AMR_Hdr(valueof(ts_RTP_AMR_Hdr(amr_ft, amr_ft, '1'B)));
2604 }
2605 case else {
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002606 setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode);
2607 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2608 }
2609 }
2610
2611 /* Pad the payload to conform the expected length */
2612 payload := f_pad_oct(hdr & payload, payload_len, '00'O);
2613 cfg.tx_fixed_payload := payload;
2614 f_rtpem_configure(RTPEM_CTRL, cfg);
2615
2616 /* Step 2: bind the RTP emulation to the configured address */
2617 var PortNumber rtpem_bind_port := mp_rtpem_bind_port;
2618 f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port);
2619
Vadim Yanitskiy0dd96e92022-05-01 01:36:12 +03002620 /* Step 3a: send CRCX to create an RTP connection at the IUT */
2621 var RSL_Message crcx_ack := f_rsl_transceive_ret(
2622 /* FIXME (OS#5242): do not include Remote IP/Port IEs because
2623 * osmo-bts would respond with nonsense listen addr='0.0.0.0'. */
2624 ts_RSL_IPA_CRCX(g_chan_nr, omit, omit),
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002625 tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2626 "IPA CRCX ACK");
Vadim Yanitskiy0dd96e92022-05-01 01:36:12 +03002627 var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002628
Vadim Yanitskiy0dd96e92022-05-01 01:36:12 +03002629 /* Step 3b: send MDCX with the configured address/port to the IUT */
2630 var RSL_Message mdcx_ack := f_rsl_transceive_ret(
2631 ts_RSL_IPA_MDCX(g_chan_nr, conn_id,
2632 remote_ip := f_inet_addr(mp_rtpem_bind_ip),
2633 remote_port := rtpem_bind_port,
2634 rtp_pt2 := 0),
2635 tr_RSL_IPA_MDCX_ACK(g_chan_nr, conn_id, ?, ?, ?),
2636 "IPA MDCX ACK");
2637
2638 /* Step 4: connect to the IUT's address/port parsed from MDCX ACK */
2639 var HostName bts_bind_ip := f_inet_ntoa(mdcx_ack.ies[2].body.ipa_local_ip);
2640 var PortNumber bts_bind_port := mdcx_ack.ies[3].body.ipa_local_port;
2641 f_rtpem_connect(RTPEM_CTRL, bts_bind_ip, bts_bind_port);
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002642
2643 /* Step 5: set the given RTP emulation mode */
2644 f_rtpem_mode(RTPEM_CTRL, mode);
2645}
2646
Harald Welte70767382018-02-21 12:16:40 +01002647/* establish DChan, verify existance + contents of measurement reports */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002648private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002649 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002650 RSL.clear;
2651
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07002652 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02002653 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002654 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002655 }
Harald Welte70767382018-02-21 12:16:40 +01002656
2657 f_est_dchan();
2658
2659 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
2660 * RSL measurement reports on Abis side */
2661 timer T := 8.0;
2662 T.start;
2663 alt {
2664 [] as_l1_sacch();
2665 [] as_meas_res();
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +07002666 [] as_l1_dcch_loop();
Vadim Yanitskiydc008112020-10-19 14:42:04 +07002667 [] as_l1_tch_loop();
Harald Welte70767382018-02-21 12:16:40 +01002668 [] L1CTL.receive { repeat; }
2669 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002670 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01002671 * of any earlier errors, so if we reach this timeout, we're good */
2672 setverdict(pass);
2673 }
2674 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002675 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01002676 }
2677 }
2678 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01002679 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01002680}
Harald Welte0472ab42018-03-12 15:02:26 +01002681
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002682/* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */
2683private function f_wait_ramp_up() runs on ConnHdlr return integer {
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002684 var L1ctlDlMessage l1_dl;
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002685 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2686 timer Tup := 10.0;
2687 Tup.start;
2688 alt {
2689 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2690 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2691 log("Received rx_level=", rx_lvl);
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002692
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002693 if (rx_lvl != max_rx_lvl) {
2694 repeat;
2695 }
2696 Tup.stop;
2697 }
2698 [] L1CTL.receive { repeat; }
2699 [] Tup.timeout {
2700 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2701 log2str("Didn't reach full power ", max_rx_lvl));
2702 }
2703 }
2704 return max_rx_lvl;
2705}
2706
2707/* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */
2708private function f_verify_ramp_up() runs on ConnHdlr {
2709 var L1ctlDlMessage l1_dl;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002710 var integer initial_rx_lvl := -1;
2711 var integer last_rx_lvl := -1;
2712 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2713
2714 timer T := 2.0;
2715 alt {
2716 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2717 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2718 log("Received rx_level=", rx_lvl);
2719 if (initial_rx_lvl == -1) {
2720 initial_rx_lvl := rx_lvl;
2721 last_rx_lvl := rx_lvl;
2722
2723 /* Expect a somehow low value during first received messages */
2724 if (initial_rx_lvl >= max_rx_lvl / 2) {
2725 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2726 log2str("Detected high initial tx power during ramp up: ",
2727 initial_rx_lvl , ", full power is", max_rx_lvl));
2728 }
2729 }
2730
2731 /* received Rx level bigger than maximum allowed power by CN */
2732 if (rx_lvl > max_rx_lvl) {
2733 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2734 log2str("Detected Tx power higher than full power: ",
2735 rx_lvl , " > ", max_rx_lvl));
2736 }
2737
2738 /* Make sure it never decreases, since we are rumping up */
2739 if (last_rx_lvl > rx_lvl) {
2740 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2741 log2str("Detected Tx power decrease during ramp up: ",
2742 last_rx_lvl , " -> ", rx_lvl));
2743 }
2744
2745 if (rx_lvl == max_rx_lvl and not T.running) {
2746 /* We reached the maximum power, start timer and receive
2747 /* a few more to make sure we don't surpass it */
2748 log("Reached full power, wating a bit more until success");
2749 T.start;
2750 }
2751
2752 last_rx_lvl := rx_lvl;
2753 repeat;
2754 }
2755 [] L1CTL.receive { repeat; }
2756 [] T.timeout { }
2757 }
2758
2759 /* We didn't increase tx power during ramp up */
2760 if (initial_rx_lvl < last_rx_lvl) {
2761 log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl);
2762 } else {
2763 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2764 log2str("No Tx power increase during whole ramp up: ",
2765 initial_rx_lvl , " -> ", last_rx_lvl));
2766 }
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002767}
2768
2769/* verify BTS ramps power down to rx_level 0 */
2770private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr {
2771 var L1ctlDlMessage l1_dl;
2772 var integer last_rx_lvl := max_rx_lvl;
2773
2774 timer Tdown := 5.0;
2775 Tdown.start;
2776 alt {
2777 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2778 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2779 log("Received rx_level=", rx_lvl);
2780
2781 /* received Rx level bigger than maximum allowed power by CN */
2782 if (rx_lvl > max_rx_lvl) {
2783 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2784 log2str("Detected Tx power higher than full power: ",
2785 rx_lvl , " > ", max_rx_lvl));
2786 }
2787
2788 /* Make sure it never increases, since we are rumping down */
2789 if (last_rx_lvl < rx_lvl) {
2790 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2791 log2str("Detected Tx power increase during ramp up: ",
2792 last_rx_lvl , " -> ", rx_lvl));
2793 }
2794
2795 last_rx_lvl := rx_lvl;
2796 if (last_rx_lvl != 0) {
2797 repeat;
2798 }
2799 /* we reached power level 0, we are done */
2800 Tdown.stop;
2801 }
2802 [] L1CTL.receive { repeat; }
2803 [] Tdown.timeout { }
2804 }
2805
2806 /* We didn't increase tx power during ramp down */
2807 if (max_rx_lvl > last_rx_lvl) {
2808 log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl);
2809 } else {
2810 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2811 log2str("No Tx power decrease during whole ramp down: ",
2812 max_rx_lvl , " -> ", last_rx_lvl));
2813 }
2814}
2815
2816/* Verify Tx power reduction and ramping up during BTS bring up */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002817private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002818 f_l1_tune(L1CTL);
2819 RSL.clear;
2820
2821 f_verify_ramp_up();
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002822
2823 setverdict(pass);
2824}
2825testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT {
2826 var ConnHdlr vc_conn;
2827 var ConnHdlrPars pars;
2828 f_init();
2829 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2830 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars,
2831 pcu_comp := false, trxc_comp := true);
2832 vc_conn.done;
2833 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2834}
2835
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002836/* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002837private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002838 f_connhdlr_init_vty_bsc();
2839
2840 f_l1_tune(L1CTL);
2841 RSL.clear;
2842
2843 /* Wait until BTS is started and at full power */
2844 var integer max_rx_lvl := f_wait_ramp_up();
2845 log("Reached nominal level ", max_rx_lvl, ", shutting down OML link");
2846
2847 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2848 f_verify_ramp_down(max_rx_lvl);
2849
2850 setverdict(pass);
2851}
2852testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT {
2853 var ConnHdlr vc_conn;
2854 var ConnHdlrPars pars;
2855 f_init();
2856 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2857 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars,
2858 pcu_comp := false, trxc_comp := true);
2859 vc_conn.done;
2860 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2861}
2862
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002863/* Verify Tx power:
2864 * + ramping down during ADM state UNLOCKED->LOCKED
2865 * + ramping up during ADM state LOCKED->UNLOCKED
2866 */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002867private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr {
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002868 var L1ctlDlMessage l1_dl;
2869 var integer last_rx_lvl;
2870
2871 f_connhdlr_init_vty_bsc();
2872
2873 f_l1_tune(L1CTL);
2874 RSL.clear;
2875
2876 /* Wait until BTS is started and at full power */
2877 var integer max_rx_lvl := f_wait_ramp_up();
2878 log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED");
2879
2880 log("ADM STATE UNLOCKED->LOCKED");
2881 f_vty_enter_cfg_trx(BSCVTY);
2882 f_vty_transceive(BSCVTY, "rf_locked 1");
2883 last_rx_lvl := max_rx_lvl;
2884 f_verify_ramp_down(max_rx_lvl);
2885
2886 /* Let some time after we received 0dBm, then check we don't receive BCCH
2887 * anymore because scheduler has stopped after ramping down */
2888 f_sleep(2.0);
2889 L1CTL.clear;
2890 timer Tlocked := 2.0;
2891 Tlocked.start;
2892 alt {
2893 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2894 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2895 log2str("Received data_ind during rf_locked: ", l1_dl));
2896 }
2897 [] L1CTL.receive { repeat; }
2898 [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); }
2899 }
2900
2901 log("ADM STATE LOCKED->UNLOCKED");
2902 f_vty_transceive(BSCVTY, "rf_locked 0");
2903 f_verify_ramp_up();
2904 setverdict(pass);
2905}
2906testcase TC_tx_power_ramp_adm_state_change() runs on test_CT {
2907 var ConnHdlr vc_conn;
2908 var ConnHdlrPars pars;
2909 f_init();
2910 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2911 vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars,
2912 pcu_comp := false, trxc_comp := true);
2913 vc_conn.done;
2914 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2915}
2916
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002917private function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002918 timer T := 8.0;
2919 T.start;
2920 var RSL_Message rsl;
2921 alt {
2922 [] as_l1_sacch();
2923 [] L1CTL.receive { repeat; }
2924 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
2925 if (rsl.ies[3].body.bs_power.power_level == level) {
2926 setverdict(pass)
2927 } else {
2928 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
2929 }
2930 }
2931 [] T.timeout {
2932 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
2933 }
2934 }
2935}
2936
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002937/* See if the RSL MEASurement RESult contains expeced BS power level
2938 * set _during_ the CHANnel ACTIVation procedure. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002939private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002940 f_l1_tune(L1CTL);
2941 RSL.clear;
2942
2943 if (mp_bts_trxc_port != -1) {
2944 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2945 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2946 }
2947
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002948 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002949 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2950 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2951
2952 f_est_dchan(more_ies :={valueof(pwr)});
2953
2954 f_check_meas_bs_power_level(pwr_var);
2955
2956 f_rsl_chan_deact();
2957 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2958}
2959
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002960/* See if the RSL MEASurement RESult contains expeced BS power level
2961 * set _after_ the CHANnel ACTIVation procedure. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002962private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002963 f_l1_tune(L1CTL);
2964 RSL.clear;
2965
2966 if (mp_bts_trxc_port != -1) {
2967 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2968 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2969 }
2970
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002971 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002972 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2973
2974 f_est_dchan();
2975
2976 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2977
2978 f_check_meas_bs_power_level(pwr_var);
2979
2980 f_rsl_chan_deact();
2981 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2982}
2983
2984testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2985 var ConnHdlr vc_conn;
2986 var ConnHdlrPars pars;
Vadim Yanitskiyda5964d2021-10-23 16:27:27 +03002987
Eric Wildae8f2622019-06-18 17:05:11 +02002988 f_init();
Vadim Yanitskiyda5964d2021-10-23 16:27:27 +03002989
2990 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1));
2991 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2992 pcu_comp := false, trxc_comp := true);
2993 vc_conn.done;
2994
Eric Wildae8f2622019-06-18 17:05:11 +02002995 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2996}
2997
2998testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2999 var ConnHdlr vc_conn;
3000 var ConnHdlrPars pars;
Vadim Yanitskiyda5964d2021-10-23 16:27:27 +03003001
Eric Wildae8f2622019-06-18 17:05:11 +02003002 f_init();
Vadim Yanitskiyda5964d2021-10-23 16:27:27 +03003003
3004 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN, trx_nr := 1));
3005 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
3006 pcu_comp := false, trxc_comp := true);
3007 vc_conn.done;
3008
Eric Wildae8f2622019-06-18 17:05:11 +02003009 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3010}
3011
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02003012/* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
3013 * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds.
3014 * These power levels are valid for all bands and require no special handling. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003015private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02003016 var uint5_t pwr_var := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003017 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003018
3019 f_trxc_fake_rssi(rxlev2dbm(10));
3020 f_l1_tune(L1CTL);
3021 RSL.clear;
3022
3023 var RSL_IE_List addl_ies;
3024 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
3025
3026 addl_ies := {
3027 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
3028 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
3029 };
3030
3031 /* establish with power parameters */
3032 f_est_dchan(more_ies := addl_ies);
3033
3034 /* set a high value to ensure L1 power control level increases */
3035 f_trxc_fake_rssi(rxlev2dbm(20));
3036
3037 timer T2 := 6.0;
3038 T2.start;
3039 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003040 [] as_l1_sacch_l1h(l1h) {
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +07003041 f_send_meas_rep_l1h(ts_MeasurementResults, l1h);
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003042
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003043 if (l1h.ms_power_lvl < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003044 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01003045 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003046 T2.stop;
3047 }
3048 [] L1CTL.receive { repeat; }
3049 [] T2.timeout {
3050 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3051 "Power Level in L1 header has not increased sufficiently");
3052 }
3053 }
3054
3055 /* set a low value to ensure L1 power control level decreases */
3056 f_trxc_fake_rssi(rxlev2dbm(0));
3057
3058 timer T4 := 6.0;
3059 T4.start;
3060 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003061 [] as_l1_sacch_l1h(l1h) {
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +07003062 f_send_meas_rep_l1h(ts_MeasurementResults, l1h);
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003063
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003064 if (l1h.ms_power_lvl > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003065 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01003066 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003067 T4.stop;
3068 setverdict(pass, "Power level in L1 decreased/increased as expected");
3069 }
3070 [] L1CTL.receive { repeat; }
3071 [] T4.timeout {
3072 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3073 "Power Level in L1 header has not decreased sufficiently");
3074 }
3075 }
3076
3077 f_rsl_chan_deact();
3078 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3079
3080}
3081
3082/* check that we do not exceed the max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003083private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02003084 var uint5_t pwr_var := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003085 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003086
3087 /* set a low value to ensure power increases */
3088 f_trxc_fake_rssi(rxlev2dbm(10));
3089 f_l1_tune(L1CTL);
3090 RSL.clear;
3091
3092 var RSL_IE_List addl_ies;
3093 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
3094
3095 addl_ies := {
3096 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
3097 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
3098 };
3099
3100 /* establish with power parameters */
3101 f_est_dchan(more_ies := addl_ies);
3102
3103 timer T1 := 10.0;
3104 T1.start;
3105 alt {
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003106 [] as_l1_sacch_l1h(l1h) {
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +07003107 f_send_meas_rep_l1h(ts_MeasurementResults, l1h);
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003108 repeat;
3109 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003110 [] L1CTL.receive { repeat; }
3111 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003112 if (not isbound(l1h)) {
3113 setverdict(fail, "No SACCH blocks were received");
3114 } else if (l1h.ms_power_lvl != pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003115 setverdict(fail, "Power level in L1 header should not have changed");
3116 }
3117 }
3118 }
3119
3120 f_rsl_chan_deact();
3121 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3122
3123}
3124
3125/* see if we reach the band max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003126private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003127 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003128 var uint5_t pwr_var := 15;
3129 var uint5_t pwr_max_var := f_get_max_power_from_band();
3130
3131 /* set a low value to ensure power increases */
3132 f_trxc_fake_rssi(rxlev2dbm(10));
3133 f_l1_tune(L1CTL);
3134 RSL.clear;
3135
3136 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
3137 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
3138
3139 /* establish with fixed power level */
3140 f_est_dchan(more_ies :={valueof(pwr)});
3141
3142 /* check our initial power level */
3143 f_wait_for_l1_power_level(pwr_var);
3144
3145 /* update power param to enable power loop
3146 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
3147 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
3148
Vadim Yanitskiy93ad8142022-04-08 01:52:13 +03003149 /* By default, the MS power loop gets triggered every 4th SACCH block (1.92s).
3150 * We need 9 * 4 dB steps to get from 0 dBm to 33 dBm, so 9 * 1.92s total.
3151 * Add an extra offset to avoid race conditions: +1.92s. */
3152 timer T1 := 9.0 * 1.92 + 1.92;
Eric Wild61edb7e2019-06-03 12:38:31 +02003153 T1.start;
3154 alt {
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003155 [] as_l1_sacch_l1h(l1h) {
Vadim Yanitskiya2cd8932022-08-10 17:56:25 +07003156 f_send_meas_rep_l1h(ts_MeasurementResults, l1h);
Vadim Yanitskiy39994912022-07-30 18:06:13 +07003157 repeat;
3158 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003159 [] L1CTL.receive { repeat; }
3160 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003161 if (not isbound(l1h)) {
3162 setverdict(fail, "No SACCH blocks were received");
3163 } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003164 setverdict(pass, "Power level in L1 header reduced as expected");
3165 } else {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003166 setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ",
3167 "reach the expected value := ", pwr_max_var);
Eric Wild61edb7e2019-06-03 12:38:31 +02003168 }
3169 }
3170 }
3171
3172 f_rsl_chan_deact();
3173 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3174
3175}
3176
3177/* see if we reach the band min power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003178private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003179 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003180
3181 /* set a high value to ensure power decreases */
3182 f_trxc_fake_rssi(rxlev2dbm(50));
3183 f_l1_tune(L1CTL);
3184 RSL.clear;
3185
3186 var uint5_t pwr_var := 5;
3187 var uint5_t pwr_target_val := 15;
3188
3189 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
3190 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
3191
3192 /* establish with fixed power level */
3193 f_est_dchan(more_ies :={valueof(pwr)});
3194
3195 /* check our initial power level */
3196 f_wait_for_l1_power_level(pwr_var);
3197
3198 /* update power param to enable power loop
3199 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01003200 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02003201
3202 /* wait, then check that our power level was increased */
3203 timer T1 := 10.0;
3204 T1.start;
3205 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003206 [] as_l1_sacch_l1h(l1h) { repeat; }
Eric Wild61edb7e2019-06-03 12:38:31 +02003207 [] L1CTL.receive { repeat; }
3208 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003209 if (not isbound(l1h)) {
3210 setverdict(fail, "No SACCH blocks were received");
3211 } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) {
3212 setverdict(pass, "Power level increased to lowest power value");
Eric Wild61edb7e2019-06-03 12:38:31 +02003213 } else {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003214 setverdict(fail, "Power level NOT increased to lowest power value");
Eric Wild61edb7e2019-06-03 12:38:31 +02003215 }
3216 }
3217 }
3218
3219 f_rsl_chan_deact();
3220 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3221
3222}
3223
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02003224/* See if the power level remains constant when MS Power Parameters IE
3225 * is _absent_ in the CHANnel ACTIVation message. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003226private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003227 var SacchL1Header l1h;
Eric Wild280ccb82019-06-17 11:11:52 +02003228
3229 /* set a high value to ensure power decreases */
3230 f_trxc_fake_rssi(rxlev2dbm(50));
3231 f_l1_tune(L1CTL);
3232 RSL.clear;
3233
3234 var uint5_t pwr_var := 5;
3235
3236 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
3237 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
3238
3239 /* establish with fixed power level */
3240 f_est_dchan(more_ies :={valueof(pwr)});
3241
3242 /* check our initial power level */
3243 f_wait_for_l1_power_level(pwr_var);
3244
3245 /* wait, then check that our power level did not change */
3246 timer T1 := 10.0;
3247 T1.start;
3248 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003249 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3250 if (l1h.ms_power_lvl != pwr_var) {
Eric Wild280ccb82019-06-17 11:11:52 +02003251 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3252 "BS power control should not be active unless we receive a power parameters IE!");
3253 }
3254 repeat;
3255 }
3256 [] L1CTL.receive { repeat; }
3257 [] T1.timeout { setverdict(pass); }
3258 }
3259
3260 f_rsl_chan_deact();
3261 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3262
3263}
3264
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02003265/* See if the power level remains constant when MS Power Parameters IE
3266 * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003267private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003268 var SacchL1Header l1h;
Eric Wild095024b2019-06-17 15:08:57 +02003269
3270 /* set a high value to ensure power decreases */
3271 f_trxc_fake_rssi(rxlev2dbm(50));
3272 f_l1_tune(L1CTL);
3273 RSL.clear;
3274
3275 var uint5_t pwr_var := 5;
3276
3277 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
3278 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
3279
3280 /* establish with fixed power level */
3281 f_est_dchan(more_ies :={valueof(pwr)});
3282
3283 /* check our initial power level */
3284 f_wait_for_l1_power_level(pwr_var);
3285
3286 /* pwr control without power params IE, should NOT activate MS power control*/
3287 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
3288
3289 /* wait, then check that our power level did not change */
3290 timer T1 := 10.0;
3291 T1.start;
3292 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003293 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3294 if (l1h.ms_power_lvl != pwr_var) {
Eric Wild095024b2019-06-17 15:08:57 +02003295 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3296 "BS power control should not be active unless we receive a power parameters IE!");
3297 }
3298 repeat;
3299 }
3300 [] L1CTL.receive { repeat; }
3301 [] T1.timeout { setverdict(pass); }
3302 }
3303
3304 f_rsl_chan_deact();
3305 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3306
3307}
3308
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003309private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003310 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003311 timer T0 := 10.0;
3312 T0.start;
3313 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003314 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3315 if (l1h.ms_power_lvl != level) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003316 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3317 "Power level in L1 header != signaled (RSL) power level.");
3318 }
3319 }
3320 [] L1CTL.receive { repeat; }
3321 [] T0.timeout {
3322 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3323 "Timeout waiting for initial power level");
3324 }
3325 }
3326 T0.stop;
3327}
3328
3329private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
3330 var IntegerRecord min_dbm_level;
3331 var IntegerRecord max_dbm_level;
3332 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3333
3334 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
3335 if (min_dbm_level[i] == level) {
3336 return true;
3337 }
3338 }
3339 return false;
3340}
3341
3342private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
3343 var IntegerRecord min_dbm_level;
3344 var IntegerRecord max_dbm_level;
3345 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3346
3347 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
3348 if (max_dbm_level[i] == level) {
3349 return true;
3350 }
3351 }
3352 return false;
3353}
3354
3355private function f_get_max_power_from_band() runs on ConnHdlr return integer {
3356 var IntegerRecord min_dbm_level;
3357 var IntegerRecord max_dbm_level;
3358 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3359 return max_dbm_level[0];
3360}
3361
3362type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003363private template charstring BtsBand_allGSM := pattern "GSM???";
Eric Wild61edb7e2019-06-03 12:38:31 +02003364private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
3365 // 45.005 4.1.1
3366 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
3367 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
3368 2, 1, 0};
3369 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
3370 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
3371 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
3372 var IntegerRecord rv;
3373
3374 select(band){
3375 case (BtsBand_allGSM){
3376 rv := gsm_power;
3377 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
3378 max_dbm_level := {2, 1, 0};
3379 }
3380 case("DCS1800"){
3381 rv := dcs_power;
3382 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
3383 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
3384 }
3385 case("PCS1900"){
3386 rv := pcs_power;
3387 min_dbm_level := {15};
3388 max_dbm_level := {30};
3389 }
Harald Welte194b6912020-10-11 21:01:55 +02003390 case else {
3391 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band);
3392 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003393 }
3394
3395 return rv;
3396}
3397
3398private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
Harald Weltec935fad2020-10-11 21:02:54 +02003399 return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of*type* in band (\w+),*", 0);
Eric Wild61edb7e2019-06-03 12:38:31 +02003400}
3401
3402testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
3403 var ConnHdlr vc_conn;
3404 var ConnHdlrPars pars;
3405 f_init();
3406 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3407 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3408 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3409 pars.bts0_band := f_vty_get_bts0_band();
3410 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
3411 vc_conn.done;
3412 }
3413 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3414 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3415}
3416
3417testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
3418 var ConnHdlr vc_conn;
3419 var ConnHdlrPars pars;
3420 f_init();
3421 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
3422 for (var integer tn := 1; tn <= 1; tn := tn+1) {
Vadim Yanitskiyc78aeb72022-07-30 17:56:39 +07003423 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN, t_guard := 30.0));
Eric Wild61edb7e2019-06-03 12:38:31 +02003424 pars.bts0_band := f_vty_get_bts0_band();
3425 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
3426 vc_conn.done;
3427 }
3428 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3429 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3430}
3431
3432testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
3433 var ConnHdlr vc_conn;
3434 var ConnHdlrPars pars;
3435 f_init();
3436 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
3437 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3438 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3439 pars.bts0_band := f_vty_get_bts0_band();
3440 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
3441 vc_conn.done;
3442 }
3443 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3444 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3445}
3446
3447testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
3448 var ConnHdlr vc_conn;
3449 var ConnHdlrPars pars;
3450 f_init();
3451 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3452 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3453 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3454 pars.bts0_band := f_vty_get_bts0_band();
3455 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
3456 vc_conn.done;
3457 }
3458 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3459 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3460}
3461
Eric Wild280ccb82019-06-17 11:11:52 +02003462testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
3463 var ConnHdlr vc_conn;
3464 var ConnHdlrPars pars;
3465 f_init();
3466 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3467 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3468 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3469 pars.bts0_band := f_vty_get_bts0_band();
3470 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
3471 vc_conn.done;
3472 }
3473 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3474 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3475}
3476
Eric Wild095024b2019-06-17 15:08:57 +02003477testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
3478 var ConnHdlr vc_conn;
3479 var ConnHdlrPars pars;
3480 f_init();
3481 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3482 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3483 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3484 pars.bts0_band := f_vty_get_bts0_band();
3485 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
3486 vc_conn.done;
3487 }
3488 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3490}
3491
Philipp Maier149c3922020-10-22 17:29:36 +02003492function f_TC_meas_res_speech_tchf(boolean facch_enabled) runs on test_CT {
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003493 var template RSL_IE_ChannelMode ch_mode;
3494 var ConnHdlr vc_conn;
3495 var ConnHdlrPars pars;
3496 f_init();
3497 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1);
3498 for (var integer tn := 1; tn <= 1; tn := tn + 1) {
3499 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode));
Philipp Maier149c3922020-10-22 17:29:36 +02003500 pars.l1_pars.facch_enabled := facch_enabled;
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003501 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3502 pcu_comp := false, trxc_comp := true);
3503 vc_conn.done;
3504 }
3505 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3506}
Philipp Maier149c3922020-10-22 17:29:36 +02003507
3508testcase TC_meas_res_speech_tchf() runs on test_CT {
3509 f_TC_meas_res_speech_tchf(false);
3510}
3511
3512testcase TC_meas_res_speech_tchf_facch() runs on test_CT {
3513 f_TC_meas_res_speech_tchf(true);
3514}
3515
3516function f_TC_meas_res_speech_tchh(boolean facch_enabled) runs on test_CT {
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003517 var template RSL_IE_ChannelMode ch_mode;
3518 var ConnHdlr vc_conn;
3519 var ConnHdlrPars pars;
3520 f_init();
3521 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
3522 for (var integer ss := 0; ss <= 1; ss := ss + 1) {
3523 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
Philipp Maier149c3922020-10-22 17:29:36 +02003524 pars.l1_pars.facch_enabled := facch_enabled;
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003525 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3526 pcu_comp := false, trxc_comp := true);
3527 vc_conn.done;
3528 }
3529 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3530}
Philipp Maier149c3922020-10-22 17:29:36 +02003531
3532testcase TC_meas_res_speech_tchh() runs on test_CT {
3533 f_TC_meas_res_speech_tchh(false)
3534}
3535
3536testcase TC_meas_res_speech_tchh_facch() runs on test_CT {
3537 f_TC_meas_res_speech_tchh(true)
3538}
3539
Vadim Yanitskiy780bc072020-10-20 02:16:01 +07003540testcase TC_meas_res_speech_tchh_toa256() runs on test_CT {
3541 var template RSL_IE_ChannelMode ch_mode;
3542 var ConnHdlr vc_conn;
3543 var ConnHdlrPars pars;
3544 f_init();
3545 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
3546 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
3547 for (var integer ss := 0; ss <= 1; ss := ss + 1) {
3548 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
3549 pars.l1_pars.toa256_enabled := true;
3550 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3551 pcu_comp := false, trxc_comp := true);
3552 vc_conn.done;
3553 }
3554 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3555}
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003556
Harald Welte70767382018-02-21 12:16:40 +01003557testcase TC_meas_res_sign_tchf() runs on test_CT {
3558 var ConnHdlr vc_conn;
3559 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003560 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003561 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003562 for (var integer tn := 1; tn <= 4; tn := tn+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003563 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_F)));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07003564 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3565 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003566 vc_conn.done;
3567 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003568 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003569}
3570testcase TC_meas_res_sign_tchh() runs on test_CT {
3571 var ConnHdlr vc_conn;
3572 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003573 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003574 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003575 for (var integer ss := 0; ss <= 1; ss := ss+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003576 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
Eric Wild5b9ef142019-07-11 19:28:02 +02003577 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3578 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003579 vc_conn.done;
3580 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003581 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003582}
3583testcase TC_meas_res_sign_sdcch4() runs on test_CT {
3584 var ConnHdlr vc_conn;
3585 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003586 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003587 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003588 for (var integer ss := 0; ss <= 3; ss := ss+1) {
3589 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02003590 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3591 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003592 vc_conn.done;
3593 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003594 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003595}
3596testcase TC_meas_res_sign_sdcch8() runs on test_CT {
3597 var ConnHdlr vc_conn;
3598 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003599 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003600 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003601 for (var integer ss := 0; ss <= 7; ss := ss+1) {
3602 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02003603 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3604 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003605 vc_conn.done;
3606 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003607 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003608}
Harald Welte685d5982018-02-27 20:42:05 +01003609testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
3610 var ConnHdlr vc_conn;
3611 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003612 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01003613 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
3614 for (var integer ss := 0; ss <= 1; ss := ss+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003615 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
Harald Welte685d5982018-02-27 20:42:05 +01003616 pars.l1_pars.toa256_enabled := true;
Vadim Yanitskiy0b652192020-10-20 02:39:02 +07003617 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3618 pcu_comp := false, trxc_comp := true);
Harald Welte685d5982018-02-27 20:42:05 +01003619 vc_conn.done;
3620 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003621 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01003622}
3623
Vadim Yanitskiy8f6eae02021-10-26 02:49:21 +03003624/* Make sure that we always get RSL MEASurement RESult messages regardless
3625 * of what is sent on SACCH: (RR) Measurement Report or SAPI=3 data (SMS). */
3626private function f_TC_meas_res_sapi3(charstring id) runs on ConnHdlr {
3627 timer Texec := 8.0;
3628 timer Timpf := 2.0;
3629 timer Tmr;
3630
3631 f_l1_tune(L1CTL);
3632 RSL.clear;
3633
3634 f_est_dchan();
3635 L1CTL.clear;
3636
3637 /* Establish the main SAPI=0 link on DCCH first */
3638 f_tx_lapdm(ts_LAPDm_SABM(0, cr_MO_CMD, true, ''O), ts_RslLinkID_DCCH(0));
3639
3640 /* Give more time for the first RSL MEASurement RESult */
3641 Tmr.start(0.480 * 2.0);
3642 Texec.start; /* EXECution timer */
3643 Timpf.start; /* IMPFung timer */
3644
3645 alt {
3646 /* We expect RSL MEASurement RESult messages every ~480ms (plus some guard) */
3647 [] RSL.receive(tr_RSL_MEAS_RES(g_pars.chan_nr)) {
3648 /* Reschedule the MEAS RES timer */
3649 Tmr.start(0.480 + 0.120);
3650 repeat;
3651 }
3652 [] RSL.receive { repeat; }
3653 [] Tmr.timeout {
3654 setverdict(fail, "Timeout waiting for RSL MEAS RES");
3655 }
3656 /* Inject some SAPI=3 traffic on SACCH every 2 seconds */
3657 [] Timpf.timeout {
3658 f_tx_lapdm(ts_LAPDm_SABM(3, cr_MO_CMD, true, ''O), ts_RslLinkID_SACCH(3));
3659 log("Injected SAPI=3 traffic on SACCH");
3660 Timpf.start;
3661 repeat;
3662 }
3663 /* We're good if survived so far */
3664 [] Texec.timeout {
3665 setverdict(pass);
3666 }
3667 }
3668
3669 f_rsl_chan_deact();
3670 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3671 f_rslem_unregister(0, g_chan_nr);
3672}
3673testcase TC_meas_res_speech_tchf_sapi3() runs on test_CT {
3674 var template RSL_IE_ChannelMode ch_mode;
3675 var template ConnHdlrPars pars;
3676 var ConnHdlr vc_conn;
3677
3678 f_init();
3679
3680 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1);
3681 pars := t_Pars(t_RslChanNr_Bm(1), ch_mode);
3682
3683 vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars));
3684 vc_conn.done;
3685
3686 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3687}
3688testcase TC_meas_res_speech_tchh_sapi3() runs on test_CT {
3689 var template RSL_IE_ChannelMode ch_mode;
3690 var template ConnHdlrPars pars;
3691 var ConnHdlr vc_conn;
3692
3693 f_init();
3694
3695 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
3696 pars := t_Pars(t_RslChanNr_Lm(5, 0), ch_mode);
3697
3698 vc_conn := f_start_handler(refers(f_TC_meas_res_sapi3), valueof(pars));
3699 vc_conn.done;
3700
3701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3702}
3703
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003704/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
3705 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003706private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003707 var SacchL1Header l1h;
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003708 var RSL_IE_MS_Power ms_power;
3709 var RSL_Message rsl;
3710 var uint5_t power_level := 0;
3711
3712 f_l1_tune(L1CTL);
3713 RSL.clear;
3714
3715 f_est_dchan();
3716
3717 ms_power.reserved := 0;
3718 ms_power.fpc_epc := false;
3719
3720 /* Send the first power control command. This will disable any BTS/TRX
3721 * internal power control and switch the MS (which is not in scope of
3722 * this test) to a constant power level. We start with a power level
3723 * of 0 */
3724 ms_power.power_level := power_level;
3725 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
3726 RSL.send(rsl);
3727
3728 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003729 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3730 if (l1h.ms_power_lvl != power_level) {
3731 setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
3732 "match the signaled (RSL) power level := ", power_level);
3733 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003734 }
3735
3736 /* Signal a new power level via RSL for the next turn. */
3737 if (power_level < 31) {
3738 power_level := power_level + 1;
3739 ms_power.power_level := power_level;
3740 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
3741 RSL.send(rsl);
3742 repeat;
3743 }
3744
3745 }
3746
3747 /* Ignore all other blocks */
3748 [] L1CTL.receive { repeat; }
3749
3750 }
3751
3752 f_rsl_chan_deact();
3753 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3754
3755 setverdict(pass);
3756}
3757
3758testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
3759 var ConnHdlr vc_conn;
3760 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003761 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003762
3763 for (var integer tn := 1; tn <= 4; tn := tn+1) {
3764 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3765 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
3766 vc_conn.done;
3767 }
3768 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3769}
Harald Welte70767382018-02-21 12:16:40 +01003770
Pau Espin Pedrol188bfd22020-06-03 20:32:45 +02003771/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
Eric Wild6833cc92019-05-23 19:34:44 +02003772TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003773private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
Eric Wild6833cc92019-05-23 19:34:44 +02003774 var uint5_t ta_to_test := 16;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003775 var SacchL1Header l1h;
Eric Wild6833cc92019-05-23 19:34:44 +02003776
3777 f_l1_tune(L1CTL);
3778 RSL.clear;
3779
3780 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07003781 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02003782
3783 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
3784
3785
3786 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003787 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3788 if (l1h.actual_ta != ta_to_test) {
Eric Wild6833cc92019-05-23 19:34:44 +02003789 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
3790 }
3791
3792 }
3793
3794 /* Ignore all other blocks */
3795 [] L1CTL.receive { repeat; }
3796
3797 }
3798
3799 f_rsl_chan_deact();
3800 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3801
3802 setverdict(pass);
3803}
3804
3805testcase TC_rsl_chan_initial_ta() runs on test_CT {
3806 var ConnHdlr vc_conn;
3807 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003808 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02003809 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07003810 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
3811 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02003812 vc_conn.done;
3813 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3814}
3815
Eric Wilde57e1a62019-05-28 13:30:55 +02003816/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003817private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
Eric Wilde57e1a62019-05-28 13:30:55 +02003818 var uint5_t ms_power_level := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003819 var SacchL1Header l1h;
Eric Wilde57e1a62019-05-28 13:30:55 +02003820
3821 var RSL_IE_MS_Power ms_power;
3822 ms_power.reserved := 0;
3823 ms_power.fpc_epc := false;
3824 ms_power.power_level := ms_power_level;
3825
3826 f_l1_tune(L1CTL);
3827 RSL.clear;
3828
3829 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
3830
3831 timer T := 1.0;
3832 T.start;
3833 alt {
3834 /* Pick all SACCH blocks for checking */
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003835 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3836 if (l1h.ms_power_lvl != ms_power_level) {
3837 setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
3838 "match the signaled (RSL) power level := ", ms_power_level);
Eric Wilde57e1a62019-05-28 13:30:55 +02003839 }
3840 }
3841 /* Ignore all other blocks */
3842 [] L1CTL.receive { repeat; }
3843 [] T.timeout {
3844 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
3845 }
3846 }
3847
3848 f_rsl_chan_deact();
3849 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3850 setverdict(pass);
3851}
3852
3853testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
3854 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3855 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
3856}
3857
Harald Welte0472ab42018-03-12 15:02:26 +01003858/* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND (TS 48.058 4.10) */
Harald Welte70767382018-02-21 12:16:40 +01003859private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01003860 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01003861 RSL.clear;
3862
3863 f_est_dchan();
3864 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01003865 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01003866
3867 timer T := 40.0;
3868 T.start;
3869 alt {
3870 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
3871 setverdict(pass)
3872 }
3873 [] RSL.receive { repeat };
3874 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003875 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01003876 }
3877 }
3878 f_rsl_chan_deact();
3879}
3880testcase TC_conn_fail_crit() runs on test_CT {
3881 var ConnHdlr vc_conn;
3882 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003883 f_init();
Harald Welte70767382018-02-21 12:16:40 +01003884 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
3885 pars.t_guard := 60.0;
3886 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
3887 vc_conn.done;
3888}
3889
Harald Welte93640c62018-02-25 16:59:33 +01003890/***********************************************************************
3891 * Paging
3892 ***********************************************************************/
3893
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003894private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
Harald Welte68e495b2018-02-25 00:05:57 +01003895 if (tmsi == 'FFFFFFFF'O) {
3896 return true;
3897 } else {
3898 return false;
3899 }
3900}
Harald Welte70767382018-02-21 12:16:40 +01003901
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003902private type record allowedFn { integer frame_nr }
3903private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
3904private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
3905private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
3906private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
3907private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
3908private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
3909private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
3910private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
3911private function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
Philipp Maier82cb0b12018-08-31 14:41:39 +02003912{
3913 var integer frame_nr_51;
3914 frame_nr_51 := frame_nr mod 51
3915
3916 var allowedFn fn_check;
3917 fn_check.frame_nr := frame_nr_51;
3918
3919 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003920 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003921 return;
3922 }
3923
3924 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
3925 return;
3926 }
3927 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
3928 return;
3929 }
3930 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
3931 return;
3932 }
3933 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
3934 return;
3935 }
3936 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
3937 return;
3938 }
3939 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
3940 return;
3941 }
3942 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
3943 return;
3944 }
3945 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
3946 return;
3947 }
3948
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003949 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003950 return;
3951}
3952
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003953private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs,
3954 inout integer num_paging_rcv_ids,
3955 PagingTestCfg cfg)
Harald Welte68e495b2018-02-25 00:05:57 +01003956runs on test_CT {
3957 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01003958 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003959 repeat;
3960 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01003961 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01003962 var octetstring without_plen :=
3963 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
3964 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02003965
3966 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
3967
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07003968 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
3969 /* Ignore empty RR Paging Request (PCH filling) messages.
3970 * TODO: does it make sense to count them? */
3971 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003972 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3973 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003974 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003975 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3976 }
3977 } else if (match(rr, tr_PAGING_REQ2)) {
3978 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3979 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
3980 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3981 }
3982 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
3983 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3984 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003985 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003986 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3987 }
3988 } else if (match(rr, tr_PAGING_REQ3)) {
3989 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3990 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
3991 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3992 }
3993 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
3994 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3995 }
3996 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
3997 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3998 }
3999 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
4000 num_paging_rcv_ids := num_paging_rcv_ids + 1;
4001 }
4002 }
4003 repeat;
4004 }
4005}
4006
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004007private type record PagingTestCfg {
Harald Welte68e495b2018-02-25 00:05:57 +01004008 boolean combined_ccch,
4009 integer bs_ag_blks_res,
4010 float load_factor,
Philipp Maierca058272021-06-23 10:35:23 +02004011 /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus)
4012 * paging command that is issued via RSL. */
4013 integer ps_load_modulus,
4014 /* Wait until the paging queue inside the BTS is congested before starting to add
4015 * pagings via the PCU socket (0 = disabled) */
4016 boolean ps_wait_cong,
4017 /* Maximum time to wait until the paging queue is drained at the end of the test.
4018 * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended
4019 * to set this value to 18s, however the draining process may take significantly
4020 * longer when the queue contains paging requests for PS as those are implemented
4021 * as immediate assignments and require an entire MAC block alone. */
4022 float queue_drain_timeout,
Harald Welte68e495b2018-02-25 00:05:57 +01004023 boolean exp_load_ind,
4024 boolean exp_overload,
4025 boolean use_tmsi
4026}
4027
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004028private type record PagingTestState {
Harald Welte68e495b2018-02-25 00:05:57 +01004029 integer num_paging_sent,
4030 integer num_paging_rcv_msgs,
4031 integer num_paging_rcv_ids,
Philipp Maierca058272021-06-23 10:35:23 +02004032 integer num_overload,
4033 /* When free space inside the paging queue reaches more than 2 thirds
4034 * of its capacity cong_detected is set to true. */
4035 boolean cong_detected
Harald Welte68e495b2018-02-25 00:05:57 +01004036}
4037
Harald Welte68e495b2018-02-25 00:05:57 +01004038/* Helper function for paging related testing */
4039private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Philipp Maierca058272021-06-23 10:35:23 +02004040 /* Using the PCU socket affects the timing of the paging processing. We only
4041 * activate the PCU socket if we do paging load tests that include additional
4042 * paging load that is introduced through the PCU socket. */
4043 if (cfg.ps_load_modulus > 0) {
4044 f_init_with_pcuif();
4045 } else {
4046 f_init();
4047 }
Harald Welte68e495b2018-02-25 00:05:57 +01004048 f_init_l1ctl();
4049 f_l1_tune(L1CTL);
4050
Philipp Maierca058272021-06-23 10:35:23 +02004051 var octetstring imm_ass := f_rnd_octstring(23);
4052 var ASP_RSL_Unitdata load_ind;
4053
Harald Welte68e495b2018-02-25 00:05:57 +01004054 var PagingTestState st := {
4055 num_paging_sent := 0,
4056 num_paging_rcv_msgs := 0,
4057 num_paging_rcv_ids := 0,
Philipp Maierca058272021-06-23 10:35:23 +02004058 num_overload := 0,
4059 cong_detected := false
Harald Welte68e495b2018-02-25 00:05:57 +01004060 };
4061
4062 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
4063 var float max_pch_imsi_per_sec;
4064 if (cfg.use_tmsi) {
4065 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
4066 } else {
4067 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
4068 }
4069 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
4070 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004071 var float time_total := 20.0;
4072 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
4073 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01004074
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004075 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
4076 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01004077
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004078 timer T_itv := 0.0;
4079 T_itv.start;
4080 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01004081 alt {
4082 /* check for presence of CCCH LOAD IND (paging load) */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004083 [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Harald Welte68e495b2018-02-25 00:05:57 +01004084 st.num_overload := st.num_overload + 1;
4085 repeat;
4086 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004087 [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004088 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01004089 }
Philipp Maierca058272021-06-23 10:35:23 +02004090 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind {
Harald Welte68e495b2018-02-25 00:05:57 +01004091 log("Rx LOAD_IND");
Philipp Maierca058272021-06-23 10:35:23 +02004092
4093 /* Detect paging congestion: The logic inside the BTS will diagnose the
4094 * paging queue as congested when the fill state is more than 66% (which
4095 * is two thirds fill state, or approx. 66 of 200 paging slots. When a
4096 * paging congestion is detected pagings that are issued through the PCU
4097 * socket (PS) are dropped in order to prefer the CS related pagings. */
4098 if (load_ind.rsl.ies[1].body.paging_load < 66) {
4099 st.cong_detected := true;
4100 }
4101
Harald Welte68e495b2018-02-25 00:05:57 +01004102 /* FIXME: analyze/verify interval + contents */
4103 repeat;
4104 }
Vadim Yanitskiy2372db62021-06-09 00:50:11 +02004105 /* ignore other RSL messages like RF RESource INDication */
4106 [] RSL_CCHAN.receive { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01004107 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02004108 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01004109 [] L1CTL.receive { repeat; }
Philipp Maierca058272021-06-23 10:35:23 +02004110 /* Only relevant when testing including with PCU sock connected */
4111 [] PCU.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004112 [] T_itv.timeout {
4113 /* Send paging cmds based on elapsed time */
4114 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
4115 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004116 var MobileIdentityV mi;
4117
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004118 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004119 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004120 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004121 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004122 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004123 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004124
4125 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004126 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004127
Philipp Maierca058272021-06-23 10:35:23 +02004128 /* Add additional pagings through the PCU socket interface. */
4129 if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) {
4130 if (st.cong_detected == true or cfg.ps_wait_cong == false) {
4131 f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false);
4132 }
4133 }
4134
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004135 st.num_paging_sent := st.num_paging_sent + 1;
4136 }
4137 if (st.num_paging_sent < pkt_total) {
4138 /* Wait for interval to next PAGING COMMAND */
4139 var float time_now := T_total.read;
4140 var float next_sched := int2float(st.num_paging_sent)*interval;
4141 if (next_sched > time_now) {
4142 T_itv.start(next_sched - time_now);
4143 } else {
4144 T_itv.start(0.0);
4145 }
4146 } else {
4147 /* We are done, no need to keep counting */
4148 T_total.stop;
4149 }
4150 }
4151 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01004152 }
4153 }
4154
Philipp Maierca058272021-06-23 10:35:23 +02004155 timer T_wait := cfg.queue_drain_timeout
Harald Welte68e495b2018-02-25 00:05:57 +01004156 T_wait.start;
4157 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02004158 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01004159 [] L1CTL.receive { repeat; }
4160 /* 65535 == empty paging queue, we can terminate*/
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004161 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
Philipp Maierca058272021-06-23 10:35:23 +02004162 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { repeat; }
Vadim Yanitskiy2372db62021-06-09 00:50:11 +02004163 /* ignore other RSL messages like RF RESource INDication */
4164 [] RSL_CCHAN.receive { repeat; }
Philipp Maierca058272021-06-23 10:35:23 +02004165 /* Only relevant when testing including with PCU sock connected */
4166 [] PCU.receive { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01004167 [] T_wait.timeout {
Philipp Maierca058272021-06-23 10:35:23 +02004168 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 Welte68e495b2018-02-25 00:05:57 +01004169 }
Harald Welte68e495b2018-02-25 00:05:57 +01004170 }
4171
4172 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
4173 " rcvd_ids=", st.num_paging_rcv_ids);
4174 return st;
4175}
4176
4177/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
4178 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
4179 * - that CCCH LOAD IND (PCH) are being generated
4180 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
4181testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02004182 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01004183 var PagingTestCfg cfg := {
4184 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02004185 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01004186 load_factor := 0.8,
Philipp Maierca058272021-06-23 10:35:23 +02004187 ps_load_modulus := 0,
4188 ps_wait_cong := false,
4189 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01004190 exp_load_ind := true,
4191 exp_overload := false,
4192 use_tmsi := false
4193 };
4194 var PagingTestState st := f_TC_paging(cfg);
4195 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004196 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
4197 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01004198 } else {
4199 setverdict(pass);
4200 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004201 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004202}
4203
4204/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
4205 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
4206 * - that CCCH LOAD IND (PCH) are being generated
4207 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
4208testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02004209 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01004210 var PagingTestCfg cfg := {
4211 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02004212 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01004213 load_factor := 0.8,
Philipp Maierca058272021-06-23 10:35:23 +02004214 ps_load_modulus := 0,
4215 ps_wait_cong := false,
4216 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01004217 exp_load_ind := true,
4218 exp_overload := false,
4219 use_tmsi := true
4220 };
4221 var PagingTestState st := f_TC_paging(cfg);
4222 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004223 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
4224 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01004225 } else {
4226 setverdict(pass);
4227 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004228 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004229}
4230
4231/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
4232 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
4233 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
4234 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
4235testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02004236 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01004237 var PagingTestCfg cfg := {
4238 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02004239 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01004240 load_factor := 2.0,
Philipp Maierca058272021-06-23 10:35:23 +02004241 ps_load_modulus := 0,
4242 ps_wait_cong := false,
4243 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01004244 exp_load_ind := true,
4245 exp_overload := true,
4246 use_tmsi := false
4247 };
4248 var PagingTestState st := f_TC_paging(cfg);
4249 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
4250 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004251 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01004252 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004253 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01004254 } else {
4255 setverdict(pass);
4256 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004257 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004258}
4259
4260/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
4261 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
4262 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
4263 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
4264testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02004265 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01004266 var PagingTestCfg cfg := {
4267 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02004268 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01004269 load_factor := 2.0,
Philipp Maierca058272021-06-23 10:35:23 +02004270 ps_load_modulus := 0,
4271 ps_wait_cong := false,
4272 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01004273 exp_load_ind := true,
4274 exp_overload := true,
4275 use_tmsi := true
4276 };
4277 var PagingTestState st := f_TC_paging(cfg);
4278 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
4279 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02004280 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01004281 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004282 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01004283 } else {
4284 setverdict(pass);
4285 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004286 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004287}
4288
Philipp Maierca058272021-06-23 10:35:23 +02004289/* Same as above, but with additional paging load created by PS pagings that
4290 * are issued through the PCU socket. The additional load is introduced when
4291 * the paging queue is already two thirds full. Since the BTS implements a
4292 * prioritization logic that drops the pagings from the PCU under in those
4293 * congestive sitautions the behaviour on the PS side is expected to be
4294 * unaffected and match the behavior of TC_paging_imsi_200percent() */
4295testcase TC_paging_imsi_200percent_with_ps() runs on test_CT {
4296 var SystemInformation si3 := valueof(ts_SI3_default);
4297 var PagingTestCfg cfg := {
4298 combined_ccch := true,
4299 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
4300 load_factor := 2.0,
4301 ps_load_modulus := 16,
4302 ps_wait_cong := true,
4303 queue_drain_timeout := 18.0,
4304 exp_load_ind := true,
4305 exp_overload := true,
4306 use_tmsi := false
4307 };
4308 var PagingTestState st := f_TC_paging(cfg);
4309 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
4310 * slots and will fully drain that buffer before returning */
4311 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
4312 if (not match(st.num_paging_rcv_ids, tpl)) {
4313 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
4314 } else {
4315 setverdict(pass);
4316 }
4317 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4318}
4319
4320
Harald Welte68e495b2018-02-25 00:05:57 +01004321
Harald Welte93640c62018-02-25 16:59:33 +01004322/***********************************************************************
4323 * Immediate Assignment / AGCH
4324 ***********************************************************************/
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +07004325private const MobileAllocationLV c_MA_null := {
Harald Weltee8d750e2018-06-10 21:41:35 +02004326 len := 0,
4327 ma := ''B
4328}
Harald Welte93640c62018-02-25 16:59:33 +01004329
Harald Weltee8d750e2018-06-10 21:41:35 +02004330private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
4331 return int2str(num_tx) & " sent, "
4332 & int2str(num_rx) & " received, "
4333 & int2str(num_del) & " deleted";
4334}
4335
4336private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
4337 var L1ctlDlMessage l1_dl;
4338 timer T := 10.0;
4339 var integer num_tx := 0;
4340 var integer num_rx := 0;
4341 var integer num_del := 0;
4342 var charstring res_str;
4343 var float rx_ratio;
4344
Harald Welte10474062019-05-30 16:48:17 +02004345 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02004346 f_init_l1ctl();
4347 f_l1_tune(L1CTL);
4348
4349 for (var integer i := 0; i < num_total; i := i+1) {
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +07004350 var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0),
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07004351 mp_trx_pars[0].arfcn,
4352 mp_tsc_def));
Harald Weltee8d750e2018-06-10 21:41:35 +02004353 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
4354 var octetstring ia_enc := enc_GsmRrMessage(ia);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004355 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02004356 num_tx := num_tx+1;
4357 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01004358 }
4359 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02004360 T.start;
4361 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004362 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
Harald Weltee8d750e2018-06-10 21:41:35 +02004363 num_del := num_del+1;
4364 repeat;
4365 }
4366 [] RSL_CCHAN.receive {
4367 repeat;
4368 }
4369 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
Harald Weltee8d750e2018-06-10 21:41:35 +02004370 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
4371 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
4372 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004373 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02004374 } else {
4375 num_rx := num_rx+1;
4376 }
4377 repeat;
4378 }
4379 [] L1CTL.receive { repeat; }
4380 [] T.timeout { }
4381 }
4382 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
4383 log("AGCH test: " & res_str);
4384 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004385 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02004386 }
4387 rx_ratio := int2float(num_rx) / int2float(num_tx);
4388 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004389 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02004390 } else {
4391 setverdict(pass);
4392 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004393 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004394}
4395
Harald Weltee8d750e2018-06-10 21:41:35 +02004396/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
4397testcase TC_imm_ass_1000_20ms() runs on test_CT {
4398 f_TC_imm_ass(1000, 0.02, 0.25);
4399}
4400
4401/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
4402testcase TC_imm_ass_200_0ms() runs on test_CT {
4403 f_TC_imm_ass(200, 0.0, 0.05);
4404}
4405
4406/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
4407testcase TC_imm_ass_200_76ms() runs on test_CT {
4408 f_TC_imm_ass(150, 0.076, 1.00);
4409}
4410
4411
4412
Harald Welte48494ca2018-02-25 16:59:50 +01004413/***********************************************************************
4414 * BCCH
4415 ***********************************************************************/
4416
4417/* tuple of Frame Number + decoded SI */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004418private type record SystemInformationFn {
Harald Welte48494ca2018-02-25 16:59:50 +01004419 GsmFrameNumber frame_number,
4420 SystemInformation si
4421}
4422
4423/* an arbitrary-length vector of decoded SI + gsmtap header */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004424private type record of SystemInformationFn SystemInformationVector;
Harald Welte48494ca2018-02-25 16:59:50 +01004425
4426/* an array of SI-vectors indexed by TC value */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004427private type SystemInformationVector SystemInformationVectorPerTc[8];
Harald Welte48494ca2018-02-25 16:59:50 +01004428
4429/* determine if a given SI vector contains given SI type at least once */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004430private function f_si_vecslot_contains(SystemInformationVector arr,
4431 RrMessageType key,
4432 boolean bcch_ext := false)
4433return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004434 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
4435 var integer fn_mod51 := arr[i].frame_number mod 51;
4436 if (not bcch_ext and fn_mod51 == 2 or
4437 bcch_ext and fn_mod51 == 6) {
4438 if (arr[i].si.header.message_type == key) {
4439 return true;
4440 }
4441 }
4442 }
4443 return false;
4444}
4445
4446/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004447private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr,
4448 integer tc, RrMessageType key,
4449 boolean ext_bcch := false)
4450{
Harald Welte48494ca2018-02-25 16:59:50 +01004451 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004452 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004453 }
4454}
4455
4456/* check if a given SI vector contains given SI type at least once on any TC */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004457private function f_si_vec_contains(SystemInformationVectorPerTc arr,
4458 RrMessageType key)
4459return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004460 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
4461 if (f_si_vecslot_contains(arr[tc], key) or
4462 f_si_vecslot_contains(arr[tc], key, true)) {
4463 return true;
4464 }
4465 }
4466 return false;
4467}
4468
4469/* determine if a given SI vector contains given SI type at least N of M times */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004470private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr,
4471 RrMessageType key,
4472 boolean bcch_ext := false,
4473 integer n := 1, integer m := 4)
4474return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004475 var integer count := 0;
4476 if (sizeof(arr) < m) {
Harald Weltea616ec92020-10-11 21:28:00 +02004477 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: "
4478 & int2str(sizeof(arr)) & " < " & int2str(m));
Harald Welte48494ca2018-02-25 16:59:50 +01004479 }
4480 for (var integer i:= 0; i < m; i := i + 1) {
4481 var integer fn_mod51 := arr[i].frame_number mod 51;
4482 if (not bcch_ext and fn_mod51 == 2 or
4483 bcch_ext and fn_mod51 == 6) {
4484 if (arr[i].si.header.message_type == key) {
4485 count := count + 1;
4486 }
4487 }
4488 }
4489 if (count >= n) {
4490 return true;
4491 } else {
4492 return false;
4493 }
4494}
4495
4496/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004497private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr,
4498 integer tc, RrMessageType key,
4499 boolean ext_bcch := false,
4500 integer n, integer m)
4501{
Harald Welte48494ca2018-02-25 16:59:50 +01004502 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004503 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004504 }
4505}
4506
4507/* determine if a given SI vector contains given SI type at least once */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004508private function f_si_vecslot_contains_only(SystemInformationVector arr,
4509 RrMessageType key,
4510 boolean bcch_ext := false)
4511return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004512 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
4513 var integer fn_mod51 := arr[i].frame_number mod 51;
4514 if (not bcch_ext and fn_mod51 == 2 or
4515 bcch_ext and fn_mod51 == 6) {
4516 if (arr[i].si.header.message_type != key) {
4517 return false;
4518 }
4519 }
4520 }
4521 return true;
4522}
4523
4524/* ensure a given TC slot of the SI vector contains only given SI type */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004525private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr,
4526 integer tc, RrMessageType key,
4527 boolean ext_bcch := false)
4528{
Harald Welte48494ca2018-02-25 16:59:50 +01004529 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004530 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004531 }
4532}
4533
4534/* SI configuration of cell, against which we validate actual SI messages */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004535private type set SystemInformationConfig {
Harald Welte48494ca2018-02-25 16:59:50 +01004536 boolean bcch_extended,
4537 boolean si1_present,
4538 boolean si2bis_present,
4539 boolean si2ter_present,
4540 boolean si2quater_present,
4541 boolean si7_present,
4542 boolean si8_present,
4543 boolean si9_present,
4544 boolean si13_present,
4545 boolean si13alt_present,
4546 boolean si15_present,
4547 boolean si16_present,
4548 boolean si17_present,
4549 boolean si2n_present,
4550 boolean si21_present,
4551 boolean si22_present
4552}
4553
4554/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004555private function f_validate_si_scheduling(SystemInformationConfig cfg,
4556 SystemInformationVectorPerTc si_per_tc)
4557{
Harald Welte48494ca2018-02-25 16:59:50 +01004558 var integer i;
4559 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
4560 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004561 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01004562 }
4563 }
4564 if (cfg.si1_present) {
4565 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
4566 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
4567 * when TC = 0, it can assume that System Information Type 1 is not in use. */
4568 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
4569 /* make sure *ALL* contain SI1 */
4570 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
4571 }
4572 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
4573 /* iii) A SI 2 message will be sent at least every time TC = 1 */
4574 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
4575 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
4576 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
4577 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
4578
4579 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
4580 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
4581 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
4582 * consecutive occurrences of TC = 4. */
4583 if (cfg.si2bis_present and not cfg.si2ter_present) {
4584 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
4585 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
4586 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
4587 } else if (cfg.si2ter_present and cfg.si2bis_present) {
4588 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
4589 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
4590 }
4591
4592 if (cfg.si7_present or cfg.si8_present) {
4593 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
4594 * if System Information type 4 does not contain all information needed for cell
4595 * selection and reselection. */
4596 if (not cfg.bcch_extended) {
4597 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
4598 }
4599 if (cfg.si7_present) {
4600 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
4601 }
4602 if (cfg.si8_present) {
4603 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
4604 }
4605 }
4606
4607 if (cfg.si2quater_present) {
4608 /* iii) System information type 2 quater is sent if needed, as determined by the system
4609 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
4610 * and 2ter are used, otherwise it shall be sent at least once within any of 4
4611 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
4612 * within any of 4 consecutive occurrences of TC = 5. */
4613 if (not (cfg.bcch_extended)) {
4614 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
4615 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
4616 } else {
4617 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
4618 }
4619 } else {
4620 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
4621 }
4622 }
4623 if (cfg.si9_present) {
4624 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
4625 * in system information type 3 as defined in 3GPP TS 44.018. */
4626 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
4627 }
4628 if (cfg.si13_present) {
4629 /* vii) System Information type 13 is only related to the GPRS service. System Information
4630 * Type 13 need only be sent if GPRS support is indicated in one or more of System
4631 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
4632 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
4633 * In the case that the message is sent on the BCCH Norm, it is sent at least once
4634 * within any of 4 consecutive occurrences of TC=4. */
4635 if (not cfg.bcch_extended) {
4636 log("not-bccch-extended");
4637 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
4638 } else {
4639 log("bccch-extended");
4640 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
4641 }
4642 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004643 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01004644 }
4645 }
4646 if (cfg.si16_present or cfg.si17_present) {
4647 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
4648 * should not be sent in a cell where network sharing is used (see rule xv). */
4649 if (cfg.si22_present) {
4650 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
4651 }
4652 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004653 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01004654 }
4655 if (not cfg.bcch_extended) {
4656 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
4657 }
4658 if (cfg.si16_present) {
4659 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
4660 }
4661 if (cfg.si17_present) {
4662 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
4663 }
4664 }
4665
4666 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
4667 * broadcast information. The frequency with which they are sent is determined by the
4668 * system operator. System Information type 9 identifies the scheduling of System
4669 * Information type 18 and 20 messages. */
4670
4671 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
4672 * Information Type 19 is present, then its scheduling shall be indicated in System
4673 * Information Type 9. */
4674
4675 if (cfg.si15_present) {
4676 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
4677 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
4678 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
4679 * 4 consecutive occurrences of TC = 1. */
4680 if (not cfg.bcch_extended) {
4681 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
4682 } else {
4683 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
4684 }
4685 }
4686 if (cfg.si13alt_present) {
4687 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
4688 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
4689 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
4690 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
4691 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
4692 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
4693 * of TC = 4. */
4694 if (cfg.si13_present) {
4695 testcase.stop("Error: Cannot have SI13alt and SI13");
4696 }
4697 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004698 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01004699 }
4700 if (not cfg.bcch_extended) {
4701 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
4702 } else {
4703 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
4704 }
4705 }
4706 if (cfg.si2n_present) {
4707 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
4708 * as determined by the system operator. In the case that the message is sent on the
4709 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
4710 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
4711 * consecutive occurrences of TC = 4. */
4712 if (not cfg.bcch_extended) {
4713 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
4714 } else {
4715 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
4716 }
4717 }
4718 if (cfg.si21_present) {
4719 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
4720 * determined by the system operator. If Extended Access Barring is in use in the cell
4721 * then this message is sent at least once within any of 4 consecutive occurrences of
4722 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
4723 * cell then this message shall only be sent on BCCH Ext. */
4724 if (not cfg.bcch_extended) {
4725 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
4726 } else {
4727 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
4728 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004729 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01004730 }
4731 }
4732 }
4733 if (cfg.si22_present) {
4734 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
4735 * should not be sent in a cell where SoLSA is used (see rule viii). System
4736 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
4737 * =2 and TC=6. */
4738 if (cfg.si16_present or cfg.si17_present) {
4739 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
4740 }
4741 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
4742 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004743 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01004744 }
4745 if (not cfg.bcch_extended) {
4746 testcase.stop("Error: SI22 requires BCCH Extd!");
4747 } else {
4748 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
4749 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
4750 }
4751 }
4752}
4753
4754/* sample Systme Information for specified duration via L1CTL */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004755private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0)
4756return SystemInformationVectorPerTc {
Harald Welte48494ca2018-02-25 16:59:50 +01004757 timer T := duration;
4758 var SystemInformationVectorPerTc si_per_tc;
4759 var L1ctlDlMessage l1_dl;
4760
4761 /* initialize all per-TC vectors empty */
4762 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
4763 si_per_tc[i] := {};
4764 }
4765
4766 /* flush all previous L1 queued msgs */
4767 pt.clear;
4768
4769 T.start;
4770 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004771 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07004772 var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr };
4773 if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) {
4774 log("Ignoring non-RR or invalid SI ", l1_dl);
Harald Welte48494ca2018-02-25 16:59:50 +01004775 repeat;
4776 }
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07004777
Harald Welte48494ca2018-02-25 16:59:50 +01004778 var integer tc := f_gsm_compute_tc(sig.frame_number);
4779 log("SI received at TC=", tc, ": ", sig.si);
4780 /* append to the per-TC bucket */
4781 si_per_tc[tc] := si_per_tc[tc] & { sig };
4782 repeat;
4783 }
4784 [] pt.receive { repeat; }
4785 [] T.timeout { }
4786 }
4787
4788 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
4789 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
4790 }
4791 log("si_per_tc=", si_per_tc);
4792 return si_per_tc;
4793}
4794
4795/* helper function: Set given SI via RSL + validate scheduling.
4796 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
Harald Welte9b965d52020-10-11 21:28:22 +02004797private function f_TC_si_sched(float duration := 8.0) runs on test_CT {
Harald Welte48494ca2018-02-25 16:59:50 +01004798 var SystemInformationVectorPerTc si_per_tc;
4799 f_init_l1ctl();
4800 f_l1_tune(L1CTL);
4801
4802 /* Sample + Validate Scheduling */
Harald Welte9b965d52020-10-11 21:28:22 +02004803 si_per_tc := f_l1_sample_si(L1CTL, duration);
Harald Welte48494ca2018-02-25 16:59:50 +01004804 f_validate_si_scheduling(si_cfg, si_per_tc);
4805
4806 setverdict(pass);
4807}
4808
4809testcase TC_si_sched_default() runs on test_CT {
4810 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01004811 /* 2+3+4 are mandatory and set in f_init() */
4812 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004813 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01004814}
4815
4816testcase TC_si_sched_1() runs on test_CT {
4817 f_init();
4818 si_cfg.si1_present := true;
4819 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004820 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004821 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004822}
4823
4824testcase TC_si_sched_2bis() runs on test_CT {
4825 f_init();
4826 si_cfg.si2bis_present := true;
4827 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4828 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004829 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004830}
4831
4832testcase TC_si_sched_2ter() runs on test_CT {
4833 f_init();
4834 si_cfg.si2ter_present := true;
4835 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4836 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004837 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004838}
4839
4840testcase TC_si_sched_2ter_2bis() runs on test_CT {
4841 f_init();
4842 si_cfg.si2bis_present := true;
4843 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4844 si_cfg.si2ter_present := true;
4845 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4846 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004847 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004848}
4849
4850testcase TC_si_sched_2quater() runs on test_CT {
4851 f_init();
4852 si_cfg.si2quater_present := true;
Vadim Yanitskiy3bb3b602020-10-24 21:24:05 +07004853 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O);
Harald Welte9b965d52020-10-11 21:28:22 +02004854 f_TC_si_sched(16.0);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004855 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004856}
4857
4858testcase TC_si_sched_13() runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01004859 /* NOTE: PCUIF connection is not used in this test case, but
4860 * without it the IUT would not broadcast SI13 (see OS#3075). */
4861 f_init_with_pcuif();
Harald Welte48494ca2018-02-25 16:59:50 +01004862 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02004863 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004864 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004865 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004866}
4867
4868testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01004869 /* NOTE: PCUIF connection is not used in this test case, but
4870 * without it the IUT would not broadcast SI13 (see OS#3075). */
4871 f_init_with_pcuif();
Harald Welte48494ca2018-02-25 16:59:50 +01004872 si_cfg.si2bis_present := true;
4873 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4874 si_cfg.si2ter_present := true;
4875 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4876 si_cfg.si2quater_present := true;
Vadim Yanitskiy3bb3b602020-10-24 21:24:05 +07004877 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004878 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02004879 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte9b965d52020-10-11 21:28:22 +02004880 f_TC_si_sched(16.0);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004881 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004882}
4883
4884
Harald Welte68e495b2018-02-25 00:05:57 +01004885testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004886 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01004887 /* FIXME: enable / disable individual BCCH info */
4888 //ts_RSL_BCCH_INFO(si_type, info);
4889 /* expect no ERROR REPORT after either of them *
4890 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004891 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004892}
4893
Harald Welte93640c62018-02-25 16:59:33 +01004894/***********************************************************************
4895 * Low-Level Protocol Errors / ERROR REPORT
4896 ***********************************************************************/
4897
Harald Welte01d982c2018-02-25 01:31:40 +01004898private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
4899 timer T := 5.0;
4900 T.start;
4901 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004902 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
Harald Welte01d982c2018-02-25 01:31:40 +01004903 setverdict(pass);
4904 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004905 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004907 }
4908 [] RSL_CCHAN.receive {
4909 repeat;
4910 }
4911 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004912 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004913 }
4914 }
4915}
4916
4917/* Provoke a protocol error (message too short) and match on ERROR REPORT */
4918testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004919 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004920 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4921 rsl.ies := omit;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004922 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004923
4924 f_exp_err_rep(RSL_ERR_PROTO);
4925}
4926
4927/* Provoke a mandatory IE error and match on ERROR REPORT */
4928testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004929 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004930
4931 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4932 rsl.ies := { rsl.ies[0] };
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004933 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004934
4935 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
4936}
4937
4938/* Provoke an IE content error and match on ERROR REPORT */
4939testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004940 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004941 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4942 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004943 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004944
4945 f_exp_err_rep(RSL_ERR_IE_CONTENT);
4946}
4947
Harald Welteee25aae2019-05-19 14:32:37 +02004948/* attempt to activate channel with wrong RSL Message Discriminator IE */
4949function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
4950 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4951 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
4952 RSL.send(rsl);
4953 f_rslem_unregister(0, g_chan_nr);
4954}
4955testcase TC_err_rep_wrong_mdisc() runs on test_CT {
4956 var ConnHdlr vc_conn;
4957 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4958
Harald Welte10474062019-05-30 16:48:17 +02004959 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004960
4961 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
4962 vc_conn.done;
4963 f_exp_err_rep(RSL_ERR_MSG_DISCR);
4964
4965 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4966}
4967
4968/* Send messages with wrong message type */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004969private function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004970 var template (value) RSL_Message rsl_tx;
4971 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4972 rsl_tx.msg_type := RSL_MT_NOT_CMD;
4973 RSL.send(rsl_tx);
4974 f_rslem_unregister(0, g_chan_nr);
4975}
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004976private function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004977 var template (value) RSL_Message rsl_tx;
4978 /* we first have to activate the dedicated channel */
4979 f_rsl_chan_act(g_pars.chan_mode);
4980 /* ... to then send an invalid RLL message */
4981 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
4982 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
4983 RSL.send(rsl_tx);
4984 f_rslem_unregister(0, g_chan_nr);
4985}
4986testcase TC_err_rep_wrong_msg_type() runs on test_CT {
4987 var ConnHdlr vc_conn;
4988 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4989 var template (value) RSL_Message rsl_tx;
4990
Harald Welte10474062019-05-30 16:48:17 +02004991 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004992
4993 /* Common Channel with wrong message type */
4994 RSL_CCHAN.clear;
4995 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4996 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004997 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02004998 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4999
5000 /* TRX Management */
5001 RSL_CCHAN.clear;
5002 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
5003 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07005004 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02005005 f_exp_err_rep(RSL_ERR_MSG_TYPE);
5006
5007 /* Dedicated Channel */
5008 RSL_CCHAN.clear;
5009 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
5010 vc_conn.done;
5011 f_exp_err_rep(RSL_ERR_MSG_TYPE);
5012
5013 /* RLL */
5014 RSL_CCHAN.clear;
5015 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
5016 vc_conn.done;
5017 f_exp_err_rep(RSL_ERR_MSG_TYPE);
5018}
5019
5020/* Send messages in wrong sequence (RLL to an inactive lchan) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005021private function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02005022 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
5023 f_rslem_unregister(0, g_chan_nr);
5024}
5025testcase TC_err_rep_wrong_sequence() runs on test_CT {
5026 var ConnHdlr vc_conn;
5027 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
5028
Harald Welte10474062019-05-30 16:48:17 +02005029 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02005030
5031 RSL_CCHAN.clear;
5032 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
5033 vc_conn.done;
5034 f_exp_err_rep(RSL_ERR_MSG_SEQ);
5035}
5036
Harald Welte93640c62018-02-25 16:59:33 +01005037/***********************************************************************
5038 * IPA CRCX/MDCX/DLCS media stream handling
5039 ***********************************************************************/
5040
Harald Weltea871a382018-02-25 02:03:14 +01005041/* Send IPA DLCX to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005042private function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01005043 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
5044 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01005045}
5046testcase TC_ipa_dlcx_not_active() runs on test_CT {
5047 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02005048 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01005049 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
5050 vc_conn.done;
5051}
Harald Welte68e495b2018-02-25 00:05:57 +01005052
Harald Weltea3f1df92018-02-25 12:49:55 +01005053/* Send IPA CRCX twice to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005054private function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01005055 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
5056 "IPA CRCX ACK");
5057 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
5058 "IPA CRCX NACK");
5059}
5060testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
5061 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02005062 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01005063 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
5064 vc_conn.done;
5065}
5066
5067/* Regular sequence of CRCX/MDCX/DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005068private function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01005069 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
5070 "IPA CRCX ACK");
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02005071 var OCT4 remote_ip := f_rnd_octstring(4);
Harald Weltea3f1df92018-02-25 12:49:55 +01005072 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
5073 var uint7_t rtp_pt2 := f_rnd_int(127);
5074 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
5075 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
5076 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
5077 "IPA MDCX ACK");
5078 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
5079 "IPA DLCX ACK");
5080}
5081testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
5082 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02005083 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01005084 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
5085 vc_conn.done;
5086}
5087
Harald Welte3ae11da2018-02-25 13:36:06 +01005088/* Sequence of CRCX, 2x MDCX, DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005089private function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte3ae11da2018-02-25 13:36:06 +01005090 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
5091 "IPA CRCX ACK");
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02005092 var OCT4 remote_ip := f_rnd_octstring(4);
Harald Welte3ae11da2018-02-25 13:36:06 +01005093 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
5094 var uint7_t rtp_pt2 := f_rnd_int(127);
5095 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
5096 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
5097 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
5098 "IPA MDCX ACK");
5099 /* Second MDCX */
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02005100 remote_ip := f_rnd_octstring(4);
Harald Welte3ae11da2018-02-25 13:36:06 +01005101 remote_port := f_rnd_int(c_UINT16_MAX);
5102 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
5103 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
5104 "IPA MDCX ACK");
5105 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
5106 "IPA DLCX ACK");
5107}
5108testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
5109 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02005110 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01005111 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
5112 vc_conn.done;
5113}
5114
Harald Welte9912eb52018-02-25 13:30:15 +01005115/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005116private function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
Harald Welte9912eb52018-02-25 13:30:15 +01005117 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
5118 "IPA CRCX NACK");
5119}
5120testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
5121 var ConnHdlrPars pars;
5122 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005123 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01005124
5125 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
5126 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
5127 vc_conn.done;
5128
5129 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
5130 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
5131 vc_conn.done;
5132}
5133
Vadim Yanitskiy866afc22022-05-01 16:08:30 +03005134/* Make sure that CRCX ACK contains a valid listen address (see OS#5242) */
5135private function f_TC_ipa_crcx_ack_addr(charstring id) runs on ConnHdlr {
5136 var OCT4 bind_ip := f_inet_addr("192.168.1.1");
5137 var PortNumber bind_port := 16811;
5138 var RSL_Message crcx_ack;
5139
5140 crcx_ack := f_rsl_transceive_ret(ts_RSL_IPA_CRCX(g_chan_nr, bind_ip, bind_port),
5141 tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
5142 "IPA CRCX ACK");
5143 var HostName bts_bind_ip := f_inet_ntoa(crcx_ack.ies[2].body.ipa_local_ip);
5144 if (match(bts_bind_ip, "0.0.0.0")) {
5145 setverdict(fail, "CRCX ACK indicates nonsense addr ", bts_bind_ip);
5146 }
5147
5148 var uint16_t conn_id := crcx_ack.ies[1].body.ipa_conn_id;
5149 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, conn_id),
5150 tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
5151 "IPA DLCX ACK");
5152}
5153testcase TC_ipa_crcx_ack_addr() runs on test_CT {
5154 var ConnHdlrPars pars;
5155 var ConnHdlr vc_conn;
5156 f_init();
5157
5158 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)));
5159 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars);
5160 vc_conn.done;
5161
5162 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)));
5163 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_ack_addr), pars);
5164 vc_conn.done;
5165}
5166
Harald Weltea3f1df92018-02-25 12:49:55 +01005167
Harald Welte883340c2018-02-28 18:59:29 +01005168/***********************************************************************
5169 * PCU Socket related tests
5170 ***********************************************************************/
5171
Harald Welte07bd2d22019-05-25 11:03:30 +02005172/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02005173friend function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
Harald Welte883340c2018-02-28 18:59:29 +01005174runs on test_CT {
5175 timer T := 3.0;
5176
5177 /* we don't expect any RTS.req before PDCH are active */
5178 T.start;
5179 alt {
5180 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005181 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01005182 }
5183 [] PCU.receive { repeat; }
5184 [] T.timeout { }
5185 }
5186
5187 /* Send PDCH activate request for known PDCH timeslot */
5188 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
5189
5190 /* we now expect RTS.req for this timeslot (only) */
5191 T.start;
5192 alt {
5193 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
5194 setverdict(pass);
5195 }
5196 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
5197 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005198 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01005199 }
5200 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005201 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01005202 }
5203 [] PCU.receive { repeat; }
5204 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005205 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01005206 }
5207 [not exp_success] T.timeout {
5208 setverdict(pass);
5209 }
5210 }
5211}
5212
Harald Welte07bd2d22019-05-25 11:03:30 +02005213/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02005214friend function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
Harald Welte883340c2018-02-28 18:59:29 +01005215runs on test_CT {
5216 timer T := 3.0;
5217
5218 /* Send PDCH activate request for known PDCH timeslot */
5219 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
Harald Weltec87d81f2020-10-11 18:17:25 +02005220 /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know
5221 * when it will actually have been executed in the BTS */
5222 f_sleep(1.0);
Harald Welte883340c2018-02-28 18:59:29 +01005223 PCU.clear;
5224 /* we now expect no RTS.req for this timeslot */
5225 T.start;
5226 alt {
5227 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005228 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01005229 }
5230 [] PCU.receive { repeat; }
5231 [] T.timeout {
5232 setverdict(pass);
5233 }
5234 }
5235}
5236
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005237friend function f_init_with_pcuif() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01005238 f_init();
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005239 map(self:PCU, system:PCU);
5240 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
Max2c6f5632019-03-18 17:25:17 +01005241 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
5242}
5243
Harald Welte883340c2018-02-28 18:59:29 +01005244/* PDCH activation via PCU socket; check for presence of RTS.req */
5245testcase TC_pcu_act_req() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005246 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005247
Harald Welte883340c2018-02-28 18:59:29 +01005248 f_TC_pcu_act_req(0, 0, 7, true);
5249}
5250
5251/* PDCH activation via PCU socket on non-PDCU timeslot */
5252testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005253 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005254
Harald Welte883340c2018-02-28 18:59:29 +01005255 f_TC_pcu_act_req(0, 0, 1, false);
5256}
5257
5258/* PDCH activation via PCU socket on wrong BTS */
5259testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005260 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005261
Harald Welte883340c2018-02-28 18:59:29 +01005262 f_TC_pcu_act_req(23, 0, 7, false);
5263}
5264
5265/* PDCH activation via PCU socket on wrong TRX */
5266testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005267 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005268
Harald Welte883340c2018-02-28 18:59:29 +01005269 f_TC_pcu_act_req(0, 23, 7, false);
5270}
5271
5272/* PDCH deactivation via PCU socket; check for absence of RTS.req */
5273testcase TC_pcu_deact_req() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005274 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005275
Harald Welte883340c2018-02-28 18:59:29 +01005276 /* Activate PDCH */
5277 f_TC_pcu_act_req(0, 0, 7, true);
5278 f_sleep(1.0);
5279 /* and De-Activate again */
5280 f_TC_pcu_deact_req(0, 0, 7);
5281}
5282
5283/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
5284testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005285 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01005286
Harald Welte883340c2018-02-28 18:59:29 +01005287 f_TC_pcu_deact_req(0, 0, 1);
5288}
5289
5290/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
Philipp Maier94c08482021-02-01 17:36:05 +01005291function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT {
Harald Welte883340c2018-02-28 18:59:29 +01005292 var PCUIF_send_data sd;
5293 timer T:= 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005294 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005295
5296 /* Set SI13 via RSL */
Philipp Maier94c08482021-02-01 17:36:05 +01005297 f_rsl_bcch_fill_raw(rsl_si_type, si);
Max2c6f5632019-03-18 17:25:17 +01005298
Harald Welte883340c2018-02-28 18:59:29 +01005299 T.start;
5300 alt {
5301 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
Philipp Maier94c08482021-02-01 17:36:05 +01005302 if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) {
Harald Welte883340c2018-02-28 18:59:29 +01005303 setverdict(pass);
5304 } else {
5305 repeat;
5306 }
5307 }
5308 [] PCU.receive { repeat; }
5309 [] T.timeout {
Philipp Maier94c08482021-02-01 17:36:05 +01005310 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI");
Harald Welte883340c2018-02-28 18:59:29 +01005311 }
5312 }
5313}
5314
Philipp Maier94c08482021-02-01 17:36:05 +01005315/* Test the PCU->BTS Version and BTS->PCU SI1 handshake */
5316testcase TC_pcu_ver_si1() runs on test_CT {
5317 const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O;
5318 f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1);
5319}
5320
5321/* Test the PCU->BTS Version and BTS->PCU SI3 handshake */
5322testcase TC_pcu_ver_si3() runs on test_CT {
5323 const octetstring si3 := '49012223242526272929AABBCC'O;
5324 f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3);
5325}
5326
5327/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
5328testcase TC_pcu_ver_si13() runs on test_CT {
5329 const octetstring si13 := '01010203040506070909'O;
5330 f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13);
5331}
5332
Harald Welte883340c2018-02-28 18:59:29 +01005333private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
5334
5335/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02005336friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01005337 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
5338runs on test_CT
5339{
5340 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
5341 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
5342}
5343
5344/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
Harald Weltead033dc2019-05-25 17:28:16 +02005345friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
5346 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01005347runs on test_CT
5348{
5349 var PCUIF_send_data sd;
5350
5351 timer T := 3.0;
5352 T.start;
5353 alt {
5354 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
5355 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
5356 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
5357 sd.data.u.rts_req.fn, sapi, data);
5358 }
5359 [] PCU.receive { repeat; }
5360 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005361 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01005362 }
5363 }
5364}
5365
5366/* Send DATA.req on invalid BTS */
5367testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02005368 var TfiUsfArr tua := f_TfiUsfArrInit();
5369 var octetstring data := '0000'O & f_rnd_octstring(21);
5370
5371 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005372
Harald Welte883340c2018-02-28 18:59:29 +01005373 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02005374 f_TfiUsfArrSet(tua, 7, 0);
5375 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5376 f_sleep(1.0);
5377
5378 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01005379}
5380
5381/* Send DATA.req on invalid TRX */
5382testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02005383 var TfiUsfArr tua := f_TfiUsfArrInit();
5384 var octetstring data := '0000'O & f_rnd_octstring(21);
5385
5386 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005387
Harald Welte883340c2018-02-28 18:59:29 +01005388 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02005389 f_TfiUsfArrSet(tua, 7, 0);
5390 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5391 f_sleep(1.0);
5392
5393 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01005394}
5395
5396/* Send DATA.req on invalid timeslot */
5397testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02005398 var TfiUsfArr tua := f_TfiUsfArrInit();
5399 var octetstring data := '0000'O & f_rnd_octstring(21);
5400
5401 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005402
Harald Welte883340c2018-02-28 18:59:29 +01005403 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02005404 f_TfiUsfArrSet(tua, 7, 0);
5405 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5406 f_sleep(1.0);
5407
5408 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01005409}
5410
5411/* Send DATA.req on timeslot that hasn't been activated */
5412testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02005413 var TfiUsfArr tua := f_TfiUsfArrInit();
5414 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01005415
Harald Welte7162a612019-05-26 12:56:09 +02005416 f_virtphy_common();
5417
5418 f_TfiUsfArrSet(tua, 7, 0);
5419 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5420 f_sleep(1.0);
5421
5422 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01005423}
5424
Harald Weltead033dc2019-05-25 17:28:16 +02005425private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02005426 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
5427 boolean wait_rts := true)
5428runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02005429 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02005430 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02005431
5432 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02005433 if (wait_rts) {
5434 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
5435 } else {
5436 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
5437 }
Harald Weltead033dc2019-05-25 17:28:16 +02005438
5439 T.start;
5440 alt {
Harald Welte7162a612019-05-26 12:56:09 +02005441 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02005442 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
5443 setverdict(pass);
5444 }
Harald Welte7162a612019-05-26 12:56:09 +02005445 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
5446 setverdict(fail, "Received unexpected ", rx_dl);
5447 }
Harald Weltead033dc2019-05-25 17:28:16 +02005448 [] L1CTL.receive {
5449 repeat;
5450 }
Harald Welte7162a612019-05-26 12:56:09 +02005451 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02005452 setverdict(fail, "Timeout waiting for ", data);
5453 }
Harald Welte7162a612019-05-26 12:56:09 +02005454 [not expect_data] T.timeout {
5455 setverdict(pass);
5456 }
Harald Weltead033dc2019-05-25 17:28:16 +02005457 }
5458}
5459
5460private function f_disable_dynamic_ts() runs on test_CT
5461{
5462 f_init_vty_bsc();
5463 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
5464 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
5465 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
5466 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005467 f_init_with_pcuif();
Harald Weltead033dc2019-05-25 17:28:16 +02005468}
5469
5470private function f_virtphy_common() runs on test_CT {
5471 f_disable_dynamic_ts();
5472 f_init_l1ctl();
5473 f_l1_tune(L1CTL);
5474}
5475
5476testcase TC_pcu_data_req_pdtch() runs on test_CT {
5477 var TfiUsfArr tua := f_TfiUsfArrInit();
5478 var octetstring data := '0000'O & f_rnd_octstring(21);
5479
5480 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005481
Harald Welte883340c2018-02-28 18:59:29 +01005482 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02005483 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, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01005488}
5489
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005490/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01005491testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02005492 var TfiUsfArr tua := f_TfiUsfArrInit();
5493 var octetstring data := '0000'O & f_rnd_octstring(21);
5494
5495 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005496
Harald Welte883340c2018-02-28 18:59:29 +01005497 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02005498 f_TfiUsfArrSet(tua, 7, 0);
5499 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5500 f_sleep(1.0);
5501
5502 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01005503}
5504
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005505private function f_TC_pcu_ptcch_ul(uint16_t ra)
5506runs on test_CT {
5507 var template PCUIF_Message pcu_rach_ind;
5508 var PCUIF_send_data sd;
5509 var GsmFrameNumber fn;
5510 timer T;
5511
5512 /* Send an Access Burst on PTCCH/U over the Um-interface */
5513 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
5514 chan_nr := ts_RslChanNr_PDCH(7),
5515 link_id := ts_RslLinkID_OSMO_PTCCH(0));
5516
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005517 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
5518 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005519
5520 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
5521 T.start(52.0 * 4.615 / 1000.0);
5522 alt {
5523 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
5524 log("Rx an Access Burst on the PCU interface: ", sd.data);
5525 setverdict(pass);
5526 T.stop;
5527 }
5528 [] PCU.receive { repeat; }
5529 [] T.timeout {
5530 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
5531 /* Keep going, that's not the end of the world */
5532 }
5533 }
5534}
5535
5536testcase TC_pcu_ptcch() runs on test_CT {
5537 var L1ctlDlMessage dl;
5538 var octetstring data;
5539 timer T;
5540
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005541 f_init_with_pcuif();
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005542 f_init_l1ctl();
5543 f_l1_tune(L1CTL);
5544
5545 /* Activate PDCH channel on TS7 */
5546 f_TC_pcu_act_req(0, 0, 7, true);
5547
5548 /* Tune trxcon to that PDCH channel */
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005549 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiy13a29d52020-07-15 14:41:54 +07005550 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005551 { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); }
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005552 f_l1ctl_est_dchan(L1CTL, pars);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005553
5554 /* Verify PTCCH/U: send several access bursts, make sure they're received */
5555 for (var integer i := 0; i < 16; i := i + 1) {
5556 log("Sending an Access Burst towards the L1CTL interface");
5557 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
5558 }
5559
5560 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
5561 data := f_rnd_octstring(23);
5562
5563 /* Verify PTCCH/D: send a random data block, make sure it's received */
5564 log("Sending a PTCCH/D block towards the PCU interface: ", data);
5565 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
5566
5567 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
5568 * let's give it more time in case if we miss the beginning. */
5569 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
5570 alt {
5571 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
5572 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
5573 link_id := tr_RslLinkID_OSMO_PTCCH(?),
5574 frame := data)) -> value dl {
5575 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
5576 setverdict(pass);
5577 T.stop;
5578 }
5579 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
5580 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
5581 link_id := tr_RslLinkID_OSMO_PTCCH(?),
5582 l2_data := data)) -> value dl {
5583 log("Rx PTCCH/D data block on L1CTL: ", dl);
5584 setverdict(pass);
5585 T.stop;
5586 }
5587 [] L1CTL.receive { repeat; }
5588 [] T.timeout {
5589 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
5590 }
5591 }
5592}
5593
Harald Welte883340c2018-02-28 18:59:29 +01005594/* Send AGCH from PCU; check it appears on Um side */
5595testcase TC_pcu_data_req_agch() runs on test_CT {
5596 timer T := 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005597 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005598 f_init_l1ctl();
5599 f_l1_tune(L1CTL);
5600
5601 f_TC_pcu_act_req(0, 0, 7, true);
5602 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
5603
5604 T.start;
5605 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01005606 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01005607 setverdict(pass);
5608 }
5609 [] L1CTL.receive { repeat; }
5610 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005611 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01005612 }
5613 }
5614}
5615
Harald Welte928622b2019-05-26 13:22:59 +02005616/* Send AGCH from PCU; check it appears on Um side */
5617testcase TC_pcu_data_req_pch() runs on test_CT {
5618 timer T := 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005619 f_init_with_pcuif();
Harald Welte928622b2019-05-26 13:22:59 +02005620 f_init_l1ctl();
5621 f_l1_tune(L1CTL);
5622
5623 f_TC_pcu_act_req(0, 0, 7, true);
5624 /* three characters prefix: last 3 digits of IMSI as ASCII */
5625 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
5626
5627 T.start;
5628 alt {
5629 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
5630 setverdict(pass);
5631 }
5632 [] L1CTL.receive { repeat; }
5633 [] T.timeout {
5634 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
5635 }
5636 }
5637}
5638
Harald Welte883340c2018-02-28 18:59:29 +01005639/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
5640testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
5641 var octetstring imm_ass := f_rnd_octstring(23);
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005642 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005643 f_init_l1ctl();
5644 f_l1_tune(L1CTL);
5645
5646 /* append 3 last imsi digits so BTS can compute pagng group */
5647 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
5648
5649 timer T := 0.5;
5650 T.start;
5651 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01005652 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01005653 /* TODO: verify paging group */
5654 setverdict(pass);
5655 }
5656 [] L1CTL.receive { repeat; }
5657 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005658 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01005659 }
5660 }
5661}
5662
5663/* Send RACH from Um side, expect it to show up on PCU socket */
5664testcase TC_pcu_rach_content() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005665 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005666 f_init_l1ctl();
5667 f_l1_tune(L1CTL);
5668
5669 var GsmFrameNumber fn_last := 0;
5670 for (var integer i := 0; i < 1000; i := i+1) {
5671 var OCT1 ra := f_rnd_ra_ps();
5672 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
5673 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005674 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01005675 }
5676 fn_last := fn;
5677
5678 timer T := 2.0;
5679 T.start;
5680 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005681 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn))) {
Harald Welte883340c2018-02-28 18:59:29 +01005682 T.stop;
5683 }
5684 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005685 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01005686 }
5687 [] PCU.receive { repeat; }
5688 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005689 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01005690 }
5691 }
5692 }
5693 setverdict(pass);
5694}
5695
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005696/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
5697 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
5698testcase TC_pcu_ext_rach_content() runs on test_CT {
5699 var template PCUIF_Message pcu_rach_ind;
5700 var GsmFrameNumber fn_last := 0;
5701 var L1ctlRachSynchSeq synch_seq;
5702 var PCUIF_BurstType pcu_bt;
5703 var GsmFrameNumber fn;
5704 var BIT11 ra11;
5705
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005706 f_init_with_pcuif();
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005707 f_init_l1ctl();
5708 f_l1_tune(L1CTL);
5709
5710 for (var integer i := 0; i < 1000; i := i+1) {
5711 /* We need to test both TS1 & TS2 */
5712 if (i rem 2 == 0) {
5713 synch_seq := RACH_SYNCH_SEQ_TS1;
5714 pcu_bt := BURST_TYPE_1;
5715 } else {
5716 synch_seq := RACH_SYNCH_SEQ_TS2;
5717 pcu_bt := BURST_TYPE_2;
5718 }
5719
5720 ra11 := f_rnd_ra11_ps();
5721 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
5722 if (fn == fn_last) {
5723 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5724 "Two RACH in same FN?!?");
5725 }
5726 fn_last := fn;
5727
5728 /* Compose the expected message */
5729 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005730 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005731 ra := bit2int(ra11),
5732 is_11bit := 1,
5733 burst_type := pcu_bt,
5734 fn := fn);
5735
5736 timer T := 2.0;
5737 T.start;
5738 alt {
5739 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
5740 T.stop;
5741 }
5742 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
5743 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
5744 }
5745 [] PCU.receive { repeat; }
5746 [] T.timeout {
5747 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
5748 }
5749 }
5750 }
5751 setverdict(pass);
5752}
5753
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005754private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
5755runs on test_CT {
5756 var template PCUIF_send_data sdt;
5757 var PCUIF_send_data sd;
5758 var int16_t lqual_cb;
5759 timer T := 1.0;
5760
5761 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
5762 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
5763
5764 /* Send a random PDTCH frame over Um */
5765 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
5766 '0000'O & f_rnd_octstring(21)));
5767
5768 T.start;
5769 alt {
5770 /* If expected link quality is above the threshold */
5771 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
5772 lqual_cb := sd.data.u.data_ind.lqual_cb;
5773 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
5774
5775 /* Make sure the actual link quality matches the expected value */
5776 if (not match(lqual_cb, lqual_cb_exp)) {
5777 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
5778 "expected value ", lqual_cb_exp));
5779 } else {
5780 setverdict(pass);
5781 }
5782 }
5783 /* If expected link quality is below the threshold */
5784 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
5785 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5786 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
5787 }
5788 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
5789 [] PCU.receive { repeat; }
5790 [lqual_cb_exp < thresh] T.timeout {
5791 log("Rx nothing, as expected");
5792 setverdict(pass);
5793 }
5794 [lqual_cb_exp >= thresh] T.timeout {
5795 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5796 "Timeout waiting for PCUIF_DATA.ind");
5797 }
5798 }
5799}
5800
5801/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
5802testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005803 f_init_with_pcuif();
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005804 PCU.clear;
5805
5806 f_init_l1ctl();
5807 f_l1_tune(L1CTL);
5808
5809 /* Activate a PDCH channel on TS7 */
5810 f_TC_pcu_act_req(0, 0, 7, true);
5811
5812 /* Tune trxcon to that PDCH channel on TS7 */
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005813 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiy13a29d52020-07-15 14:41:54 +07005814 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005815 { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); }
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005816 f_l1ctl_est_dchan(L1CTL, pars);
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005817
5818 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
5819 for (var int16_t i := -256; i <= 1280; i := i + 128) {
5820 var TrxcMessage ret;
5821
Vadim Yanitskiy418066a2021-10-03 14:04:17 +06005822 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(i));
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005823
5824 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
5825 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
5826 }
5827}
5828
Harald Welte883340c2018-02-28 18:59:29 +01005829/* Send PAGING via RSL, expect it to shw up on PCU socket */
5830testcase TC_pcu_paging_from_rsl() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005831 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005832
5833 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005834 var MobileIdentityLV mi_lv;
5835 var octetstring mi_lv_enc;
5836 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01005837 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005838
Harald Welte883340c2018-02-28 18:59:29 +01005839 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005840 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01005841 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005842 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01005843 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005844
5845 /* Fancy encoding for PCUIF */
5846 mi_lv := valueof(ts_MI_LV(mi));
5847 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
5848 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01005849
5850 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07005851 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01005852 T.start;
5853 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005854 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01005855 }
5856 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005857 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01005858 }
5859 [] PCU.receive { repeat; }
5860 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005861 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01005862 }
5863 }
5864 }
5865 setverdict(pass);
5866}
5867
Harald Welted66c9b82019-05-25 09:03:15 +02005868/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
5869testcase TC_pcu_time_ind() runs on test_CT {
5870 var PCUIF_send_data pcu_sd;
5871 var integer num_time_ind := 0;
5872 var integer first_fn, last_fn;
5873 var float test_duration := 5.0;
5874 timer T;
5875
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005876 f_init_with_pcuif();
Harald Welted66c9b82019-05-25 09:03:15 +02005877 f_TC_pcu_act_req(0, 0, 7, true);
5878
5879 PCU.clear;
5880 T.start(test_duration);
5881 alt {
5882 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
5883 num_time_ind := num_time_ind + 1;
5884 if (not isbound(first_fn)) {
5885 first_fn := pcu_sd.data.u.time_ind.fn;
5886 }
5887 last_fn := pcu_sd.data.u.time_ind.fn;
5888 repeat;
5889 }
5890 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
5891 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
5892 repeat;
5893 }
5894 [] PCU.receive {
5895 repeat;
5896 }
5897 [] T.timeout {}
5898 }
5899 var integer fn_expired := last_fn - first_fn;
5900 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
5901
5902 /* verify the number of frames expired matches our expectation */
5903 const float c_GSM_FN_DURATION_MS := 4.61538;
5904 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02005905 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02005906 if (not match(fn_expired, t_fn_expected)) {
5907 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
5908 }
5909
5910 /* There are three TIME.ind in every fn MOD 13 */
5911 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
5912 /* Add some tolerance */
5913 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
5914 if (not match(num_time_ind, t_time_ind_exp)) {
5915 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
5916 }
5917
5918 setverdict(pass);
5919}
5920
Harald Welte4832c862019-05-25 14:57:18 +02005921/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
5922testcase TC_pcu_rts_req() runs on test_CT {
5923 var PCUIF_send_data pcu_sd;
5924 var integer first_fn, last_fn;
5925 var integer num_rts_pdtch := 0;
5926 var integer num_rts_ptcch := 0;
5927 var float test_duration := 5.0;
5928 timer T;
5929
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005930 f_init_with_pcuif();
Harald Welte4832c862019-05-25 14:57:18 +02005931 f_TC_pcu_act_req(0, 0, 7, true);
5932
5933 PCU.clear;
5934 T.start(test_duration);
5935 alt {
5936 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
5937 -> value pcu_sd {
5938 num_rts_pdtch := num_rts_pdtch + 1;
5939 if (not isbound(first_fn)) {
5940 first_fn := pcu_sd.data.u.rts_req.fn;
5941 }
5942 last_fn := pcu_sd.data.u.rts_req.fn;
5943 repeat;
5944 }
5945 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
5946 -> value pcu_sd {
5947 num_rts_ptcch := num_rts_ptcch + 1;
5948 if (not isbound(first_fn)) {
5949 first_fn := pcu_sd.data.u.rts_req.fn;
5950 }
5951 last_fn := pcu_sd.data.u.rts_req.fn;
5952 repeat;
5953 }
5954 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
5955 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
5956 repeat;
5957 }
5958 [] PCU.receive {
5959 repeat;
5960 }
5961 [] T.timeout {}
5962 }
5963 var integer fn_expired := last_fn - first_fn;
5964 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
5965 ", num_rts_ptcch=", num_rts_ptcch);
5966
5967 /* verify the number of frames expired matches our expectation */
5968 const float c_GSM_FN_DURATION_MS := 4.61538;
5969 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02005970 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02005971 if (not match(fn_expired, t_fn_expected)) {
5972 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
5973 }
5974
5975 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
5976 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
5977 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
5978 if (not match(num_rts_ptcch, t_ptcch_exp)) {
5979 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
5980 t_ptcch_exp);
5981 }
5982
5983 /* We have 12 PDTCH blocks every 52-multiframe */
5984 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
5985 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
5986 if (not match(num_rts_pdtch, t_pdtch_exp)) {
5987 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
5988 t_pdtch_exp);
5989 }
5990
5991 setverdict(pass);
5992}
5993
Harald Welte07bd2d22019-05-25 11:03:30 +02005994/* test for generating Abis side OML ALERT from the PCU */
5995testcase TC_pcu_oml_alert() runs on test_CT {
5996 var PCUIF_send_data pcu_sd;
5997 var integer num_time_ind := 0;
5998 var integer first_fn, last_fn;
5999 var float test_duration := 5.0;
6000 timer T;
6001
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01006002 f_init_with_pcuif();
Harald Welte07bd2d22019-05-25 11:03:30 +02006003 f_TC_pcu_act_req(0, 0, 7, true);
6004
6005 /* re-connect CTRL port from BTS to BSC */
6006 f_ipa_ctrl_stop();
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01006007 f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
Harald Welte07bd2d22019-05-25 11:03:30 +02006008
6009 /* Send that OML Alert */
6010 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
6011
6012 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
6013 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
6014 setverdict(pass);
6015}
6016
Harald Welteeaa9a862019-05-26 23:01:08 +02006017/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
6018private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
6019 var PCUIF_Message first_info;
6020 var integer pcu_conn_id := -1;
6021 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6022 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
6023 var OCT4 tlli := '01020304'O;
6024 var OCT1 cause := '23'O;
6025 timer T := 5.0;
6026
6027 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6028
6029 f_l1_tune(L1CTL);
6030 RSL.clear;
6031
6032 f_est_dchan();
6033 L1CTL.clear;
6034
6035 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
6036
6037 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
6038 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
6039 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
6040
6041 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
6042 T.start;
6043 alt {
6044 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
6045 setverdict(pass);
6046 }
6047 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
6048 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
6049 }
6050 [] PCU.receive {
6051 repeat;
6052 }
6053 [] T.timeout {
6054 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
6055 }
6056 }
Alexander Couzensa0634832019-06-07 00:28:56 +02006057
6058 /* release the channel */
6059 f_rsl_chan_deact();
6060 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6061 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02006062}
6063testcase TC_pcu_rr_suspend() runs on test_CT {
6064 var ConnHdlrPars pars;
6065 var ConnHdlr vc_conn;
6066
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006067 f_init_with_pcuif();
Harald Welteeaa9a862019-05-26 23:01:08 +02006068
6069 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
6070 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
6071 vc_conn.done;
6072}
Harald Welte07bd2d22019-05-25 11:03:30 +02006073
Harald Weltea2e0e942019-05-27 18:12:53 +02006074/* Ensure that PCUIF socket can accept only a single connection */
6075testcase TC_pcu_socket_connect_multi() runs on test_CT {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006076 var boolean connected := false;
6077 var UD_connect_result cr;
6078 var integer cid;
Harald Weltea2e0e942019-05-27 18:12:53 +02006079 timer T := 5.0;
6080
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006081 var template UD_Result tr_ok := { result_code := SUCCESS, err := omit };
6082 var template UD_Result tr_err := { result_code := ERROR, err := ? };
6083
Harald Weltea2e0e942019-05-27 18:12:53 +02006084 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006085 f_init_with_pcuif();
Harald Weltea2e0e942019-05-27 18:12:53 +02006086
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006087 /* try to establish a second connection */
Harald Weltea2e0e942019-05-27 18:12:53 +02006088 PCU.send(UD_connect:{mp_pcu_socket, -1});
6089 T.start;
6090 alt {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006091 /* the IUT will first accept() the new connection, and close() it immediately */
6092 [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr {
6093 log("BTS has accept()ed connection");
6094 connected := true;
6095 cid := cr.id;
6096 repeat;
6097 }
6098 [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) {
6099 log("BTS has close()d connection");
Harald Weltea2e0e942019-05-27 18:12:53 +02006100 setverdict(pass);
6101 }
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006102 /* ignore other messages related to the first connection */
6103 [] PCU.receive { repeat; }
Harald Weltea2e0e942019-05-27 18:12:53 +02006104 [] T.timeout {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006105 setverdict(fail, "Timeout waiting for connection result");
Harald Weltea2e0e942019-05-27 18:12:53 +02006106 }
6107 }
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01006108
Harald Weltea2e0e942019-05-27 18:12:53 +02006109 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6110}
6111
Harald Weltec8effb72019-05-27 18:23:04 +02006112/* Ensure that PCUIF socket can disconnect + reconnect */
6113testcase TC_pcu_socket_reconnect() runs on test_CT {
6114 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006115 f_init_with_pcuif();
Harald Weltec8effb72019-05-27 18:23:04 +02006116
6117 f_sleep(1.0);
6118
6119 f_pcuif_close(PCU, g_pcu_conn_id);
6120 g_pcu_conn_id := -1;
6121
6122 f_sleep(1.0);
6123
6124 /* re-connect */
6125 PCU.clear;
6126 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
6127 setverdict(pass);
6128
6129 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6130}
6131
Harald Weltebe030482019-05-27 22:29:35 +02006132/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07006133private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
6134runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02006135 var L1ctlDlMessage l1_dl;
6136 var SystemInformation si;
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07006137 var integer rc;
Harald Weltebe030482019-05-27 22:29:35 +02006138 timer T := 5.0;
6139 T.start;
6140 alt {
6141 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07006142 rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si);
6143 if (rc != 0 or si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02006144 repeat;
6145 }
6146 }
6147 [] pt.receive {
6148 repeat;
6149 }
6150 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07006151 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6152 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02006153 }
6154 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07006155 return si;
Harald Weltebe030482019-05-27 22:29:35 +02006156}
6157
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006158/* Check if GPRS Indicator is present in RR System Information of a given type */
6159private function f_si_has_gprs_indicator(RrMessageType si_type)
6160runs on test_CT return boolean {
6161 var SystemInformation si := f_get_si(L1CTL, si_type);
6162
6163 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +02006164 return si.payload.si3.rest_octets.gprs_ind.presence == '1'B;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006165 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +02006166 return si.payload.si4.rest_octets.gprs_ind.presence == '1'B;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006167 }
6168
6169 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
6170 return false;
Harald Weltebe030482019-05-27 22:29:35 +02006171}
6172
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006173/* Make sure that GPRS Indicator is absent when the PCU is not connected */
6174private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
6175runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006176 f_init();
Harald Weltebe030482019-05-27 22:29:35 +02006177 f_init_l1ctl();
6178 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02006179 f_sleep(2.0);
6180 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006181
6182 if (f_si_has_gprs_indicator(si_type)) {
6183 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02006184 } else {
6185 setverdict(pass);
6186 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006187
Harald Weltebe030482019-05-27 22:29:35 +02006188 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6189}
6190
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006191testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
6192 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
6193}
Harald Weltebe030482019-05-27 22:29:35 +02006194
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006195testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
6196 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
6197}
6198
6199/* Ensure that GPRS capability is advertised after PCU socket connect */
6200private function f_TC_pcu_socket_connect(RrMessageType si_type)
6201runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02006202 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006203 f_init_with_pcuif();
Harald Weltebe030482019-05-27 22:29:35 +02006204 f_init_l1ctl();
6205 f_l1_tune(L1CTL);
6206
6207 f_sleep(2.0);
6208 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006209
6210 if (not f_si_has_gprs_indicator(si_type)) {
6211 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02006212 } else {
6213 setverdict(pass);
6214 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006215
Harald Weltebe030482019-05-27 22:29:35 +02006216 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6217}
6218
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006219testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
6220 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
6221}
Harald Weltebe030482019-05-27 22:29:35 +02006222
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006223testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
6224 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
6225}
6226
6227/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
6228private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
6229runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02006230 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006231 f_init_with_pcuif();
Harald Weltebe030482019-05-27 22:29:35 +02006232 f_init_l1ctl();
6233 f_l1_tune(L1CTL);
6234
6235 f_pcuif_close(PCU, g_pcu_conn_id);
6236 g_pcu_conn_id := -1;
6237
6238 f_sleep(1.0);
6239
6240 /* re-connect */
6241 PCU.clear;
6242 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
6243
6244 f_sleep(2.0);
6245 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006246
6247 if (f_si_has_gprs_indicator(si_type)) {
6248 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02006249 } else {
6250 setverdict(pass);
6251 }
6252
6253 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6254}
6255
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006256testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
6257 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
6258}
6259
6260testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
6261 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
6262}
6263
Oliver Smithf5239c72019-08-28 10:01:25 +02006264/* 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) */
6265testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
6266 var SystemInformation si3 := valueof(ts_SI3_default);
6267
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006268 f_init_with_pcuif();
Oliver Smithf5239c72019-08-28 10:01:25 +02006269
Harald Welte76220222020-10-11 20:32:44 +02006270 /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct
6271 * information */
6272 timer T := 2.0;
6273 T.start;
6274 alt {
6275 [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; }
6276 [] T.timeout {}
6277 }
6278
Oliver Smithf5239c72019-08-28 10:01:25 +02006279 /* Verify cell_id */
6280 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
6281 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
6282 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02006283 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
6284 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
6285 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02006286 }
6287
6288 /* Verify LAC */
6289 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
6290 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
6291 if (lac_si3 != lac_pcu) {
6292 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
6293 }
6294
6295 setverdict(pass);
6296}
Harald Welted66c9b82019-05-25 09:03:15 +02006297
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006298/* Verify hopping parameters in the INFO.ind message (version >= 10) */
6299testcase TC_pcu_info_ind_fh_params() runs on test_CT {
6300 var PCUIF_info_ind info_ind;
Vadim Yanitskiyca813922020-09-12 19:08:31 +07006301 var FreqHopPars fhp;
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006302
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006303 f_init_with_pcuif();
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006304
6305 info_ind := g_pcu_last_info.u.info_ind;
6306
6307 for (var integer i := 0; i < mp_transceiver_num; i := i + 1) {
6308 for (var integer tn := 0; tn < 8; tn := tn + 1) {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006309 if (info_ind.trx[i].pdch_mask[tn] != '1'B) {
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006310 /* Skip inactive timeslots */
6311 continue;
6312 }
6313
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006314 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiy7e1d0a22020-09-17 19:48:11 +07006315 { f_resolve_fh_params(fhp, tn, trx_nr := i); }
Vadim Yanitskiyca813922020-09-12 19:08:31 +07006316 else
6317 { fhp.enabled := false; }
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006318
6319 var template PCUIF_InfoTrxTs tr_ts;
Vadim Yanitskiyca813922020-09-12 19:08:31 +07006320 if (fhp.enabled) {
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006321 tr_ts := tr_PCUIF_InfoTrxTsH1(
Vadim Yanitskiyca813922020-09-12 19:08:31 +07006322 hsn := fhp.maio_hsn.hsn,
6323 maio := fhp.maio_hsn.maio,
6324 ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B),
Vadim Yanitskiyaa553ed2020-09-17 19:44:32 +07006325 ma_bit_len := mp_transceiver_num);
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006326 } else {
6327 tr_ts := tr_PCUIF_InfoTrxTsH0;
6328 }
6329
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006330 var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn];
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07006331 log("Checking timeslot #", tn, " of trx#", i, ": ", ts);
6332 if (not match(ts, tr_ts)) {
6333 setverdict(fail, "Hopping parameters do not match: ",
6334 "received ", ts, " vs expected ", tr_ts);
6335 } else {
6336 setverdict(pass);
6337 }
6338 }
6339 }
6340}
6341
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006342/* Verify IPv4 NSVC address in the INFO.ind message */
Alexander Couzens5283f552020-07-28 15:39:04 +02006343testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT {
6344 f_init_vty_bsc();
6345 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127");
6346 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6347
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006348 f_init_with_pcuif();
Alexander Couzens5283f552020-07-28 15:39:04 +02006349
6350 var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr;
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006351 var template PCUIF_RemoteAddr tr_remote_addr := {
6352 addr_type := { PCUIF_ADDR_TYPE_IPV4, ? },
Vadim Yanitskiy216021a2021-03-24 15:51:06 +01006353 addr := { f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), ? }
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006354 };
Alexander Couzens5283f552020-07-28 15:39:04 +02006355
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006356 if (not match(remote_addr, tr_remote_addr)) {
6357 setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr);
Alexander Couzens5283f552020-07-28 15:39:04 +02006358 }
6359
6360 setverdict(pass);
6361}
6362
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006363/* Verify IPv4 NSVC address in the INFO.ind message */
Alexander Couzens5283f552020-07-28 15:39:04 +02006364testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT {
6365 f_init_vty_bsc();
6366 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee");
6367
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01006368 f_init_with_pcuif();
Alexander Couzens5283f552020-07-28 15:39:04 +02006369
6370 var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr;
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006371 var template PCUIF_RemoteAddr tr_remote_addr := {
6372 addr_type := { PCUIF_ADDR_TYPE_IPV6, ? },
6373 addr := { f_inet6_addr("fd00::ca:ff:ee"), ? }
6374 };
Alexander Couzens5283f552020-07-28 15:39:04 +02006375
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006376 if (not match(remote_addr, tr_remote_addr)) {
6377 setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr);
Alexander Couzens5283f552020-07-28 15:39:04 +02006378 }
6379
6380 setverdict(pass);
6381}
6382
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01006383/* Verify coding of two NSVCs in the INFO.ind message */
6384testcase TC_pcu_socket_two_nsvc() runs on test_CT {
6385 f_init_vty_bsc();
6386
6387 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234");
6388 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234");
6389 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127");
6390 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234");
6391
6392 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678");
6393 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678");
6394 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee");
6395 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678");
6396
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01006397 f_init_with_pcuif();
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01006398
6399 var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind;
6400 var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr;
6401 var template PCUIF_RemoteAddr tr_remote_addr := {
6402 addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 },
Vadim Yanitskiy216021a2021-03-24 15:51:06 +01006403 addr := {
6404 f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O),
6405 f_inet6_addr("fd00::ca:ff:ee")
6406 }
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01006407 };
6408
6409 if (not match(info_ind.nsvci, { 1234, 5678 }))
6410 { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); }
6411 if (not match(remote_addr, tr_remote_addr))
6412 { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); }
6413 if (not match(info_ind.local_port, { 1234, 5678 }))
6414 { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); }
6415 if (not match(info_ind.remote_port, { 1234, 5678 }))
6416 { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); }
6417
6418 setverdict(pass);
6419}
6420
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006421/* Verify periodic interference reports on PDCH */
6422testcase TC_pcu_interf_ind() runs on test_CT {
6423 var template PCUIF_Message tr_interf_ind;
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006424 var integer interf_ind_num := 0;
Vadim Yanitskiy3b868cb2021-11-10 04:10:48 +03006425 var boolean first := true;
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006426 var PCUIF_send_data sd;
6427 timer T;
6428
Vadim Yanitskiyd9b60e62021-11-10 03:58:31 +03006429 /* Set the averaging/reporting period to 480ms */
6430 f_init_vty_bsc();
6431 f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 1" });
6432 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6433
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006434 f_init_with_pcuif();
6435 f_TC_pcu_act_req(0, 0, 7, true);
6436
6437 /* We need trxcon for NOPE indications */
6438 f_init_l1ctl();
6439 f_l1_tune(L1CTL);
6440
6441 /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006442 tr_interf_ind := tr_PCUIF_INTERF_IND(
6443 bts_nr := 0,
6444 trx_nr := 0,
6445 fn := ?,
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03006446 interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) }
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006447 );
6448
Vadim Yanitskiy3b868cb2021-11-10 04:10:48 +03006449 T.start(0.480 * 1.5);
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006450 alt {
Vadim Yanitskiy3b868cb2021-11-10 04:10:48 +03006451 /* The first interference report may contain unreliable values, so we ignore it */
6452 [first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) {
6453 /* 4 SACCH periods => 4 reports (plus some guard time) */
6454 T.start(0.480 * 4.0 + 0.480 / 2.0);
6455 first := false;
6456 repeat;
6457 }
6458 /* Subsequent interference reports shall match our expectations */
6459 [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd {
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006460 /* Check TDMA frame number period */
6461 if (sd.data.u.interf_ind.fn mod 104 != 0) {
6462 setverdict(fail, "Odd TDMA frame number := ",
6463 sd.data.u.interf_ind.fn);
6464 }
6465 interf_ind_num := interf_ind_num + 1;
6466 if (interf_ind_num < 4)
6467 { repeat; }
6468 }
Vadim Yanitskiy3b868cb2021-11-10 04:10:48 +03006469 [not first] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd {
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006470 setverdict(fail, "Received unexpected interference report: ", sd.data);
6471 }
6472 [] PCU.receive { repeat; }
6473 [] T.timeout {
6474 setverdict(fail, "Timeout waiting for interference reports");
6475 }
6476 }
6477
Vadim Yanitskiyd9b60e62021-11-10 03:58:31 +03006478 /* Reset the averaging/reporting period back to default */
6479 f_vty_cfg_bts(BSCVTY, 0, { "interference-meas avg-period 6" });
6480
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02006481 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6482}
6483
Harald Welte3d04ae62018-04-04 20:29:05 +02006484/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02006485 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02006486 ***********************************************************************/
6487
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006488private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp,
6489 integer bts_nr, integer trx_nr)
Harald Welte3d04ae62018-04-04 20:29:05 +02006490runs on ConnHdlr {
6491 var PCUIF_send_data sd;
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006492
6493 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006494 var BIT8 pdch_mask := sd.data.u.info_ind.trx[trx_nr].pdch_mask;
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006495 if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) {
6496 repeat;
6497 }
6498 }
6499}
6500
6501private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6502runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006503 /* Expect BTS to immediately acknowledge activation as PDCH */
6504 PCU.clear;
6505 f_rsl_chan_act(g_pars.chan_mode);
6506 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006507 timer T_wait := 2.0;
6508 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02006509 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006510 [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr);
Harald Welte3d04ae62018-04-04 20:29:05 +02006511 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006512 [] T_wait.timeout {
6513 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6514 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
6515 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006516 }
6517 /* try to activate this PDCH from the PCU point of view */
6518 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6519 /* FIXME: is there a response? */
6520}
6521
6522private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6523runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006524 /* Send RSL CHAN REL (deactivate) */
6525 PCU.clear;
6526 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
6527 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006528 timer T_wait := 2.0;
6529 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02006530 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006531 [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr);
Harald Welte3d04ae62018-04-04 20:29:05 +02006532 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006533 [] T_wait.timeout {
6534 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6535 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
6536 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006537 }
6538 /* Emulate PCU asking BTS to deactivate PDCH */
6539 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6540 alt {
6541 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
6542 setverdict(pass);
6543 }
6544 [] RSL.receive { repeat; }
6545 }
6546}
6547
6548/* Activate Osmocom-style dynamic PDCH from BSC side */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006549private function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006550 var PCUIF_Message first_info;
6551 var integer ts_nr := g_chan_nr.tn;
6552 var integer trx_nr := 0;
6553 var integer bts_nr := 0;
6554 var integer pcu_conn_id := -1;
6555
6556 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6557
6558 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6559 f_sleep(3.0);
6560 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6561 setverdict(pass);
6562}
6563testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
6564 var ConnHdlrPars pars;
6565 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006566 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006567
6568 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6569 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
6570 vc_conn.done;
6571}
6572
6573/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006574private function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006575 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02006576 var integer pcu_conn_id := -1;
6577
6578 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6579
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02006580 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
6581 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
6582 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02006583 setverdict(pass);
6584}
6585testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
6586 var ConnHdlrPars pars;
6587 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006588 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006589
6590 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6591 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
6592 vc_conn.done;
6593}
6594
6595/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006596private function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006597 var PCUIF_Message first_info;
6598 var integer ts_nr := g_chan_nr.tn;
6599 var integer trx_nr := 0;
6600 var integer bts_nr := 0;
6601 var integer pcu_conn_id := -1;
6602
6603 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6604
6605 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02006606 /* Send a second Chan Activ and expect it to be NACKed */
6607 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
6608 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02006609 setverdict(pass);
6610}
6611testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
6612 var ConnHdlrPars pars;
6613 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006614 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006615
6616 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6617 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
6618 vc_conn.done;
6619}
6620
6621/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006622private function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006623 var PCUIF_Message first_info;
6624 var integer ts_nr := g_chan_nr.tn;
6625 var integer trx_nr := 0;
6626 var integer bts_nr := 0;
6627 var integer pcu_conn_id := -1;
6628 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
6629
6630 /* register for the TCH/F channel number */
6631 f_rslem_register(0, chan_nr);
6632
6633 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6634
6635 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
6636 "RSL CHAN ACT");
6637 setverdict(pass);
6638}
6639testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
6640 var ConnHdlrPars pars;
6641 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006642 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006643
6644 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6645 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
6646 vc_conn.done;
6647}
6648
6649/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006650private function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006651 var PCUIF_Message first_info;
6652 var integer ts_nr := g_chan_nr.tn;
6653 var integer trx_nr := 0;
6654 var integer bts_nr := 0;
6655 var integer pcu_conn_id := -1;
6656 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
6657 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
6658
6659 /* register for the TCH/H channel numbers */
6660 f_rslem_register(0, chan_nr[0]);
6661 f_rslem_register(0, chan_nr[1]);
6662
6663 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6664
6665 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
6666 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
6667 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
6668 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
6669 setverdict(pass);
6670}
6671testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
6672 var ConnHdlrPars pars;
6673 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006674 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006675
6676 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6677 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
6678 vc_conn.done;
6679}
6680
Pau Espin Pedrol8e57ac12021-06-29 17:04:24 +02006681/* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */
6682private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr {
6683 var PCUIF_Message first_info;
6684 var integer ts_nr := g_chan_nr.tn;
6685 var integer trx_nr := 0;
6686 var integer bts_nr := 0;
6687 var integer pcu_conn_id := -1;
6688 var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)),
6689 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)),
6690 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)),
6691 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)),
6692 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)),
6693 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)),
6694 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)),
6695 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) };
6696
6697 /* register for the TCH/H channel numbers */
6698 for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) {
6699 f_rslem_register(0, chan_nr[i]);
6700 }
6701
6702 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6703
6704 for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) {
6705 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode),
6706 tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]");
6707 }
6708 setverdict(pass);
6709}
6710testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT {
6711 var ConnHdlrPars pars;
6712 var ConnHdlr vc_conn;
6713 f_init();
6714
6715 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6716 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true);
6717 vc_conn.done;
6718}
6719
Vadim Yanitskiy64043d82021-10-03 15:00:20 +06006720/* Reproduce a race condition described in OS#5245 */
6721private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr {
6722 f_rsl_chan_act(g_pars.chan_mode);
6723 f_sleep(1.0);
6724 f_rsl_chan_deact();
6725 setverdict(pass);
6726}
6727testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT {
6728 var ConnHdlrPars pars[2];
6729 var ConnHdlr vc_conn[2];
6730 var TrxcMessage rsp;
6731
6732 f_init();
6733
6734 /* Configure an artificial delay of 200 ms for TRXC RSP messages */
6735 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6736 ts_TRXC_FAKE_TRXC_DELAY(200));
6737
6738 /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second
6739 * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */
6740 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6741 /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */
6742 pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN));
6743 vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact),
6744 pars[i], l1ctl := false);
6745 }
6746
6747 /* Wait for all components to finish */
6748 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6749 vc_conn[i].done;
6750 }
6751
6752 /* Disable the artificial delay for TRXC RSP messages */
6753 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6754 ts_TRXC_FAKE_TRXC_DELAY(0));
6755}
6756testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT {
6757 var ConnHdlrPars pars[8];
6758 var ConnHdlr vc_conn[8];
6759 var TrxcMessage rsp;
6760
6761 f_init();
6762
6763 /* Configure an artificial delay of 200 ms for TRXC RSP messages */
6764 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6765 ts_TRXC_FAKE_TRXC_DELAY(200));
6766
6767 /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent
6768 * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */
6769 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6770 /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */
6771 pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN));
6772 vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact),
6773 pars[i], l1ctl := false);
6774 }
6775
6776 /* Wait for all components to finish */
6777 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6778 vc_conn[i].done;
6779 }
6780
6781 /* Disable the artificial delay for TRXC RSP messages */
6782 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6783 ts_TRXC_FAKE_TRXC_DELAY(0));
6784}
6785
Harald Welte9bbbfb52018-04-05 09:33:19 +02006786/***********************************************************************
6787 * IPA Style Dynamic Timeslot Support
6788 ***********************************************************************/
6789
6790private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6791runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006792 /* Expect BTS to immediately acknowledge activation as PDCH */
6793 PCU.clear;
6794 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
6795 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006796 timer T_wait := 2.0;
6797 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02006798 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006799 [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr);
Harald Welte9bbbfb52018-04-05 09:33:19 +02006800 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006801 [] T_wait.timeout {
6802 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6803 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
6804 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02006805 }
6806 /* try to activate this PDCH from the PCU point of view */
6807 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6808 /* FIXME: is there a response? */
6809
6810 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
6811}
6812
6813private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6814runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006815 /* Send RSL CHAN REL (deactivate) */
6816 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
6817 PCU.clear;
6818 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006819 timer T_wait := 2.0;
6820 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02006821 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006822 [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr);
Harald Welte9bbbfb52018-04-05 09:33:19 +02006823 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006824 [] T_wait.timeout {
6825 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6826 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
6827 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02006828 }
6829 /* Emulate PCU asking BTS to deactivate PDCH */
6830 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6831 alt {
6832 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
6833 setverdict(pass);
6834 }
6835 [] RSL.receive { repeat; }
6836 }
6837}
6838
6839/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006840private function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006841 var PCUIF_Message first_info;
6842 var integer ts_nr := g_chan_nr.tn;
6843 var integer trx_nr := 0;
6844 var integer bts_nr := 0;
6845 var integer pcu_conn_id := -1;
6846
6847 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6848
6849 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6850 f_sleep(3.0);
6851 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6852
6853 setverdict(pass);
6854
6855}
6856testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
6857 var ConnHdlrPars pars;
6858 var ConnHdlr vc_conn;
6859 f_init();
6860
6861 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6862 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
6863 vc_conn.done;
6864}
6865
6866/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006867private function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006868 var PCUIF_Message first_info;
6869 var integer ts_nr := g_chan_nr.tn;
6870 var integer trx_nr := 0;
6871 var integer bts_nr := 0;
6872 var integer pcu_conn_id := -1;
6873
6874 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6875
6876 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
6877 "RSL CHAN ACT");
6878 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
6879 "RF CHAN REL", true);
6880 setverdict(pass);
6881}
6882testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
6883 var ConnHdlrPars pars;
6884 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006885 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006886
6887 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6888 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
6889 vc_conn.done;
6890}
6891
6892/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006893private function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006894 var PCUIF_Message first_info;
6895 var integer ts_nr := g_chan_nr.tn;
6896 var integer trx_nr := 0;
6897 var integer bts_nr := 0;
6898 var integer pcu_conn_id := -1;
6899
6900 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6901
6902 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
6903 "RSL CHAN ACT");
6904
6905 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
6906 alt {
6907 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
6908 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006909 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02006910 }
6911 [] RSL.receive { repeat; }
6912 }
6913
6914 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
6915 "RF CHAN REL", true);
6916 setverdict(pass);
6917}
6918testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
6919 var ConnHdlrPars pars;
6920 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006921 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006922
6923 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6924 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
6925 vc_conn.done;
6926}
6927
6928/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006929private function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006930 var PCUIF_Message first_info;
6931 var integer ts_nr := g_chan_nr.tn;
6932 var integer trx_nr := 0;
6933 var integer bts_nr := 0;
6934 var integer pcu_conn_id := -1;
6935
6936 /* register for the TCH/F channel number */
6937 f_rslem_register(0, g_chan_nr);
6938
6939 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6940
6941 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6942
6943 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
6944 "RSL CHAN ACT");
6945
6946 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6947
6948 setverdict(pass);
6949}
6950testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
6951 var ConnHdlrPars pars;
6952 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006953 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006954
6955 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6956 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
6957 vc_conn.done;
6958}
6959
6960
Harald Welte0472ab42018-03-12 15:02:26 +01006961/***********************************************************************
6962 * LAPDm / RLL related
6963 ***********************************************************************/
6964
6965private function f_tx_lapdm(template (value) LapdmFrame l,
6966 template (value) RslLinkId link_id) runs on ConnHdlr {
6967 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006968 var template (value) SacchL1Header l1h;
6969
6970 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01006971 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006972 /* Compose dummy L1 header */
Vadim Yanitskiy68c4cff2022-07-30 23:45:02 +07006973 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, g_pars.l1_pars.ms_actual_ta);
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006974 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1h, f_pad_oct(l2, 21, '2B'O)));
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02006975 } else {
6976 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006977 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, f_pad_oct(l2, 23, '2B'O)));
Harald Welte0472ab42018-03-12 15:02:26 +01006978 }
Harald Welte0472ab42018-03-12 15:02:26 +01006979}
6980
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006981friend type record RllTestCase {
Harald Welte0472ab42018-03-12 15:02:26 +01006982 uint3_t sapi,
6983 RslLinkId link_id,
6984 octetstring l3,
6985 boolean exp
6986}
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006987friend type record of RllTestCase RllTestCases;
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006988friend template RllTestCase t_EITC(template (present) uint3_t sapi,
6989 template (present) RslLinkId id,
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006990 octetstring l3, boolean exp) := {
Harald Welte0472ab42018-03-12 15:02:26 +01006991 sapi := sapi,
6992 link_id := id,
6993 l3 := l3,
6994 exp := exp
6995}
6996
6997/* execute the same callback function with a set of different parameters (tcs) on a
6998 * variety of logical channels */
6999private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
7000 var ConnHdlrPars pars;
7001 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02007002 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01007003
7004 /* test on each of the channels we have */
7005 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
7006 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
7007
7008 /* test each of the test cases on the current channel */
7009 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
7010 pars.spec.rll := tcs[j];
7011 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
7012 vc_conn := f_start_handler(fn, pars);
7013 vc_conn.done;
7014 }
7015 }
7016
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007017 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01007018}
7019
7020/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
7021private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
7022 var RllTestCase tc := g_pars.spec.rll;
7023 timer T := 3.0;
7024
7025 f_l1_tune(L1CTL);
7026 RSL.clear;
7027
7028 /* activate the logical channel */
7029 f_est_dchan();
7030 L1CTL.clear;
7031
7032 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
7033 T.start;
7034 alt {
7035 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
7036 if (tc.exp) {
7037 setverdict(pass);
7038 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007039 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01007040 }
7041 }
7042 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
7043 if (tc.exp) {
7044 setverdict(pass);
7045 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007046 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01007047 }
7048 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07007049 /* We also expect to receive the measurements */
7050 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01007051 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007052 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01007053 }
7054 [not tc.exp] T.timeout {
7055 setverdict(pass);
7056 }
7057 }
7058
7059 f_rsl_chan_deact();
7060 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7061 f_rslem_unregister(0, g_chan_nr);
7062}
7063testcase TC_rll_est_ind() runs on test_CT {
7064 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02007065 /* SAPI0 establishment (contention resolution) */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007066 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02007067 /* normal SAPI0 establishment */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007068 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01007069 /* SAPI 3 doesn't support contention resolution */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007070 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)),
7071 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)),
Harald Welte0472ab42018-03-12 15:02:26 +01007072 /* normal SAPI3 establishment on main DCCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007073 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01007074 /* normal SAPI3 establishment on SACCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007075 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007076 };
7077 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
7078}
7079
7080/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
7081private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
7082 var RllTestCase tc := g_pars.spec.rll;
7083 var L1ctlDlMessage dl;
7084 timer T := 3.0;
7085
7086 f_l1_tune(L1CTL);
7087 RSL.clear;
7088
7089 /* activate the logical channel */
7090 f_est_dchan();
7091 L1CTL.clear;
7092
7093 /* Send a RSL EST REQ for SAPI3 on main DCCH */
7094 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
7095 T.start;
7096 alt {
Vadim Yanitskiy0310f632021-06-01 01:22:24 +02007097 [] as_l1_exp_lapdm(tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O));
Harald Welte0472ab42018-03-12 15:02:26 +01007098 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007099 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01007100 }
7101 }
7102
7103 f_rsl_chan_deact();
7104 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7105 f_rslem_unregister(0, g_chan_nr);
7106}
7107testcase TC_rll_est_req_DCCH_3() runs on test_CT {
7108 var RllTestCases tcs := {
7109 /* normal SAPI3 establishment on main DCCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007110 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//,
Harald Welte0472ab42018-03-12 15:02:26 +01007111 };
7112 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
7113}
7114testcase TC_rll_est_req_ACCH_3() runs on test_CT {
7115 var RllTestCases tcs := {
7116 /* normal SAPI3 establishment on SACCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007117 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007118 }
7119 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
7120}
7121
7122/* altstep to receive a LAPDm frame matching the given template */
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02007123friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
Harald Welte0472ab42018-03-12 15:02:26 +01007124 var L1ctlDlMessage dl;
7125 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
7126 var LapdmFrame lapdm;
7127 var octetstring l2 := dl.payload.data_ind.payload;
7128 if (dl.dl_info.link_id.c == SACCH) {
7129 /* remove L1 header */
7130 l2 := substr(l2, 2, lengthof(l2)-2);
7131 }
7132 if (ischosen(exp.ab)) {
7133 lapdm.ab := dec_LapdmFrameAB(l2);
7134 } else if (ischosen(exp.b4)) {
7135 lapdm.b4 := dec_LapdmFrameB4(l2);
7136 } else if (ischosen(exp.bbis)) {
7137 lapdm.bbis := dec_LapdmFrameBbis(l2);
7138 }
7139 log("Rx LAPDm ", lapdm);
7140 if (match(lapdm, exp)) {
7141 setverdict(pass);
7142 } else {
7143 repeat;
7144 }
7145 }
7146 [] L1CTL.receive { repeat; }
7147}
7148private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
7149 timer T := t;
7150 T.start;
7151 alt {
7152 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007153 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01007154 }
7155 [] as_l1_exp_lapdm(exp);
7156 }
7157}
7158
7159/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
7160private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
Vadim Yanitskiy25341352022-07-25 06:13:12 +07007161 timer T := 2.0;
Harald Welte0472ab42018-03-12 15:02:26 +01007162 /* send SABM from MS -> BTS */
7163 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
7164 /* expect RLL EST IND on Abis */
Vadim Yanitskiy25341352022-07-25 06:13:12 +07007165 T.start;
Harald Welte0472ab42018-03-12 15:02:26 +01007166 alt {
7167 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
7168 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
7169 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007170 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01007171 }
7172 [] RSL.receive { repeat; }
Vadim Yanitskiy25341352022-07-25 06:13:12 +07007173 [] T.timeout {
7174 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RLL EST IND");
7175 }
Harald Welte0472ab42018-03-12 15:02:26 +01007176 }
7177 /* expect UA from BTS -> MS */
7178 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
7179}
7180
7181/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
7182private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
7183 var RllTestCase tc := g_pars.spec.rll;
7184
7185 f_l1_tune(L1CTL);
7186 RSL.clear;
7187
7188 /* activate the logical channel */
7189 f_est_dchan();
7190 L1CTL.clear;
7191
7192 /* first establish the link-layer */
7193 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
7194
7195 /* then send the DISC */
7196 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
7197 /* ... and expect the REL IND on the RSL side */
7198 alt {
7199 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
7200 setverdict(pass);
7201 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07007202 /* We also expect to receive the measurements */
7203 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01007204 }
7205
7206 /* release the channel */
7207 f_rsl_chan_deact();
7208 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7209 f_rslem_unregister(0, g_chan_nr);
7210}
7211testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
7212 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007213 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007214 };
7215 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
7216}
7217
7218testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
7219 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007220 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007221 };
7222 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
7223}
7224testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
7225 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007226 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007227 };
7228 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
7229}
7230testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
7231 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007232 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007233 };
7234 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
7235}
7236
7237/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
7238private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
7239 var RllTestCase tc := g_pars.spec.rll;
7240 f_l1_tune(L1CTL);
7241 RSL.clear;
7242
7243 /* activate the logical channel */
7244 f_est_dchan();
7245 L1CTL.clear;
7246
7247 /* first establish the link-layer */
7248 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
7249
7250 /* then send the REL REQ via RSL */
7251 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
7252 /* ... and expect the DISC on the Um side */
7253 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02007254 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01007255 /* FIXME: send a UA in resposne to the DISC */
7256 }
7257 }
7258
7259 /* release the channel */
7260 f_rsl_chan_deact();
7261 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7262 f_rslem_unregister(0, g_chan_nr);
7263}
7264testcase TC_rll_rel_req() runs on test_CT {
7265 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007266 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)),
7267 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)),
7268 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)),
7269 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007270 };
7271 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
7272}
7273
Vadim Yanitskiy89be0602020-07-04 21:20:57 +07007274/* TODO: test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
Harald Welte0472ab42018-03-12 15:02:26 +01007275testcase TC_rll_data_req() runs on test_CT {
7276}
7277
Vadim Yanitskiy89be0602020-07-04 21:20:57 +07007278/* TODO: test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
Harald Welte0472ab42018-03-12 15:02:26 +01007279testcase TC_rll_data_ind() runs on test_CT {
7280}
7281
7282/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
7283private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
7284 var RllTestCase tc := g_pars.spec.rll;
7285
7286 f_l1_tune(L1CTL);
7287 RSL.clear;
7288
7289 f_est_dchan();
7290 L1CTL.clear;
7291
7292 /* Send UNITDATA REQ on RSL side */
7293 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
7294 /* Expect it to arrive on the other side */
7295 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02007296 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01007297 } else {
Harald Weltee613f962018-04-18 22:38:16 +02007298 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01007299 }
7300
7301 /* release the channel */
7302 f_rsl_chan_deact();
7303 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7304 f_rslem_unregister(0, g_chan_nr);
7305}
7306testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
7307 var octetstring l3 := f_rnd_octstring(15);
7308 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007309 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)),
7310 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007311 };
7312 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
7313}
7314testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
7315 var octetstring l3 := f_rnd_octstring(19);
7316 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007317 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)),
7318 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007319 };
7320 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
7321}
7322
7323/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
7324private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
7325 var RllTestCase tc := g_pars.spec.rll;
7326
7327 f_l1_tune(L1CTL);
7328 RSL.clear;
7329
7330 f_est_dchan();
7331 L1CTL.clear;
7332
7333 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02007334 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01007335 /* Expdct RLL UNITDATA IND on RSL side */
7336 alt {
7337 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
7338 setverdict(pass);
7339 }
7340 [] RSL.receive { repeat; }
7341 }
7342
7343 /* release the channel */
7344 f_rsl_chan_deact();
7345 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7346 f_rslem_unregister(0, g_chan_nr);
7347}
7348testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02007349 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01007350 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007351 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)),
7352 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007353 };
7354 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
7355}
7356testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
7357 var octetstring l3 := f_rnd_octstring(18);
7358 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02007359 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)),
7360 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01007361 };
7362 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
7363}
7364
Harald Weltee613f962018-04-18 22:38:16 +02007365/***********************************************************************
7366 * Encryption Related
7367 ***********************************************************************/
7368
7369/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07007370private function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02007371 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
7372 if (link_id.c == SACCH) {
7373 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
7374 } else {
7375 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
7376 }
7377}
7378
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07007379/* Expect (or not expect) other kinds of messages */
7380private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
7381 [exp_any] RSL.receive { repeat; }
7382 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007383 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07007384 }
7385}
7386
Harald Weltee613f962018-04-18 22:38:16 +02007387/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07007388private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07007389 RslLinkId link_id,
7390 octetstring l3,
7391 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07007392 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07007393) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02007394 timer T := 3.0;
7395 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
7396 T.start;
7397 /* Expect RLL UNITDATA IND on RSL side */
7398 alt {
7399 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
7400 setverdict(pass);
7401 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07007402 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07007403 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02007404 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007405 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02007406 }
Harald Weltee613f962018-04-18 22:38:16 +02007407 }
7408}
7409
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007410/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
7411private function f_data_mo(
7412 RslLinkId link_id,
7413 boolean p, uint3_t nr, uint3_t ns,
7414 octetstring l3,
7415 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07007416 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007417) runs on ConnHdlr {
7418 timer T := 3.0;
7419 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
7420 T.start;
7421 /* Expect RLL DATA IND on RSL side */
7422 alt {
7423 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
7424 setverdict(pass);
7425 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07007426 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007427 [] as_rsl_any_ind(exp_any);
7428 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007429 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007430 }
7431 }
7432}
7433
Harald Weltee613f962018-04-18 22:38:16 +02007434/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007435private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02007436 f_l1_tune(L1CTL);
7437 f_est_dchan(true);
7438
7439 /* now we actually need to transmit some data both ways to check if the encryption works */
7440 var L1ctlDlMessage dl;
7441
Stefan Sperling603d98e2018-07-25 16:47:28 +02007442 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02007443 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7444
7445 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
7446 f_unitdata_mt(link_id, l3);
7447
7448 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
7449 f_unitdata_mo(link_id, l3);
7450
7451 /* release the channel */
7452 f_rsl_chan_deact();
7453 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7454 f_rslem_unregister(0, g_chan_nr);
7455}
7456testcase TC_chan_act_a51() runs on test_CT {
7457 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7458 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7459 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7460}
7461testcase TC_chan_act_a52() runs on test_CT {
7462 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7463 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
7464 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7465}
7466testcase TC_chan_act_a53() runs on test_CT {
7467 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7468 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
7469 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7470}
Eric Wildb9260392021-05-15 19:48:22 +02007471testcase TC_chan_act_a54() runs on test_CT {
7472 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7473 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16)));
7474 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7475}
Harald Weltee613f962018-04-18 22:38:16 +02007476
Eric Wildf1827a72019-05-28 17:37:35 +02007477/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
7478 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007479private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
Eric Wildf1827a72019-05-28 17:37:35 +02007480 f_l1_tune(L1CTL);
7481 f_est_dchan(true);
7482
7483 /* now we actually need to transmit some data both ways to check if the encryption works */
7484 var L1ctlDlMessage dl;
7485
7486 var octetstring l3 := f_rnd_octstring(20);
7487 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7488
7489 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
7490 f_unitdata_mt(link_id, l3);
7491
7492 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
7493 f_unitdata_mo(link_id, l3);
7494
7495 var RSL_Message rsl;
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007496 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, ts_RSL_ChanMode_SIGN));
Eric Wildf1827a72019-05-28 17:37:35 +02007497
7498 /* modify key to break proper encryption */
7499 g_pars.encr.key := f_rnd_octstring(8);
7500 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
7501 rsl.ies := rsl.ies & { ei };
7502 RSL.send(rsl);
7503
7504 timer T0 := 1.0;
7505 T0.start;
7506 /* Expect RSL MODIFY ACK */
7507 alt {
7508 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
7509 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
7510 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
7511 }
7512 [] T0.timeout {
7513 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
7514 }
7515 }
7516
7517 var octetstring l3msg := f_rnd_octstring(15);
7518 timer T1 := 3.0;
7519 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
7520 due to broken encryption */
7521 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
7522 T1.start;
7523 alt {
7524 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
7525 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
7526 }
7527 [] T1.timeout {
7528 setverdict(pass);
7529 }
7530 }
7531
7532 /* release the channel */
7533 f_rsl_chan_deact();
7534 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7535 f_rslem_unregister(0, g_chan_nr);
7536}
7537testcase TC_rsl_modify_encr() runs on test_CT {
7538 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7539 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7540 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
7541}
Harald Weltee613f962018-04-18 22:38:16 +02007542
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +02007543/* Verify RF RESource INDication messages (periodically sent over the RSL) */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03007544private function f_TC_rsl_rf_resource_ind(template (present) RSL_ResourceInfo info)
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +02007545runs on test_CT {
7546 const IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
7547 var ASP_RSL_Unitdata ud;
7548 timer T;
7549
7550 /* Intave is 6 SACCH periods by default */
7551 var float Tval := int2float(6 * 480) / 1000.0 + 0.5;
7552
7553 T.start(Tval);
7554 alt {
7555 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) {
7556 setverdict(pass);
7557 }
7558 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud {
7559 setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl);
7560 }
7561 [] RSL_CCHAN.receive { repeat; }
7562 [] T.timeout {
7563 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
7564 "Timeout waiting for RF RESource INDication");
7565 }
7566 }
7567}
7568testcase TC_rsl_rf_resource_ind() runs on test_CT {
7569 var RSL_ResourceInfo info := { };
7570
7571 f_init(trx_nr := 0);
7572
7573 f_init_l1ctl();
7574 f_l1_tune(L1CTL);
7575
7576 /* g_AllChannels contains all logical channels */
7577 for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) {
7578 var RslChannelNr chan_nr := g_AllChannels[i];
7579
7580 /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */
7581 if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH)
7582 { continue; }
7583
7584 info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) };
7585 }
7586
7587 /* Align to the first interference report */
7588 f_TC_rsl_rf_resource_ind(?);
7589
7590 /* Test 4 consecutive messages */
7591 for (var integer i := 0; i < 4; i := i + 1) {
7592 f_TC_rsl_rf_resource_ind(info);
7593 }
7594
7595 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7596}
7597
Harald Weltee613f962018-04-18 22:38:16 +02007598/* Test unencrypted channel activation followed by explicit ENCR CMD later */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007599private function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02007600 /* L3 payload doesn't matter, as it is passed transparently */
7601 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
7602 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
7603 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7604
7605 f_l1_tune(L1CTL);
7606
7607 /* first establish a dedicated channel in the clear */
7608 f_est_dchan(false);
7609
7610 /* Establish ABM */
7611 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
7612
7613 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
7614 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
7615 /* expect the L3 to arrive still unencrypted on the MS side */
7616 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
7617
7618 /* configure L1 to apply ciphering */
7619 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
7620 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
7621
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007622 /* send first ciphered I-frame in response and expect it on RSL */
7623 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02007624
7625 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
7626 * and hence enable encryption also on the downlink */
7627
7628 /* expect bi-directional communication work in encrypted mode */
7629 f_unitdata_mo(link_id, f_rnd_octstring(15));
7630 f_unitdata_mt(link_id, f_rnd_octstring(15));
7631
7632 /* release the channel */
7633 f_rsl_chan_deact();
7634 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7635 f_rslem_unregister(0, g_chan_nr);
7636}
7637testcase TC_encr_cmd_a51() runs on test_CT {
7638 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7639 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7640 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7641}
7642testcase TC_encr_cmd_a52() runs on test_CT {
7643 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7644 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
7645 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7646}
7647testcase TC_encr_cmd_a53() runs on test_CT {
7648 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7649 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
7650 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7651}
Eric Wildb9260392021-05-15 19:48:22 +02007652testcase TC_encr_cmd_a54() runs on test_CT {
7653 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7654 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16)));
7655 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7656}
Harald Weltee613f962018-04-18 22:38:16 +02007657
7658private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
7659 var LapdmFrame lf;
7660 var octetstring reenc;
7661
7662 /* decode the LAPDm frame */
7663 if (ischosen(exp_match.ab)) {
7664 lf.ab := dec_LapdmFrameAB(enc);
7665 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007666 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02007667 }
7668
7669 /* check if decoder result matches expectation */
7670 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007671 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02007672 } else {
7673 log(name, ": matched");
7674 setverdict(pass);
7675 }
7676
7677 /* test if re-encoded frame equals original input */
7678 reenc := enc_LapdmFrame(lf);
7679 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007680 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02007681 } else {
7682 setverdict(pass);
7683 }
7684}
7685
7686testcase TC_lapdm_selftest() runs on test_CT {
7687 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
7688 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
7689 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
7690 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
7691 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
7692 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
7693 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
7694}
7695
Stefan Sperling4880be42018-08-07 18:12:59 +02007696/***********************************************************************
7697 * DTX Related (see GSM 05.08, section 8.3)
7698 ***********************************************************************/
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007699private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
Stefan Sperling4880be42018-08-07 18:12:59 +02007700 var L1ctlDlMessage dl;
Stefan Sperling4880be42018-08-07 18:12:59 +02007701 var GsmFrameNumber first_fn;
7702 var boolean is_first_frame := true;
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007703 var integer nfill_frames := 0;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007704 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02007705 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
7706 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007707 const integer frame_dtx_tchf_mod := 104;
7708 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
7709 * which operates in terms of blocks rather than frames. */
7710 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
7711 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02007712 timer T := 5.0;
7713
7714 f_l1_tune(L1CTL);
7715 RSL.clear;
7716 L1CTL.clear;
7717
7718 /* activate TCHF signalling channel */
7719 f_est_dchan(false);
7720
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007721 /* A template for matching dummy LAPDm func=UA frames */
7722 var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND(
7723 chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?),
7724 l2_data := f_pad_oct('030301'O, 23, '2B'O));
7725
Stefan Sperling4880be42018-08-07 18:12:59 +02007726 T.start;
7727 alt {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007728 [] L1CTL.receive(tr_fill_frame) -> value dl {
Stefan Sperling4880be42018-08-07 18:12:59 +02007729 var GsmFrameNumber fn := dl.dl_info.frame_nr;
Stefan Sperling4880be42018-08-07 18:12:59 +02007730
7731 if (is_first_frame) {
7732 is_first_frame := false;
7733 first_fn := dl.dl_info.frame_nr;
7734 }
7735
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007736 if (g_pars.chan_mode.dtx_d) {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007737 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007738 T.stop;
7739 f_rsl_chan_deact();
7740 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007741
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007742 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */
7743 expected_fill_frames := 2;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007744
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007745 if (nfill_frames < expected_fill_frames) {
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007746 setverdict(fail, "Not enough fill frames received: ",
7747 nfill_frames, " out of ", expected_fill_frames);
7748 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Stefan Sperling4880be42018-08-07 18:12:59 +02007749 } else {
7750 setverdict(pass);
7751 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007752 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007753 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
7754 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
7755 * we should only see the subset of frames numbers which correspond to a block boundary.
7756 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
7757 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
7758 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007759 nfill_frames := nfill_frames + 1;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007760 repeat;
7761 }
7762 }
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007763 setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn,
7764 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
7765 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007766 f_rsl_chan_deact();
7767 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling4880be42018-08-07 18:12:59 +02007768 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007769 } else {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007770 nfill_frames := nfill_frames + 1;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007771 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007772 T.stop;
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007773
7774 select (g_chan_nr) {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007775 /* TCH/F: we expect 24 fill frames for every 104 frames. */
7776 case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; }
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007777 /* TCH/H: we expect 2 fill frames for every 104 frames. */
7778 case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; }
7779 /* SDCCH: we expect 5 fill frames for every 104 frames. */
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007780 case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; }
7781 case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; }
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007782 case else {
7783 /* This shall not happen, just to be sure */
7784 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7785 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007786 }
7787
7788 f_rsl_chan_deact();
7789 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007790
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007791 if (nfill_frames >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007792 setverdict(pass);
7793 } else {
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007794 setverdict(fail, "Not enough fill frames received: ",
7795 nfill_frames, " out of ", expected_fill_frames);
7796 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Stefan Sperling4880be42018-08-07 18:12:59 +02007797 }
7798 } else {
7799 repeat;
7800 }
7801 }
7802 }
7803 [] L1CTL.receive { repeat; }
7804 [] T.timeout {
7805 f_rsl_chan_deact();
7806 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007807 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02007808 }
7809 }
7810}
7811
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007812private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007813 var template RSL_IE_ChannelMode ch_mode;
Stefan Sperling4880be42018-08-07 18:12:59 +02007814 var ConnHdlr vc_conn;
7815 var ConnHdlrPars pars;
7816 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02007817 f_init();
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007818 ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd);
Stefan Sperling4880be42018-08-07 18:12:59 +02007819 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007820 pars := valueof(t_Pars(g_AllChannels[i], ch_mode));
Stefan Sperling4880be42018-08-07 18:12:59 +02007821 if (dtxd) {
7822 if (i >= 4) { /* DTX is only allowed on TCH/F */
7823 break;
7824 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007825 }
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007826 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
Stefan Sperling4880be42018-08-07 18:12:59 +02007827 vc_conn.done;
7828 }
7829}
7830
7831/* Verify that L2 fill frames are sent on TCH in signaling mode if
7832 * there is nothing to transmit while DTX is disabled on downlink. */
7833testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
7834 f_tch_sign_l2_fill_frame(false);
7835}
7836
7837/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
7838 * there is nothing to transmit while DTX is enabled on downlink. */
7839testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
7840 f_tch_sign_l2_fill_frame(true);
7841}
Harald Welte0472ab42018-03-12 15:02:26 +01007842
Stefan Sperling0ec1c262018-10-15 15:12:52 +02007843testcase TC_chopped_ipa_ping() runs on test_CT {
7844 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
7845}
7846
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007847testcase TC_chopped_ipa_payload() runs on test_CT {
7848 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
7849}
7850
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007851
7852/* Callback function to be called by as_TC_ms_pwr_ctrl_constant().
7853 * Return value: Measurement Report to be sent (encoded octetstring). */
7854type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks)
7855 runs on ConnHdlr return octetstring;
7856
7857private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks)
7858runs on ConnHdlr {
7859 var L1ctlDlMessage l1_dl;
7860 var SacchL1Header l1h;
7861 var octetstring l2;
7862
7863 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
7864 /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
7865 l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2));
7866 log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h);
7867
7868 /* Pass it to the user specified call-back function */
7869 l2 := cb.apply(l1h, num_blocks);
7870 /* Send a Measurement Report generated by the call-back */
7871 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr,
7872 l1_dl.dl_info.link_id,
7873 l1h, l2));
7874
7875 /* Shall we keep going? */
7876 num_blocks := num_blocks - 1;
7877 log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining");
7878 if (num_blocks > 0) { repeat; }
7879 }
7880 [] L1CTL.receive { repeat; }
7881}
7882
7883private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks)
7884runs on ConnHdlr return octetstring {
7885 /* Command the L1 to apply received parameters */
7886 f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl);
7887
7888 /* Dummy measurement report (the results are invalid) */
7889 return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O);
7890}
7891
7892private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks)
7893runs on ConnHdlr return octetstring {
7894 if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) {
7895 setverdict(fail, "Unexpected MS Power level change: ",
7896 g_pars.l1_pars.ms_power_level, " -> ",
7897 l1h.ms_power_lvl);
7898 }
7899
7900 return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks);
7901}
7902
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07007903private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks)
7904runs on ConnHdlr return octetstring {
7905 /* UL RSSI oscillation driven by SACCH block number */
7906 if (num_blocks rem 2 == 0) {
7907 f_trxc_fake_rssi(-100);
7908 } else {
7909 f_trxc_fake_rssi(-50);
7910 }
7911
7912 /* Make sure that MS power level remains constant */
7913 return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks);
7914}
7915
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007916/* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */
7917private function f_TC_ms_pwr_ctrl_constant(charstring id)
7918runs on ConnHdlr {
7919 var integer num_blocks := 8;
7920 timer T := int2float(num_blocks);
7921
7922 f_l1_tune(L1CTL);
7923 RSL.clear;
7924
7925 /* These IEs are needed for autonomous MS power control */
7926 var template (value) RSL_IE_List ies := {
7927 t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{
7928 ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level)
7929 }),
7930 t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{
7931 ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O)
7932 })
7933 };
7934
7935 /* Ensure that 'rx-current' equals 'rx-target' */
7936 f_trxc_fake_rssi(mp_uplink_power_target);
7937
Vadim Yanitskiy8a1685d2022-07-30 23:56:18 +07007938 /* Populate SACCH cache with a Measurement Report */
Vadim Yanitskiye2003d02022-08-10 17:38:07 +07007939 f_send_meas_rep(ts_MeasurementResults);
Vadim Yanitskiy8a1685d2022-07-30 23:56:18 +07007940
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007941 /* Establish a dedicated channel */
7942 f_est_dchan(more_ies := valueof(ies));
7943
7944 L1CTL.clear;
7945 T.start;
7946 alt {
7947 [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks);
7948 [] T.timeout {
7949 setverdict(fail, "Not all SACCH blocks were processed in time, ",
7950 num_blocks, " were not handled");
7951 }
7952 }
Vadim Yanitskiy6b4404a2021-06-17 17:22:56 +02007953
7954 /* Release the channel */
7955 f_rsl_chan_deact();
7956 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007957}
7958testcase TC_ms_pwr_ctrl_constant() runs on test_CT {
7959 var ConnHdlr vc_conn;
7960 var ConnHdlrPars pars;
7961
7962 f_init();
7963
7964 /* Explicitly configure the Uplink power target (in dBm) */
7965 f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target));
7966
7967 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) {
7968 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
7969 log(testcasename(), ": starting on ", pars.chan_nr);
7970
7971 vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant),
7972 pars, trxc_comp := true);
7973 vc_conn.done;
7974 }
7975
7976 /* No need to reset Uplink power parameters - the IUT restarts anyway */
7977 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7978}
7979
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07007980/* Test Exponentially Weighted Moving Average (EWMA) power filtering */
7981private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id)
7982runs on ConnHdlr {
7983 var integer num_blocks := 16;
7984 timer T := int2float(num_blocks);
7985
7986 f_l1_tune(L1CTL);
7987 RSL.clear;
7988
7989 /* These IEs are needed for autonomous MS power control */
7990 var template (value) RSL_IE_List ies := {
7991 t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{
7992 ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level)
7993 }),
7994 t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{
7995 ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O)
7996 })
7997 };
7998
7999 /* Ensure that 'rx-current' equals 'rx-target' */
8000 f_trxc_fake_rssi(mp_uplink_power_target);
8001
Vadim Yanitskiy8a1685d2022-07-30 23:56:18 +07008002 /* Populate SACCH cache with a Measurement Report */
Vadim Yanitskiye2003d02022-08-10 17:38:07 +07008003 f_send_meas_rep(ts_MeasurementResults);
Vadim Yanitskiy8a1685d2022-07-30 23:56:18 +07008004
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07008005 /* Establish a dedicated channel */
8006 f_est_dchan(more_ies := valueof(ies));
8007
8008 L1CTL.clear;
8009 T.start;
8010 alt {
8011 [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks);
8012 [] T.timeout {
8013 setverdict(fail, "Not all SACCH blocks were processed in time, ",
8014 num_blocks, " were not handled");
8015 }
8016 }
Vadim Yanitskiy6b4404a2021-06-17 17:22:56 +02008017
8018 /* Release the channel */
8019 f_rsl_chan_deact();
8020 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07008021}
8022testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT {
8023 var ConnHdlr vc_conn;
8024 var ConnHdlrPars pars;
8025
8026 f_init();
8027
8028 /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */
8029 f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80");
8030 /* Explicitly configure the Uplink power range (target and delte) */
8031 f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)
8032 & " hysteresis " & int2str(mp_uplink_power_hysteresis));
8033
8034 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) {
8035 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
8036 log(testcasename(), ": starting on ", pars.chan_nr);
8037
8038 vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma),
8039 pars, trxc_comp := true);
8040 vc_conn.done;
8041 }
8042
8043 /* No need to reset Uplink power parameters - the IUT restarts anyway */
8044 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8045}
8046
Vadim Yanitskiy5fa85612020-10-21 03:46:18 +07008047private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr {
8048 var template L1ctlDlMessage tr_bad_frame;
8049 var L1ctlDlMessage l1_dl;
8050 timer T := 8.0;
8051
8052 f_l1_tune(L1CTL);
8053 RSL.clear;
8054
8055 f_est_dchan();
8056
8057 /* There may be a few errors right after the channel activation */
8058 f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */
8059 L1CTL.clear;
8060
8061 /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */
8062 tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0));
8063 tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND);
8064 tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */
8065 tr_bad_frame.payload := ?;
8066
8067 T.start;
8068 alt {
8069 /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that
8070 * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */
8071 [] L1CTL.receive(tr_bad_frame) -> value l1_dl {
8072 setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl);
8073 }
8074 [] as_l1_sacch();
8075 [] L1CTL.receive { repeat; }
8076 [] T.timeout {
8077 /* We're done, break the loop */
8078 setverdict(pass);
8079 }
8080 }
8081
8082 f_rsl_chan_deact();
8083 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
8084}
8085testcase TC_speech_no_rtp_tchf() runs on test_CT {
8086 var ConnHdlr vc_conn;
8087 var ConnHdlrPars pars;
8088
8089 f_init();
8090
8091 /* TS1, TCH/F, V1 (FR codec) */
8092 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)));
8093 vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars);
8094 vc_conn.done;
8095}
8096testcase TC_speech_no_rtp_tchh() runs on test_CT {
8097 var ConnHdlr vc_conn;
8098 var ConnHdlrPars pars;
8099
8100 f_init();
8101
8102 /* TS5, TCH/H, V1 (HR codec) */
8103 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)));
8104 vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars);
8105 vc_conn.done;
8106}
8107
Vadim Yanitskiy18684882021-07-04 04:15:58 +02008108/* Verify handling of Downlink and Uplink speech frames */
8109private function f_TC_speech_rtp(charstring id) runs on ConnHdlr {
8110 var L1ctlDlMessage l1_dl;
8111 var PDU_RTP rtp_pdu;
8112 var octetstring pl;
8113 timer Td, Tu;
8114
8115 f_l1_tune(L1CTL);
8116 f_est_dchan();
8117
8118 /* Activate the RTP emulation */
8119 pl := f_rnd_octstring(6);
8120 f_rtpem_activate(pl);
8121
8122 /* Give the scheduler some time to fill up the buffers */
8123 f_sleep(2.0);
8124 L1CTL.clear;
8125 RSL.clear;
8126
8127 /* Make sure that Downlink frames are received at the UE */
8128 Td.start(2.0);
8129 alt {
8130 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl {
8131 log("TCH received: ", l1_dl.payload.traffic_ind.data);
8132 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id,
8133 l1_dl.payload.traffic_ind.data));
8134 setverdict(pass);
8135 }
8136 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl {
8137 setverdict(fail, "Rx unexpected Downlink speech frame ",
8138 "(", l1_dl.payload.traffic_ind.data, ") ",
8139 "expected (", pl, ")");
8140 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8141 }
8142 [] as_l1_sacch();
8143 [] L1CTL.receive { repeat; }
8144 [] Td.timeout {
8145 setverdict(fail, "Timeout waiting for Downlink speech frames");
8146 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8147 }
8148 }
8149
8150 /* Make sure that Uplink frames are received at the BTS */
8151 RTPEM_DATA.clear;
8152 Tu.start(2.0);
8153 alt {
8154 [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu {
8155 if (rtp_pdu.data != pl)
8156 { repeat; }
8157 }
8158 [] RTPEM_DATA.receive { repeat; }
8159 [] Tu.timeout {
8160 setverdict(fail, "Timeout waiting for Uplink speech frames");
8161 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8162 }
8163 }
8164
8165 f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE);
8166 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
8167 f_rsl_chan_deact();
8168 f_rslem_unregister(0, g_chan_nr);
8169}
8170testcase TC_speech_rtp_tchf() runs on test_CT {
8171 var ConnHdlr vc_conn;
8172 var ConnHdlrPars pars;
8173
8174 f_init();
8175
8176 /* TS1, TCH/F, V1 (FR codec) */
8177 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)));
8178 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
8179 vc_conn.done;
8180
8181 /* TS1, TCH/F, V2 (EFR codec) */
8182 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)));
8183 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
8184 vc_conn.done;
8185
Pau Espin Pedrol091c5302022-09-02 18:11:12 +02008186 /* TS1, TCH/F, V3 (AMR codec) */
8187 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3)));
8188 pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */));
8189 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
8190 vc_conn.done;
Vadim Yanitskiy18684882021-07-04 04:15:58 +02008191
8192 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8193}
8194testcase TC_speech_rtp_tchh() runs on test_CT {
8195 var ConnHdlr vc_conn;
8196 var ConnHdlrPars pars;
8197
8198 f_init();
8199
8200 /* TS5, TCH/H0, V1 (HR codec) */
8201 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)));
8202 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
8203 vc_conn.done;
8204
Pau Espin Pedrol091c5302022-09-02 18:11:12 +02008205 /* TS1, TCH/H0, V3 (AMR codec) */
8206 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3)));
8207 pars.mr_conf := valueof(ts_RSL_MultirateCfg(false, 0, '00000100'B /* 5,90k */));
8208 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
8209 vc_conn.done;
Vadim Yanitskiy18684882021-07-04 04:15:58 +02008210
8211 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8212}
8213
Neels Hofmeyraf9d6ae2021-08-15 23:18:47 +02008214private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr {
8215 var GsmFrameNumber fn;
8216 var ChannelDescription ch_desc;
8217 var integer ra := 23;
8218
8219 f_l1_tune(L1CTL);
8220 RSL.clear;
8221
8222 /* Send RACH request and wait for ChanReq */
8223 fn := f_rach_req_wait_chan_rqd(ra);
8224
8225 /* The BSC already sends the Immediate Assignment, before the channel is active.
8226 * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM
8227 * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the
8228 * IMM ASS. So move the IMM ASS even before the Chan Activ.) */
8229 if (g_pars.fhp.enabled) {
8230 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
8231 } else {
8232 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc));
8233 }
8234 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map));
8235 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
8236
8237 /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC
8238 * requests Chan Activ, to make sure the RR IMM ASS is held back. */
8239 var L1ctlDlMessage dl;
8240 var GsmRrMessage rr;
8241
8242 var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn);
8243 rr_imm_ass.payload.imm_ass.ded_or_tbf := ?;
8244 rr_imm_ass.payload.imm_ass.pkt_chan_desc := *;
8245 rr_imm_ass.payload.imm_ass.chan_desc := *;
8246
8247 timer T := 1.0;
8248 T.start;
8249 alt {
8250 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
8251 rr := dec_GsmRrMessage(dl.payload.data_ind.payload);
8252 if (match(rr, rr_imm_ass)) {
8253 setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately");
8254 mtc.stop;
8255 } else {
8256 repeat;
8257 }
8258 }
8259 [] L1CTL.receive { repeat; }
8260 [] T.timeout;
8261 }
8262 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA));
8263 RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr));
8264
8265 /* Now expect the IMM ASS on Um */
8266 f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
8267 setverdict(pass);
8268
8269 /* Release the channel */
8270 f_rsl_chan_deact();
8271 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
8272}
8273
8274testcase TC_early_immediate_assignment() runs on test_CT {
8275 var ConnHdlr vc_conn;
8276 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
8277 f_init();
8278 vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars);
8279 vc_conn.done;
8280 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8281}
8282
Vadim Yanitskiyd0eb6592021-10-08 01:19:29 +06008283private function f_TC_est_dchan(charstring id) runs on ConnHdlr {
8284 var integer ra := oct2int(f_rnd_ra_cs());
8285 var ChannelDescription ch_desc;
8286
8287 /* Tune the MS to BCCH */
8288 f_l1_tune(L1CTL);
8289
8290 /* Send RACH request and wait for ChanReq */
8291 var GsmFrameNumber fn := f_rach_req_wait_chan_rqd(ra);
8292
8293 /* Activate channel on the BTS side */
8294 f_rsl_chan_act(g_pars.chan_mode);
8295
8296 /* Craft channel description (with or without frequency hopping parameters) */
8297 if (g_pars.fhp.enabled) {
8298 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
8299 } else {
8300 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc));
8301 }
8302
8303 /* Send IMM.ASS via CCHAN */
8304 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map));
8305 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
8306
8307 /* Receive IMM.ASS on the MS side */
8308 var ImmediateAssignment imm_ass := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
8309
8310 /* Match the Channel Description IE in received IMM.ASS */
8311 if (not match(imm_ass.chan_desc, ch_desc)) {
8312 setverdict(fail, "Channel Description IE does not match");
8313 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8314 }
8315
8316 /* Tune the MS to a dedicated channel indicated in the IMM.ASS */
8317 f_L1CTL_DM_EST_REQ_IA(L1CTL, imm_ass, g_pars.fhp.ma);
8318
8319 /* Expect SACCH frames on Downlink */
8320 L1CTL.clear;
8321 f_exp_sacch(true);
8322
8323 /* We're done, deactivate and release */
8324 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
8325 f_rsl_chan_deact();
8326}
8327testcase TC_est_dchan() runs on test_CT {
8328 var ConnHdlr vc_conn;
8329 var ConnHdlrPars pars;
8330
8331 f_init();
8332
8333 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
8334 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
8335 vc_conn := f_start_handler(refers(f_TC_est_dchan), pars);
8336 vc_conn.done;
8337 }
8338
8339 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8340}
8341
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008342private type record TopTestCase {
8343 RSL_IE_BS_Power bs_power,
8344 RSL_IE_OSMO_TopAcchCap top_cap,
8345 record of TopTestStep steps
8346};
8347private type record TopTestStep {
8348 MeasurementResults meas_res optional,
8349 GsmRxLev overpower_sacch,
8350 GsmRxLev overpower_facch
8351};
8352
8353private function f_rxlev_match(template (present) RslLinkId link_id,
8354 template (present) GsmRxLev rxlev)
8355runs on ConnHdlr {
8356 var L1ctlDlMessage dl := f_L1CTL_rx_data(L1CTL, g_chan_nr, link_id);
8357 if (not match(dl.dl_info.rx_level, rxlev)) {
8358 setverdict(fail, "RxLev(", link_id, ") := ", dl.dl_info.rx_level,
8359 " does not match expected RxLev := ", rxlev);
8360 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8361 }
8362}
8363
8364private function f_TC_acch_overpower(charstring id) runs on ConnHdlr {
8365 var TopTestCase tc := g_pars.spec.top;
8366 var GsmRxLev rxlev_dcch;
8367 var L1ctlDlMessage dl;
8368
8369 /* Wait for Pau ramping to complete */
8370 f_sleep(6.0);
8371
8372 f_l1_tune(L1CTL);
8373 L1CTL.clear;
8374 RSL.clear;
8375
8376 /* Measure RxLev(BCCH), calculate RxLev(DCCH) */
8377 dl := f_L1CTL_rx_data(L1CTL, t_RslChanNr_BCCH(0));
8378 rxlev_dcch := dl.dl_info.rx_level - (tc.bs_power.power_level * 2);
8379
8380 log("RxLev(BCCH) := ", dl.dl_info.rx_level);
8381 log("Expected RxLev(DCCH) := ", rxlev_dcch);
8382
8383 /* Additional IEs for the CHANnel ACTIVation message */
8384 var template (value) RSL_IE_List ies := {
8385 /* Employ BS power control in static mode */
8386 t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{
8387 bs_power := tc.bs_power
8388 }),
8389 /* Indicate the given Temporary Overpower capability */
8390 t_RSL_IE(RSL_IE_OSMO_TOP_ACCH_CAP, RSL_IE_Body:{
8391 top_acch_cap := tc.top_cap
8392 })
8393 };
8394
8395 /* Establish a dedicated channel */
8396 f_est_dchan(more_ies := valueof(ies));
8397
8398 /* Give it some time to stabilize */
8399 f_sleep(0.480 * 2.0);
8400 L1CTL.clear;
8401 RSL.clear;
8402
8403 for (var integer i := 0; i < lengthof(tc.steps); i := i + 1) {
8404 var TopTestStep step := tc.steps[i];
8405 var GsmRxLev rxlev_facch := rxlev_dcch + step.overpower_facch;
8406 var GsmRxLev rxlev_sacch := rxlev_dcch + step.overpower_sacch;
8407
8408 log("Executing step[", i, "] := ", step);
8409
8410 /* Send RR Measurement Report (if present) */
8411 if (ispresent(step.meas_res)) {
8412 f_transceive_meas_rep(step.meas_res);
8413 f_sleep(0.480 * 2.0);
8414 L1CTL.clear;
8415 }
8416
8417 /* Check RxLev on both FACCH and SACCH */
8418 f_rxlev_match(tr_RslLinkID_DCCH(?), rxlev_facch);
8419 f_rxlev_match(tr_RslLinkID_SACCH(?), rxlev_sacch);
8420
8421 setverdict(pass);
8422 }
8423}
8424testcase TC_acch_overpower_rxqual_thresh() runs on test_CT {
8425 var ConnHdlrPars pars;
8426 var ConnHdlr vc_conn;
8427
8428 f_init();
8429
8430 /* Verify lower and upper RxQual thresholds */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03008431 var template (value) TopTestCase top := {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008432 bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */
8433 top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */
8434 steps := {
8435 /* Channel established, no overpower */
8436 { meas_res := omit,
8437 overpower_sacch := 0, overpower_facch := 0 },
8438
8439 /* Worst possible RxQual value, overpower of 4dB */
8440 { meas_res := ts_MeasurementResults(rxq_f := 7),
8441 overpower_sacch := 4, overpower_facch := 4 },
8442 /* Worst possible RxQual value, disabling overpower */
8443 { meas_res := ts_MeasurementResults(rxq_f := 0),
8444 overpower_sacch := 0, overpower_facch := 0 },
8445
8446 /* Lower threshold not reached, no overpower */
8447 { meas_res := ts_MeasurementResults(rxq_f := 1),
8448 overpower_sacch := 0, overpower_facch := 0 },
8449 /* Lower threshold not reached, no overpower */
8450 { meas_res := ts_MeasurementResults(rxq_f := 2),
8451 overpower_sacch := 0, overpower_facch := 0 },
8452 /* Lower threshold reached, overpower of 4dB */
8453 { meas_res := ts_MeasurementResults(rxq_f := 4),
8454 overpower_sacch := 4, overpower_facch := 4 },
8455 /* Upper threshold not reached, keeping overpower */
8456 { meas_res := ts_MeasurementResults(rxq_f := 3),
8457 overpower_sacch := 4, overpower_facch := 4 },
8458 /* Upper threshold reached, disabling overpower */
8459 { meas_res := ts_MeasurementResults(rxq_f := 2),
8460 overpower_sacch := 0, overpower_facch := 0 }
8461 }
8462 };
8463
8464 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN,
8465 spec := { top := top }, trx_nr := 1));
8466 vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars);
8467 vc_conn.done;
8468
8469 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8470}
8471testcase TC_acch_overpower_rxqual_thresh_dtx() runs on test_CT {
8472 var ConnHdlrPars pars;
8473 var ConnHdlr vc_conn;
8474
8475 f_init();
8476
8477 /* Verify handling of FULL and SUB values */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03008478 var template (value) TopTestCase top := {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008479 bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */
8480 top_cap := ts_RSL_IE_OSMO_TopAcchCap(4), /* 4dB */
8481 steps := {
8482 /* Channel established, no overpower */
8483 { meas_res := omit,
8484 overpower_sacch := 0, overpower_facch := 0 },
8485
8486 /* Invalid measurement results, no overpower */
8487 { meas_res := ts_MeasurementResults(rxq_f := 7,
8488 rxq_s := 7,
8489 valid := false),
8490 overpower_sacch := 0, overpower_facch := 0 },
8491
8492 /* DTXu was in use, no overpower */
8493 { meas_res := ts_MeasurementResults(rxq_f := 7,
8494 rxq_s := 0,
8495 dtx_used := true),
8496 overpower_sacch := 0, overpower_facch := 0 },
8497 /* DTXu was in use, overpower of 4 dB */
8498 { meas_res := ts_MeasurementResults(rxq_f := 0,
8499 rxq_s := 7,
8500 dtx_used := true),
8501 overpower_sacch := 4, overpower_facch := 4 }
8502 }
8503 };
8504
8505 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN,
8506 spec := { top := top }, trx_nr := 1));
8507 vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars);
8508 vc_conn.done;
8509
8510 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8511}
8512testcase TC_acch_overpower_always_on_facch() runs on test_CT {
8513 var ConnHdlrPars pars;
8514 var ConnHdlr vc_conn;
8515
8516 f_init();
8517
8518 /* Overpower is always on, SACCH disabled */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03008519 var template (value) TopTestCase top := {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008520 bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */
8521 top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */
8522 rxqual := 0, /* always on */
8523 sacch_enable := false),
8524 steps := {
8525 /* Channel established, FACCH overpower */
8526 { meas_res := omit,
8527 overpower_sacch := 0, overpower_facch := 4 },
8528 /* MS indicates good RxQual, no difference */
8529 { meas_res := ts_MeasurementResults(rxq_f := 0),
8530 overpower_sacch := 0, overpower_facch := 4 },
8531 /* MS indicates bad RxQual, no difference */
8532 { meas_res := ts_MeasurementResults(rxq_f := 7),
8533 overpower_sacch := 0, overpower_facch := 4 }
8534 }
8535 };
8536
8537 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN,
8538 spec := { top := top }, trx_nr := 1));
8539 vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars);
8540 vc_conn.done;
8541
8542 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8543}
8544testcase TC_acch_overpower_always_on_sacch() runs on test_CT {
8545 var ConnHdlrPars pars;
8546 var ConnHdlr vc_conn;
8547
8548 f_init();
8549
8550 /* Overpower is always on, FACCH disabled */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03008551 var template (value) TopTestCase top := {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008552 bs_power := ts_RSL_IE_BS_Power(4), /* 4 x 2dB = 8dB */
8553 top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */
8554 rxqual := 0, /* always on */
8555 facch_enable := false),
8556 steps := {
8557 /* Channel established, SACCH overpower */
8558 { meas_res := omit,
8559 overpower_sacch := 4, overpower_facch := 0 },
8560 /* MS indicates good RxQual, no difference */
8561 { meas_res := ts_MeasurementResults(rxq_f := 0),
8562 overpower_sacch := 4, overpower_facch := 0 },
8563 /* MS indicates bad RxQual, no difference */
8564 { meas_res := ts_MeasurementResults(rxq_f := 7),
8565 overpower_sacch := 4, overpower_facch := 0 }
8566 }
8567 };
8568
8569 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN,
8570 spec := { top := top }, trx_nr := 1));
8571 vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars);
8572 vc_conn.done;
8573
8574 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8575}
8576testcase TC_acch_overpower_limit() runs on test_CT {
8577 var ConnHdlrPars pars;
8578 var ConnHdlr vc_conn;
8579
8580 f_init();
8581
8582 /* Overpower higher than current power reduction level (2dB) */
Vadim Yanitskiyd12db412022-03-12 18:05:18 +03008583 var template (value) TopTestCase top := {
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008584 bs_power := ts_RSL_IE_BS_Power(1), /* 1 x 2dB = 2dB */
8585 top_cap := ts_RSL_IE_OSMO_TopAcchCap(overpower := 4, /* 4dB */
8586 rxqual := 0 /* always on */),
8587 steps := {
8588 /* Channel established, ACCH overpower of 2dB */
8589 { meas_res := omit,
8590 overpower_sacch := 2, overpower_facch := 2 },
8591 /* MS indicates good RxQual, no difference */
8592 { meas_res := ts_MeasurementResults(rxq_f := 0),
8593 overpower_sacch := 2, overpower_facch := 2 },
8594 /* MS indicates bad RxQual, no difference */
8595 { meas_res := ts_MeasurementResults(rxq_f := 7),
8596 overpower_sacch := 2, overpower_facch := 2 }
8597 }
8598 };
8599
8600 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN,
8601 spec := { top := top }, trx_nr := 1));
8602 vc_conn := f_start_handler(refers(f_TC_acch_overpower), pars);
8603 vc_conn.done;
8604
8605 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
8606}
8607
Harald Welte0472ab42018-03-12 15:02:26 +01008608/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
8609/* protocol error as per 44.006 */
8610/* link layer failure (repetition of I-frame N200 times without ACK */
8611/* repetition of SABM or DISC N200 times without ACK */
8612/* receptiom of SABM in multi-frame established state */
8613
8614
Harald Welte68e495b2018-02-25 00:05:57 +01008615/* TODO Areas:
8616
8617* channel activation
8618** with BS_Power / MS_Power, bypassing power control loop
8619** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01008620** with timing advance from initial activation on
8621* mode modify
8622** encryption
8623** multirate
8624* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01008625** unsupported algorithm
Harald Welte68e495b2018-02-25 00:05:57 +01008626* BS Power Control
8627* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01008628* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01008629** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01008630* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01008631** DATA_IND from BTS->PCU
8632** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01008633
8634*/
Harald Welte70767382018-02-21 12:16:40 +01008635
8636control {
Vadim Yanitskiyd0eb6592021-10-08 01:19:29 +06008637 execute( TC_est_dchan() );
Harald Welte70767382018-02-21 12:16:40 +01008638 execute( TC_chan_act_stress() );
8639 execute( TC_chan_act_react() );
8640 execute( TC_chan_deact_not_active() );
8641 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01008642 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01008643 execute( TC_sacch_filling() );
8644 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01008645 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01008646 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02008647 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02008648 execute( TC_sacch_chan_act_ho_async() );
8649 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01008650 execute( TC_rach_content() );
Philipp Maier16ade782020-07-08 21:36:00 +02008651 execute( TC_rach_content_emerg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01008652 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01008653 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07008654 execute( TC_ho_rach() );
Vadim Yanitskiy1ab332f2022-03-12 15:31:23 +03008655 execute( TC_ho_physical_info() );
Harald Welte3453ab42019-05-24 21:19:58 +02008656 execute( TC_rach_load_idle_thresh0() );
8657 execute( TC_rach_load_idle_below_thresh() );
8658 execute( TC_rach_load_count() );
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07008659 execute( TC_meas_res_speech_tchf() );
Philipp Maier149c3922020-10-22 17:29:36 +02008660 execute( TC_meas_res_speech_tchf_facch() );
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07008661 execute( TC_meas_res_speech_tchh() );
Philipp Maier149c3922020-10-22 17:29:36 +02008662 execute( TC_meas_res_speech_tchh_facch() );
Vadim Yanitskiy780bc072020-10-20 02:16:01 +07008663 execute( TC_meas_res_speech_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01008664 execute( TC_meas_res_sign_tchf() );
8665 execute( TC_meas_res_sign_tchh() );
8666 execute( TC_meas_res_sign_sdcch4() );
8667 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01008668 execute( TC_meas_res_sign_tchh_toa256() );
Vadim Yanitskiy8f6eae02021-10-26 02:49:21 +03008669 execute( TC_meas_res_speech_tchf_sapi3() );
8670 execute( TC_meas_res_speech_tchh_sapi3() );
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02008671 execute( TC_tx_power_start_ramp_up_bcch() );
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02008672 execute( TC_tx_power_start_ramp_down_bcch() );
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02008673 execute( TC_tx_power_ramp_adm_state_change() );
Eric Wildae8f2622019-06-18 17:05:11 +02008674 execute( TC_rsl_bs_pwr_static_ass() );
8675 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01008676 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02008677 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02008678 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02008679 execute( TC_rsl_ms_pwr_dyn_up() );
8680 execute( TC_rsl_ms_pwr_dyn_down() );
8681 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
8682 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02008683 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02008684 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02008685 execute( TC_rsl_modify_encr() );
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +02008686 execute( TC_rsl_rf_resource_ind() );
Harald Welte70767382018-02-21 12:16:40 +01008687 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01008688 execute( TC_paging_imsi_80percent() );
8689 execute( TC_paging_tmsi_80percent() );
8690 execute( TC_paging_imsi_200percent() );
8691 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01008692 execute( TC_rsl_protocol_error() );
8693 execute( TC_rsl_mand_ie_error() );
8694 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01008695 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01008696 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01008697 execute( TC_si_sched_2bis() );
8698 execute( TC_si_sched_2ter() );
8699 execute( TC_si_sched_2ter_2bis() );
8700 execute( TC_si_sched_2quater() );
8701 execute( TC_si_sched_13() );
8702 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01008703 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01008704 execute( TC_ipa_crcx_twice_not_active() );
8705 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01008706 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01008707 execute( TC_ipa_crcx_sdcch_not_active() );
Vadim Yanitskiy866afc22022-05-01 16:08:30 +03008708 execute( TC_ipa_crcx_ack_addr() );
Harald Welte883340c2018-02-28 18:59:29 +01008709
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008710 if (mp_pcu_socket != "") {
Philipp Maierca058272021-06-23 10:35:23 +02008711 execute( TC_paging_imsi_200percent_with_ps() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008712 execute( TC_pcu_act_req() );
8713 execute( TC_pcu_act_req_wrong_ts() );
8714 execute( TC_pcu_act_req_wrong_bts() );
8715 execute( TC_pcu_act_req_wrong_trx() );
8716 execute( TC_pcu_deact_req() );
8717 execute( TC_pcu_deact_req_wrong_ts() );
Philipp Maier94c08482021-02-01 17:36:05 +01008718 execute( TC_pcu_ver_si1() );
8719 execute( TC_pcu_ver_si3() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008720 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02008721 if (mp_l1_supports_gprs) {
8722 execute( TC_pcu_data_req_pdtch() );
8723 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02008724 execute( TC_pcu_data_req_wrong_bts() );
8725 execute( TC_pcu_data_req_wrong_trx() );
8726 execute( TC_pcu_data_req_wrong_ts() );
8727 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02008728 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07008729 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008730 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02008731 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008732 execute( TC_pcu_data_req_imm_ass_pch() );
8733 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07008734 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07008735 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008736 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02008737 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02008738 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02008739 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02008740 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02008741 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02008742 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02008743 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07008744 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02008745 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07008746 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02008747 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07008748 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02008749 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01008750 execute( TC_dyn_osmo_pdch_act_deact() );
8751 execute( TC_dyn_osmo_pdch_double_act() );
8752 execute( TC_dyn_ipa_pdch_act_deact() );
8753 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01008754 execute( TC_pcu_info_ind_fh_params() );
8755 execute( TC_pcu_socket_nsvc_ipv4() );
8756 execute( TC_pcu_socket_nsvc_ipv6() );
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01008757 execute( TC_pcu_socket_two_nsvc() );
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02008758 execute( TC_pcu_interf_ind() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01008759 } else {
8760 log("PCU socket path not available, skipping PCU tests");
8761 }
Harald Welte3d04ae62018-04-04 20:29:05 +02008762
Harald Welte3d04ae62018-04-04 20:29:05 +02008763 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02008764 execute( TC_dyn_osmo_pdch_tchf_act() );
8765 execute( TC_dyn_osmo_pdch_tchh_act() );
Pau Espin Pedrol8e57ac12021-06-29 17:04:24 +02008766 execute( TC_dyn_osmo_pdch_sdcch8_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02008767 execute( TC_dyn_ipa_pdch_tchf_act() );
8768 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01008769
8770 execute( TC_rll_est_ind() );
8771 execute( TC_rll_est_req_DCCH_3() );
8772 execute( TC_rll_est_req_ACCH_3() );
8773 execute( TC_rll_rel_ind_DCCH_0() );
8774 execute( TC_rll_rel_ind_DCCH_3() );
8775 execute( TC_rll_rel_ind_ACCH_0() );
8776 execute( TC_rll_rel_ind_ACCH_3() );
8777 execute( TC_rll_rel_req() );
8778 execute( TC_rll_unit_data_req_DCCH() );
8779 execute( TC_rll_unit_data_req_ACCH() );
8780 execute( TC_rll_unit_data_ind_DCCH() );
8781 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02008782
8783 execute( TC_chan_act_a51() );
8784 execute( TC_chan_act_a52() );
8785 execute( TC_chan_act_a53() );
Vadim Yanitskiy8b4e0462022-08-27 19:18:17 +07008786 execute( TC_chan_act_a54() );
Harald Weltee613f962018-04-18 22:38:16 +02008787 execute( TC_encr_cmd_a51() );
8788 execute( TC_encr_cmd_a52() );
8789 execute( TC_encr_cmd_a53() );
Vadim Yanitskiy8b4e0462022-08-27 19:18:17 +07008790 execute( TC_encr_cmd_a54() );
Harald Weltee613f962018-04-18 22:38:16 +02008791
Harald Welteee25aae2019-05-19 14:32:37 +02008792 execute( TC_err_rep_wrong_mdisc() );
8793 execute( TC_err_rep_wrong_msg_type() );
8794 execute( TC_err_rep_wrong_sequence() );
8795
Harald Weltee613f962018-04-18 22:38:16 +02008796 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02008797
8798 execute( TC_tch_sign_l2_fill_frame() );
8799 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02008800
8801 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008802 execute( TC_chopped_ipa_payload() );
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07008803
8804 execute( TC_ms_pwr_ctrl_constant() );
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07008805 execute( TC_ms_pwr_ctrl_pf_ewma() );
Vadim Yanitskiy5fa85612020-10-21 03:46:18 +07008806
8807 execute( TC_speech_no_rtp_tchf() );
8808 execute( TC_speech_no_rtp_tchh() );
Vadim Yanitskiy18684882021-07-04 04:15:58 +02008809 execute( TC_speech_rtp_tchf() );
8810 execute( TC_speech_rtp_tchh() );
Neels Hofmeyraf9d6ae2021-08-15 23:18:47 +02008811
8812 execute( TC_early_immediate_assignment() );
Vadim Yanitskiy46f19922021-10-06 02:36:22 +06008813
Vadim Yanitskiyf9e31d22021-11-06 18:43:28 +03008814 execute( TC_acch_overpower_rxqual_thresh() );
8815 execute( TC_acch_overpower_rxqual_thresh_dtx() );
8816 execute( TC_acch_overpower_always_on_facch() );
8817 execute( TC_acch_overpower_always_on_sacch() );
8818 execute( TC_acch_overpower_limit() );
8819
Vadim Yanitskiy46f19922021-10-06 02:36:22 +06008820 /* BEWARE: these test cases can potentially break the IUT or cause
8821 * weird/unexpected behavior. Ensure that they are executed last. */
8822 execute( TC_dyn_osmo_pdch_tchh_race_act() );
8823 execute( TC_dyn_osmo_pdch_sdcch8_race_act() );
Harald Welte70767382018-02-21 12:16:40 +01008824}
8825
8826
8827}