blob: 03519d94638371a83c8a77283893ae732e68f836 [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
50import from IPL4asp_Types all;
51import from TRXC_Types all;
52import from TRXC_CodecPort all;
53import from TRXC_CodecPort_CtrlFunct all;
54
Harald Welte883340c2018-02-28 18:59:29 +010055import from PCUIF_Types all;
56import from PCUIF_CodecPort all;
Harald Weltea2e0e942019-05-27 18:12:53 +020057import from UD_Types all;
Harald Welte883340c2018-02-28 18:59:29 +010058
Harald Welte7484fc42018-02-24 14:09:45 +010059import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010060import from MobileL3_RRM_Types all;
61import from MobileL3_Types all;
62import from L3_Templates all;
Harald Welteeaa9a862019-05-26 23:01:08 +020063import from L3_Common all;
64import from MobileL3_GMM_SM_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010065
Harald Welte8da48242018-02-27 20:41:32 +010066import from Osmocom_VTY_Functions all;
67import from TELNETasp_PortType all;
Harald Welte2f2b2b72019-05-31 22:24:57 +020068import from BTS_Tests_LAPDm all;
Harald Welte8da48242018-02-27 20:41:32 +010069
Harald Welte505cf9b2018-09-15 17:47:23 +030070friend module BTS_Tests_SMSCB;
Vadim Yanitskiy73878132021-05-05 02:22:45 +020071friend module BTS_Tests_VAMOS;
Harald Weltead033dc2019-05-25 17:28:16 +020072friend module BTS_Tests_virtphy;
Harald Welte2f2b2b72019-05-31 22:24:57 +020073friend module BTS_Tests_LAPDm;
Pau Espin Pedrol5a012ee2020-02-06 19:33:22 +010074friend module BTS_Tests_perf;
Pau Espin Pedrol65d712e2021-06-25 13:55:38 +020075friend module BTS_Tests_OML;
Harald Welte505cf9b2018-09-15 17:47:23 +030076
Harald Welte70767382018-02-21 12:16:40 +010077/* The tests assume a BTS with the following timeslot configuration:
78 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020079 * TS1 : TCH/F
80 * TS2 : TCH/F
81 * TS3 : TCH/F_PDCH (IPA Style)
82 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010083 * TS5 : TCH/H
84 * TS6 : SDCCH/8
85 * TS7 : PDCH
86 */
87
88modulepar {
89 charstring mp_rsl_ip := "127.0.0.2";
90 integer mp_rsl_port := 3003;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070091 charstring mp_bts_trxc_ip := "127.0.0.1";
92 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010093 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020094 charstring mp_ctrl_ip := "127.0.0.1";
95 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020096 charstring mp_bsc_ctrl_ip := "127.0.0.1";
97 integer mp_bsc_ctrl_port := 4249;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +020098 charstring mp_rtpem_bind_ip := "127.0.0.1";
99 integer mp_rtpem_bind_port := 6766;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200100 integer mp_tolerance_rxqual := 1;
101 integer mp_tolerance_rxlev := 3;
102 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200103 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200104 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200105 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +0200106 integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */
107 integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200108 integer mp_ms_actual_ta_exp := 0;
109 integer mp_timing_offset_256syms_exp := 512;
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +0700110 integer mp_uplink_power_target := -75;
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +0700111 integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100112 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +0200113 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200114 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200115 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
116 boolean mp_l1_supports_gprs := false;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700117 /* how many transceivers do we expect to connect */
118 integer mp_transceiver_num := 1;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700119 /* frequency hopping status */
120 boolean mp_freq_hop_enabled := false;
121 /* frequency hopping parameters */
122 FreqHopConfig mp_fh_config;
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700123 /* configuration for each individual transceiver */
124 TrxPars mp_trx_pars; /* see BTS_Tests.default */
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700125 /* default Training Sequence Code */
126 GsmTsc mp_tsc_def := 7;
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +0200127 /* Default interference boundaries in osmo-bsc (in dBm):
128 * 0(-85) X1(-91) X2(-97) X3(-103) X4(-109) X5(-115)
129 * Default interference level reported by fake_trx.py:
130 * 0: -109 >= -85 dBm (no)
131 * X1: -109 >= -91 dBm (no)
132 * X2: -109 >= -97 dBm (no)
133 * X3: -109 >= -103 dBm (no)
134 * X4: -109 >= -109 dBm (yes)
135 * X5: -109 >= -115 dBm (no)
136 * So all channels should be in band 4. */
137 uint3_t mp_interf_band := 4;
Harald Welte70767382018-02-21 12:16:40 +0100138}
139
Harald Welte629cc6b2018-03-11 17:19:05 +0100140type record of RslChannelNr ChannelNrs;
141
Harald Welte70767382018-02-21 12:16:40 +0100142type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100143 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100144 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100145 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100146 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100147 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100148 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100149
150 /* L1CTL port (for classic tests) */
151 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100152
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700153 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700154 port TRXC_CODEC_PT BTS_TRXC;
155 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100156
Harald Weltef50e3ae2018-09-10 10:27:56 +0200157 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100158 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200159 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100160
Harald Welte883340c2018-02-28 18:59:29 +0100161 /* PCU Interface of BTS */
162 port PCUIF_CODEC_PT PCU;
163 var integer g_pcu_conn_id;
164 /* Last PCU INFO IND we received */
165 var PCUIF_Message g_pcu_last_info;
166
Harald Welte48494ca2018-02-25 16:59:50 +0100167 /* SI configuration */
168 var SystemInformationConfig si_cfg := {
169 bcch_extended := false,
170 si1_present := false,
171 si2bis_present := false,
172 si2ter_present := false,
173 si2quater_present := false,
174 si7_present := false,
175 si8_present := false,
176 si9_present := false,
177 si13_present := false,
178 si13alt_present := false,
179 si15_present := false,
180 si16_present := false,
181 si17_present := false,
182 si2n_present := false,
183 si21_present := false,
184 si22_present := false
185 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100186
187 /* all logical channels available on the BTS */
188 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100189 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100190}
191
192/* an individual call / channel */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200193type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100194 port L1CTL_PT L1CTL;
195
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700196 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700197 port TRXC_CODEC_PT BTS_TRXC;
198 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100199
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200200 /* port to be initialized optionally to access BSC VTY */
201 port TELNETasp_PT BSCVTY;
202
Harald Welte70767382018-02-21 12:16:40 +0100203 timer g_Tguard;
204 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
205
206 var ConnHdlrPars g_pars;
207 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100208 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200209
210 /* PCU Interface of BTS */
211 port PCUIF_CODEC_PT PCU;
Vadim Yanitskiydd228c42021-07-04 02:37:30 +0200212
213 var RTP_Emulation_CT vc_RTPEM;
214 port RTPEM_CTRL_PT RTPEM_CTRL;
215 port RTPEM_DATA_PT RTPEM_DATA;
Harald Welte70767382018-02-21 12:16:40 +0100216}
217
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700218private function f_init_rsl(charstring id) runs on test_CT {
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700219 var bitstring trx_mask := '00000000'B;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200220 var bitstring rfind_mask := '00000000'B;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700221 var integer trx_count := 0;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200222 var integer rfind_count := 0;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700223 var RSLEm_Event ev;
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200224 var ASP_RSL_Unitdata rx_ud;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700225 timer T;
226
Harald Welte70767382018-02-21 12:16:40 +0100227 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
228 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
229
230 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
231 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
232 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
233
234 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
235 vc_RSL.start(RSL_Emulation.main(false));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700236
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700237 /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here.
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700238 * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700239 T.start(mp_ipa_up_timeout);
240 alt {
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700241 /* These events are sent by the RSL_Emulation_CT */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700242 [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev {
243 /* Make sure that all transceivers use unique stream ID */
244 if (trx_mask[enum2int(ev.sid)] == '1'B) {
245 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
246 log2str("Duplicate RSL stream ID (", ev.sid, ")"));
247 }
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700248
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700249 trx_mask[enum2int(ev.sid)] := '1'B;
250 trx_count := trx_count + 1;
251
252 log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected");
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200253 repeat;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700254 }
Pau Espin Pedrol9a053c02020-10-16 13:52:28 +0200255 /* This message (RF RESource INDication) is sent by the IUT itself */
256 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud {
257 if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) {
258 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
259 log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")"));
260 }
261 if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) {
262 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
263 log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")"));
264 }
265
266 rfind_mask[enum2int(rx_ud.streamId)] := '1'B;
267 rfind_count := rfind_count + 1;
268 log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received");
269 if (rfind_count < mp_transceiver_num) { repeat; }
270 }
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700271 /* osmo-bts may send us CCCH LOAD INDication or whatever else */
272 [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; }
273 [] T.timeout {
274 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
275 "Timeout waiting for RSL bring up");
276 }
277 }
Harald Welte70767382018-02-21 12:16:40 +0100278}
279
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700280friend type record length(1 .. 256) of TrxParsItem TrxPars;
281friend type record TrxParsItem {
282 GsmArfcn arfcn,
283 TrxTsPars ts
284};
285
286friend type record length(8) of TrxTsParsItem TrxTsPars;
287friend type record TrxTsParsItem {
288 PchanConfig config
289};
290
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700291friend type record FreqHopPars {
292 /* Whether frequency hopping is in use */
293 boolean enabled,
294 /* Mobile Allocation Index Offset / Hopping Sequence Number */
295 MaioHsn maio_hsn,
296 /* MA bitmap to be indicated in RR Immediate Assignment */
297 MobileAllocationLV ma_map,
298 /* The actual Mobile Allocation (ARFCN list) to be used */
299 L1ctlMA ma
300};
301
Harald Welte70767382018-02-21 12:16:40 +0100302type record ConnHdlrPars {
303 RslChannelNr chan_nr,
304 RSL_IE_ChannelMode chan_mode,
305 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100306 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200307 TestSpecUnion spec optional,
Eric Wild61edb7e2019-06-03 12:38:31 +0200308 RSL_IE_EncryptionInfo encr optional,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700309 BtsBand bts0_band optional,
310
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700311 /* Training Sequence Code */
312 GsmTsc tsc,
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700313 /* Frequency hopping parameters */
314 FreqHopPars fhp
315};
Harald Welte0472ab42018-03-12 15:02:26 +0100316
317/* Test-specific parameters */
Vadim Yanitskiy7368a102021-06-01 01:25:08 +0200318friend type union TestSpecUnion {
Harald Welte0472ab42018-03-12 15:02:26 +0100319 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100320}
321
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700322private template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100323 max_retrans := RACH_MAX_RETRANS_7,
324 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100325 cell_barr_access := false,
326 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100327 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100328};
329
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700330private template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100331 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200332 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100333 acs := '0'B,
334 neci := true,
335 rxlev_access_min := 0
336}
337
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700338private template (value) LocationAreaIdentification ts_LAI_default := {
Harald Weltef10153f2018-02-25 16:34:05 +0100339 mcc_mnc := '262F42'H,
340 lac := 42
341}
342
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700343private template (value) GPRSIndicator ts_GPRSIndicator_def := {
344 ra_colour := 0,
345 si13_pos := '0'B
346}
347
348private template (value) SI3RestOctets ts_SI3RestOctets_def
349modifies ts_SI3RestOctets := {
350 gprs_ind := {
351 presence := CSN1_H,
352 ind := ts_GPRSIndicator_def
353 }
354}
355
356private template (value) SI4RestOctets ts_SI4RestOctets_def
357modifies ts_SI4RestOctets := {
358 gprs_ind := {
Vadim Yanitskiyab5363f2020-05-05 00:30:22 +0700359 presence := CSN1_H,
360 ind := ts_GPRSIndicator_def
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700361 }
362}
363
Harald Welte7484fc42018-02-24 14:09:45 +0100364/* Default SYSTEM INFORMATION 3 */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700365private template (value) SystemInformation ts_SI3_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100366 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100367 payload := {
368 si3 := {
369 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100370 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100371 ctrl_chan_desc := {
372 msc_r99 := true,
373 att := true,
374 bs_ag_blks_res := 1,
375 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100376 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100377 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
378 spare := '00'B,
379 bs_pa_mfrms := 0, /* 2 multiframes */
380 t3212 := 1 /* 6 minutes */
381 },
Harald Welte82ccef72018-02-25 16:17:33 +0100382 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100383 dn_ind := false,
384 pwrc := false,
385 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100386 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100387 },
Harald Weltef10153f2018-02-25 16:34:05 +0100388 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100389 rach_control := ts_RachCtrl_default,
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +0200390 rest_octets := valueof(ts_SI3RestOctets_def)
Harald Welte7484fc42018-02-24 14:09:45 +0100391 }
392 }
393}
Harald Welte70767382018-02-21 12:16:40 +0100394
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700395private template (value) SystemInformation ts_SI2_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100396 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100397 payload := {
398 si2 := {
399 bcch_freq_list := '00000000000000000000000000000000'O,
400 ncc_permitted := '11111111'B,
401 rach_control := ts_RachCtrl_default
402 }
403 }
404}
405
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700406private template (value) SystemInformation ts_SI4_default := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100407 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100408 payload := {
409 si4 := {
410 lai := ts_LAI_default,
411 cell_sel_par := ts_CellSelPar_default,
412 rach_control := ts_RachCtrl_default,
413 cbch_chan_desc := omit,
414 cbch_mobile_alloc := omit,
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +0200415 rest_octets := valueof(ts_SI4RestOctets_def)
Harald Weltef10153f2018-02-25 16:34:05 +0100416 }
417 }
418}
419
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700420private function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
Harald Weltef10153f2018-02-25 16:34:05 +0100421runs on test_CT {
422 log("Setting ", rsl_si_type, ": ", si_enc);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +0700423 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
Harald Weltef10153f2018-02-25 16:34:05 +0100424}
425
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700426private function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
Harald Weltef10153f2018-02-25 16:34:05 +0100427runs on test_CT {
428 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
429 log("Setting ", rsl_si_type, ": ", si_dec);
430 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
431}
432
Harald Welte505cf9b2018-09-15 17:47:23 +0300433friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100434 map(self:BTSVTY, system:BTSVTY);
435 f_vty_set_prompts(BTSVTY);
436 f_vty_transceive(BTSVTY, "enable");
437}
438
Harald Welte505cf9b2018-09-15 17:47:23 +0300439friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200440 map(self:BSCVTY, system:BSCVTY);
441 f_vty_set_prompts(BSCVTY, "OsmoBSC");
442 f_vty_transceive(BSCVTY, "enable");
443}
444
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200445friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr {
446 map(self:BSCVTY, system:BSCVTY);
447 f_vty_set_prompts(BSCVTY, "OsmoBSC");
448 f_vty_transceive(BSCVTY, "enable");
449}
450
Harald Welte883340c2018-02-28 18:59:29 +0100451/* PCU socket may at any time receive a new INFO.ind */
Pau Espin Pedrol65d712e2021-06-25 13:55:38 +0200452friend altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
Harald Weltef26de0b2018-04-04 20:28:05 +0200453 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100454 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200455 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
456 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100457 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200458 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200459 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100460 }
461}
462
Harald Weltef26de0b2018-04-04 20:28:05 +0200463private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
464 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100465 timer T := 2.0;
466 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100467 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200468 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100469 return;
470 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200471 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100472
473 T.start;
474 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200475 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100476 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200477 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100478 }
479 }
480}
481
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700482private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
483 out integer trxc_conn_id) {
484 var Result res;
485
486 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
487 "", -1, -1, { udp := {} }, {});
488 if (not ispresent(res.connId)) {
489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
490 "Could not connect to the control (TRXC) interface " &
491 "of FakeTRX, check your configuration");
492 }
493 trxc_conn_id := res.connId;
494}
495
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +0100496/* global init function (without PCUIF connection) */
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700497friend function f_init(uint8_t trx_nr := 0)
498runs on test_CT
499{
500 var TrxParsItem trx_pars := mp_trx_pars[trx_nr];
Harald Welte10474062019-05-30 16:48:17 +0200501 var charstring id := testcasename();
Harald Welte629cc6b2018-03-11 17:19:05 +0100502
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700503 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653.
504 * TODO: also generate this list dynamically from module parameters. */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700505 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200506 g_AllChanTypes := {
507 /* TS 1..4: TCH/F */
508 valueof(ts_RslChanNr_Bm(1)),
509 /* TS 5: TCH/H */
510 valueof(ts_RslChanNr_Lm(5,1)),
511 /* TS 0: SDCCH/4 */
512 valueof(ts_RslChanNr_SDCCH4(0,2)),
513 /* TS 6: SDCCH/8 */
514 valueof(ts_RslChanNr_SDCCH8(6,4))
515 };
516 } else {
517 g_AllChanTypes := {
518 /* TS 1..4: TCH/F */
519 valueof(ts_RslChanNr_Bm(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 }
Vadim Yanitskiy7e707092020-11-16 17:08:03 +0700526
527 g_AllChannels := { };
528
529 /* Generate list of all logical channels from module parameters */
530 for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) {
531 select (trx_pars.ts[tn].config) {
532 case (GSM_PCHAN_CCCH_SDCCH4) {
533 g_AllChannels := g_AllChannels &
534 { valueof(ts_RslChanNr_SDCCH4(tn, 0)),
535 valueof(ts_RslChanNr_SDCCH4(tn, 1)),
536 valueof(ts_RslChanNr_SDCCH4(tn, 2)),
537 valueof(ts_RslChanNr_SDCCH4(tn, 3)) };
538 }
539 case (GSM_PCHAN_SDCCH8) {
540 g_AllChannels := g_AllChannels &
541 { valueof(ts_RslChanNr_SDCCH8(tn, 0)),
542 valueof(ts_RslChanNr_SDCCH8(tn, 1)),
543 valueof(ts_RslChanNr_SDCCH8(tn, 2)),
544 valueof(ts_RslChanNr_SDCCH8(tn, 3)),
545 valueof(ts_RslChanNr_SDCCH8(tn, 4)),
546 valueof(ts_RslChanNr_SDCCH8(tn, 5)),
547 valueof(ts_RslChanNr_SDCCH8(tn, 6)),
548 valueof(ts_RslChanNr_SDCCH8(tn, 7)) };
549 }
550 case (GSM_PCHAN_TCHH_TCHF_PDCH) {
551 g_AllChannels := g_AllChannels &
552 { valueof(ts_RslChanNr_Lm(tn, 0)),
553 valueof(ts_RslChanNr_Lm(tn, 1)),
554 valueof(ts_RslChanNr_Bm(tn)) };
555 }
556 case (GSM_PCHAN_TCHH) {
557 g_AllChannels := g_AllChannels &
558 { valueof(ts_RslChanNr_Lm(tn, 0)),
559 valueof(ts_RslChanNr_Lm(tn, 1)) };
560 }
561 case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) {
562 g_AllChannels := g_AllChannels &
563 { valueof(ts_RslChanNr_Bm(tn)) };
564 }
565 }
566 }
567
Harald Welte70767382018-02-21 12:16:40 +0100568 f_init_rsl(id);
Harald Welte2d142592018-02-25 13:19:44 +0100569 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100570 f_init_vty(id);
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +0100571 f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100572
573 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100574 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
575 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
576 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
577 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100578
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700579 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100580 var TrxcMessage ret;
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700581
582 /* Init TRXC interface to FakeTRX */
583 map(self:BTS_TRXC, system:BTS_TRXC);
584 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
585
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700586 /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600587 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(2*256));
588 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(-60));
Vadim Yanitskiyde535e02019-07-26 16:29:27 +0700589 /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600590 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(60));
Harald Welte84271622018-03-10 17:21:03 +0100591 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200592
593 /* Wait some extra time to make sure the BTS emits a stable carrier.
594 * (this is only relevant when running the tests with a physical BTS.) */
595 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100596}
597
Harald Welte68e495b2018-02-25 00:05:57 +0100598/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700599friend function f_init_l1ctl() runs on test_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100600 map(self:L1CTL, system:L1CTL);
601 f_connect_reset(L1CTL);
602}
603
Vadim Yanitskiy73878132021-05-05 02:22:45 +0200604friend type function void_fn(charstring id) runs on ConnHdlr;
Harald Welte70767382018-02-21 12:16:40 +0100605
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700606private type record length(8) of FreqHopGroups FreqHopConfig;
607
608private type record of FreqHopGroup FreqHopGroups;
609private type record FreqHopGroup {
610 uint6_t hsn,
611 FreqHopGroupItems trx_maio
612};
613
614private type record of FreqHopGroupItem FreqHopGroupItems;
615private type record FreqHopGroupItem {
616 uint8_t trx_nr,
617 uint6_t maio
618};
619
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700620friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn,
621 uint8_t trx_nr := 0)
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700622{
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700623 var FreqHopGroups groups := mp_fh_config[tn];
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700624 var integer i, j;
625
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700626 fhp.enabled := false;
627
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700628 for (i := 0; i < lengthof(groups); i := i + 1) {
629 var FreqHopGroup g := groups[i];
630 for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
631 var FreqHopGroupItem gi := g.trx_maio[j];
632 if (gi.trx_nr == trx_nr) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700633 fhp.maio_hsn.maio := gi.maio;
634 fhp.maio_hsn.hsn := g.hsn;
635 fhp.enabled := true;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700636 break;
637 }
638 }
639
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700640 if (fhp.enabled) {
Vadim Yanitskiy4fa74252020-08-03 15:51:58 +0700641 /* Prepare the Mobile Allocation bitmask (length & padding) */
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700642 fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */
643 fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B);
644 fhp.ma := { }; /* to be composed below */
Vadim Yanitskiy4fa74252020-08-03 15:51:58 +0700645
646 /* Compose the actual Mobile Allocation and the bitmask */
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700647 for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
648 var FreqHopGroupItem gi := g.trx_maio[j];
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700649 var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn;
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700650 fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) };
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700651 fhp.ma_map.ma[gi.trx_nr] := '1'B;
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700652 }
653
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700654 log("Freq. hopping parameters: ", fhp);
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700655 break; /* We're done */
656 }
657 }
658}
659
Harald Welte70767382018-02-21 12:16:40 +0100660/* create a new test component */
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700661friend function f_start_handler(void_fn fn, ConnHdlrPars pars,
662 boolean pcu_comp := false,
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200663 boolean trxc_comp := false,
664 boolean l1ctl := true)
Harald Welte70767382018-02-21 12:16:40 +0100665runs on test_CT return ConnHdlr {
666 var charstring id := testcasename();
667 var ConnHdlr vc_conn;
668
669 vc_conn := ConnHdlr.create(id);
670 /* connect to RSL Emulation main component */
671 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
672 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700673
674 /* The ConnHdlr component may want to talk to some ports directly,
675 * so we disconnect it from the test_CT and connect it to the component.
676 * This obviously only works for one component, i.e. no concurrency. */
Harald Weltef26de0b2018-04-04 20:28:05 +0200677 if (pcu_comp) {
Harald Weltef26de0b2018-04-04 20:28:05 +0200678 unmap(self:PCU, system:PCU);
679 map(vc_conn:PCU, system:PCU);
680 }
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700681 if (trxc_comp) {
682 unmap(self:BTS_TRXC, system:BTS_TRXC);
683 map(vc_conn:BTS_TRXC, system:BTS_TRXC);
684 }
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200685 if (l1ctl) {
686 map(vc_conn:L1CTL, system:L1CTL);
687 }
Harald Welte70767382018-02-21 12:16:40 +0100688
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700689 /* Obtain frequency hopping parameters for a given timeslot */
690 if (mp_freq_hop_enabled and mp_transceiver_num > 1) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700691 f_resolve_fh_params(pars.fhp, pars.chan_nr.tn);
Vadim Yanitskiya9894282020-07-14 01:56:15 +0700692 }
693
Harald Welte70767382018-02-21 12:16:40 +0100694 vc_conn.start(f_handler_init(fn, id, pars));
695 return vc_conn;
696}
697
Harald Welte70767382018-02-21 12:16:40 +0100698private altstep as_Tguard() runs on ConnHdlr {
699 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200700 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100701 }
702}
703
Harald Welte990a3612019-05-27 14:02:13 +0200704friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +0700705 var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn));
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700706 f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100707}
708
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700709private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100710 var TrxcMessage ret;
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600711 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi));
Harald Welte70767382018-02-21 12:16:40 +0100712}
713
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700714private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100715 var TrxcMessage ret;
Vadim Yanitskiy418066a2021-10-03 14:04:17 +0600716 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256));
Harald Welte70767382018-02-21 12:16:40 +0100717}
718
719/* first function started in ConnHdlr component */
720private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
721runs on ConnHdlr {
722 g_pars := pars;
723 g_chan_nr := pars.chan_nr;
724
Vadim Yanitskiy918e2b22021-05-28 04:57:50 +0200725 if (L1CTL.checkstate("Mapped")) {
726 f_connect_reset(L1CTL);
727 }
Harald Welte70767382018-02-21 12:16:40 +0100728
Harald Welted48c0c72019-06-05 10:01:15 +0200729 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700730 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100731 }
Harald Welte70767382018-02-21 12:16:40 +0100732
733 g_Tguard.start(pars.t_guard);
734 activate(as_Tguard());
735
736 f_rslem_register(0, pars.chan_nr);
737
738 /* call the user-supplied test case function */
739 fn.apply(id);
740}
741
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +0700742private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx,
743 charstring id, boolean ignore_other := false)
Harald Welteb1726c92018-03-30 11:56:38 +0200744runs on ConnHdlr return RSL_Message {
745 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100746 timer T := 3.0;
747 RSL.send(tx);
748 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100749 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200750 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100751 T.stop;
752 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100753 }
Harald Welte1eba3742018-02-25 12:48:14 +0100754 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200755 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100756 }
Harald Welte21240e62018-03-11 21:43:35 +0100757 [not ignore_other] as_l1_sacch();
758 [not ignore_other] as_meas_res();
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +0700759 [not ignore_other] as_l1_dcch_loop();
Vadim Yanitskiydc008112020-10-19 14:42:04 +0700760 [not ignore_other] as_l1_tch_loop();
Harald Welte21240e62018-03-11 21:43:35 +0100761 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200762 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100763 }
Harald Welte21240e62018-03-11 21:43:35 +0100764 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100765 }
Harald Welteb1726c92018-03-30 11:56:38 +0200766 return rx;
767}
768
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700769friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx,
770 charstring id, boolean ignore_other := false)
Harald Welteb1726c92018-03-30 11:56:38 +0200771runs on ConnHdlr {
772 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100773}
774
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700775friend function f_rsl_chan_act(RSL_IE_ChannelMode mode,
776 boolean encr_enable := false,
777 RSL_IE_List more_ies := {},
778 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA)
779runs on ConnHdlr {
Harald Welte8b01c792019-05-19 22:51:25 +0200780 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200781 if (encr_enable) {
782 /* append encryption related IEs, if requested */
783 var RSL_IE_EncryptionInfo encr_info;
784 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
785 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
786encr_info})) };
787 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200788 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200789 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100790}
791
Vadim Yanitskiyb2a90db2020-07-04 20:33:47 +0700792friend function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100793 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 +0100794 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100795}
796
Harald Welte2f2b2b72019-05-31 22:24:57 +0200797friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Vadim Yanitskiye6c17552021-06-01 01:20:55 +0200798 template RSL_IE_ChannelMode chan_mode,
799 template (omit) TestSpecUnion spec := omit,
800 float t_guard := 20.0) := {
Harald Welte70767382018-02-21 12:16:40 +0100801 chan_nr := valueof(chan_nr),
802 chan_mode := valueof(chan_mode),
803 t_guard := t_guard,
804 l1_pars := {
805 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100806 toa256_enabled := false,
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +0100807 meas_valid := true,
Harald Welte70767382018-02-21 12:16:40 +0100808 meas_ul := {
809 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200810 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100811 rxqual := 0
812 },
813 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200814 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100815 rxqual := 0
816 }
817 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200818 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100819 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200820 ms_power_level := mp_ms_power_level_exp,
Philipp Maier149c3922020-10-22 17:29:36 +0200821 ms_actual_ta := mp_ms_actual_ta_exp,
822 facch_enabled := false
Harald Welte0472ab42018-03-12 15:02:26 +0100823 },
Vadim Yanitskiye6c17552021-06-01 01:20:55 +0200824 spec := spec,
Eric Wild61edb7e2019-06-03 12:38:31 +0200825 encr := omit,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700826 bts0_band := omit,
Vadim Yanitskiy3191d732020-11-15 20:45:01 +0700827 tsc := mp_tsc_def,
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700828 fhp := {
829 enabled := false,
830 maio_hsn := ts_HsnMaio(0, 0),
831 ma_map := c_MA_null,
Vadim Yanitskiy2b991b62020-11-14 21:40:41 +0700832 ma := { }
Vadim Yanitskiyca813922020-09-12 19:08:31 +0700833 }
Harald Welte70767382018-02-21 12:16:40 +0100834}
835
Harald Welte93640c62018-02-25 16:59:33 +0100836/***********************************************************************
837 * Channel Activation / Deactivation
838 ***********************************************************************/
839
Harald Welte70767382018-02-21 12:16:40 +0100840/* Stress test: Do 500 channel activations/deactivations in rapid succession */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700841private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100842 for (var integer i := 0; i < 500; i := i+1) {
843 f_rsl_chan_act(g_pars.chan_mode);
844 f_rsl_chan_deact();
845 }
846 setverdict(pass);
847}
848testcase TC_chan_act_stress() runs on test_CT {
849 var ConnHdlr vc_conn;
850 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +0200851 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100852 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
853 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200854 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100855}
856
857/* Test if re-activation of an already active channel fails as expected */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700858private function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100859 f_rsl_chan_act(g_pars.chan_mode);
860 /* attempt to activate the same lchan again -> expect reject */
861 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
862 alt {
863 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200864 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100865 }
866 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
867 setverdict(pass);
868 }
869 }
870 f_rsl_chan_deact();
871}
872testcase TC_chan_act_react() runs on test_CT {
873 var ConnHdlr vc_conn;
874 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100875 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100876 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
877 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200878 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100879}
880
881/* Attempt to de-activate a channel that's not active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700882private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100883 timer T := 3.0;
884 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
885 T.start;
886 alt {
887 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
888 setverdict(pass);
889 }
890 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200891 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100892 }
893 }
894}
895testcase TC_chan_deact_not_active() runs on test_CT {
896 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100897 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100898 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
899 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200900 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100901}
902
903/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700904private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100905 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
906 alt {
907 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200908 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100909 }
910 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
911 setverdict(pass);
912 }
913 }
914}
915private type record WrongChanNrCase {
916 RslChannelNr chan_nr,
917 charstring description
918}
919private type record of WrongChanNrCase WrongChanNrCases;
920private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
921 chan_nr := chan_nr,
922 description := desc
923}
924
925testcase TC_chan_act_wrong_nr() runs on test_CT {
926 var ConnHdlr vc_conn;
927 var ConnHdlrPars pars;
928
Harald Welte294b0a22018-03-10 23:26:48 +0100929 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100930
931 var WrongChanNrCases wrong := {
932 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
933 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
934 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
935 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
936 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
937 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
938 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
939 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
940 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
941 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
942 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
943 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
944 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
945 };
946
947 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
948 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
949 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
950 vc_conn.done;
951 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200952 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100953}
954
Harald Weltee613f962018-04-18 22:38:16 +0200955/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200956friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +0200957 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +0200958 f_init();
Harald Weltee613f962018-04-18 22:38:16 +0200959
960 /* test on each of the channels we have */
961 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
962 pars.chan_nr := valueof(g_AllChanTypes[i]);
963
964 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
965 vc_conn := f_start_handler(fn, pars);
966 vc_conn.done;
967 }
968
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200969 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200970}
971
Harald Welte93640c62018-02-25 16:59:33 +0100972/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100973 * SACCH handling
974 ***********************************************************************/
975
976private function f_exp_sacch(boolean exp) runs on ConnHdlr {
977 timer T_sacch := 3.0;
978 T_sacch.start;
979 alt {
980 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200981 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100982 }
983 [not exp] T_sacch.timeout {
984 setverdict(pass);
985 }
986 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
987 setverdict(pass);
988 }
989 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200990 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100991 }
992 [] L1CTL.receive { repeat; }
993 [] RSL.receive { repeat; }
994 }
995}
996
997/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
998private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
999 f_l1_tune(L1CTL);
1000 RSL.clear;
1001
1002 /* activate the logical channel */
1003 f_est_dchan();
1004 L1CTL.clear;
1005
1006 /* check that SACCH actually are received as expected */
1007 f_exp_sacch(true);
1008
1009 /* deactivate SACCH on the logical channel */
1010 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
1011 f_sleep(1.0);
1012 L1CTL.clear;
1013
1014 /* check that no SACCH are received anymore */
1015 f_exp_sacch(false);
1016
1017 /* release the channel */
1018 f_rsl_chan_deact();
1019 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1020}
1021testcase TC_deact_sacch() runs on test_CT {
1022 var ConnHdlr vc_conn;
1023 var ConnHdlrPars pars;
1024 f_init();
1025 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1026 //for (var integer i := 0; i < 1; i := i+1) {
1027 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1028 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1029 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
1030 vc_conn.done;
1031 }
1032 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001033 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +01001034}
1035
Harald Welte55700662018-03-12 13:15:43 +01001036/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +01001037private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
1038 var L1ctlDlMessage dl;
1039 /* check that the specified SI5 value is actually sent */
1040 timer T_sacch := 3.0;
1041 L1CTL.clear;
1042 T_sacch.start;
1043 alt {
1044 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
1045 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
1046 if (match(l3, l3_exp)) {
1047 setverdict(pass);
1048 } else {
1049 repeat;
1050 }
1051 }
1052 [] L1CTL.receive { repeat; }
1053 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001054 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +01001055 }
1056 }
1057}
1058
Harald Welte55700662018-03-12 13:15:43 +01001059/* verify that given SACCH payload is not present */
1060private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
1061 var L1ctlDlMessage dl;
1062 /* check that the specified SI5 value is actually sent */
1063 timer T_sacch := 3.0;
1064 L1CTL.clear;
1065 T_sacch.start;
1066 alt {
1067 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
1068 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
1069 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001070 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +01001071 } else {
1072 repeat;
1073 }
1074 }
1075 [] L1CTL.receive { repeat; }
1076 [] T_sacch.timeout {
1077 setverdict(pass);
1078 }
1079 }
1080}
1081
Harald Welte629cc6b2018-03-11 17:19:05 +01001082/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +01001083private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
1084 /* Set a known default SACCH filling for SI5 */
1085 var octetstring si5 := f_rnd_octstring(19);
1086 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1087
1088 f_l1_tune(L1CTL);
1089 RSL.clear;
1090
1091 /* activate the logical channel */
1092 f_est_dchan();
1093
1094 /* check that the specified SI5 value is actually sent */
1095 f_sacch_present(si5);
1096
1097 /* release the channel */
1098 RSL.clear;
1099 f_rsl_chan_deact();
1100 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1101}
1102testcase TC_sacch_filling() runs on test_CT {
1103 var ConnHdlr vc_conn;
1104 var ConnHdlrPars pars;
1105 f_init();
1106 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1107 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1108 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1109 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
1110 vc_conn.done;
1111 }
1112 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001113 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +01001114}
1115
Harald Welte629cc6b2018-03-11 17:19:05 +01001116/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +01001117private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
1118 /* Set a known default SACCH filling for SI5 */
1119 var octetstring si5 := f_rnd_octstring(19);
1120 var octetstring si5_diff := f_rnd_octstring(19);
1121 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1122
1123 f_l1_tune(L1CTL);
1124 RSL.clear;
1125
1126 log("Activating channel, expecting standard SI5");
1127 /* activate the logical channel */
1128 f_est_dchan();
1129 /* check that the specified SI5 value is actually sent */
1130 f_sacch_present(si5);
1131
1132 /* set channel-specific different SI5 */
1133 log("Setting channel specific SACCH INFO, expecting it");
1134 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
1135 /* check that the specified lchan-specific value is now used */
1136 f_sacch_present(si5_diff);
1137
1138 /* deactivate the channel and re-activate it, this should result in default SI5 */
1139 log("De-activating and re-activating channel, expecting standard SI5");
1140 f_rsl_chan_deact();
1141 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
1142 /* Verify that the TRX-wide default SACCH filling is present again */
1143 f_sacch_present(si5);
1144
1145 /* release the channel */
1146 RSL.clear;
1147 f_rsl_chan_deact();
1148 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1149}
1150testcase TC_sacch_info_mod() runs on test_CT {
1151 var ConnHdlr vc_conn;
1152 var ConnHdlrPars pars;
1153 f_init();
1154 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1155 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1156 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1157 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
1158 vc_conn.done;
1159 }
1160 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001161 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +01001162}
1163
Harald Welte075d84c2018-03-12 13:07:24 +01001164/* Test SACCH scheduling of multiple different SI message types */
1165private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
1166 var octetstring si5 := f_rnd_octstring(19);
1167 var octetstring si5bis := f_rnd_octstring(19);
1168 var octetstring si5ter := f_rnd_octstring(19);
1169 var octetstring si6 := f_rnd_octstring(19);
1170
1171 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1172 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
1173 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
1174 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1175
1176 f_l1_tune(L1CTL);
1177 RSL.clear;
1178
1179 /* activate the logical channel */
1180 f_est_dchan();
1181 L1CTL.clear;
1182
1183 /* check that SACCH actually are received as expected */
1184 f_sacch_present(si5);
1185 f_sacch_present(si5bis);
1186 f_sacch_present(si5ter);
1187 f_sacch_present(si6);
1188
1189 /* release the channel */
1190 f_rsl_chan_deact();
1191 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1192}
1193testcase TC_sacch_multi() runs on test_CT {
1194 var ConnHdlr vc_conn;
1195 var ConnHdlrPars pars;
1196 f_init();
1197 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1198 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1199 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1200 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
1201 vc_conn.done;
1202 }
1203 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001204 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +01001205}
1206
Harald Welte55700662018-03-12 13:15:43 +01001207/* Test if SACH information is modified as expected */
1208private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
1209 var octetstring si5 := f_rnd_octstring(19);
1210 var octetstring si6 := f_rnd_octstring(19);
1211
1212 /* First, configure both SI5 and SI6 to be transmitted */
1213 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1214 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1215
1216 f_l1_tune(L1CTL);
1217 RSL.clear;
1218
1219 /* activate the logical channel */
1220 f_est_dchan();
1221 L1CTL.clear;
1222
1223 /* check that SACCH actually are received as expected */
1224 f_sacch_present(si5);
1225 f_sacch_present(si6);
1226
1227 /* disable SI6 */
1228 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1229
1230 /* check that SI5 is still transmitted */
1231 f_sacch_present(si5);
1232 /* check if SI6 is now gone */
1233 f_sacch_missing(si6);
1234
1235 /* release the channel */
1236 f_rsl_chan_deact();
1237 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1238}
1239testcase TC_sacch_multi_chg() runs on test_CT {
1240 var ConnHdlr vc_conn;
1241 var ConnHdlrPars pars;
1242 f_init();
1243 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1244 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1245 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1246 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1247 vc_conn.done;
1248 }
1249 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001250 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001251}
1252
Harald Weltec8d363c2019-05-19 20:36:48 +02001253/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1254private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1255 var octetstring si5 := f_rnd_octstring(19);
1256 var octetstring si6 := f_rnd_octstring(19);
1257 var octetstring si5_specific := f_rnd_octstring(19);
1258 var octetstring si6_specific := f_rnd_octstring(19);
1259
1260 /* First, configure both SI5 and SI6 to be transmitted */
1261 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1262 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1263
1264 f_l1_tune(L1CTL);
1265 RSL.clear;
1266
1267 /* activate channel with different SACCH filling */
1268 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1269 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1270 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1271 }));
1272 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1273 RSL_IE_Body:{sacch_info := sacch_info})) };
1274 f_est_dchan(more_ies := addl_ies);
1275
1276 /* check that SACCH actually are received as expected */
1277 f_sacch_present(si5_specific);
1278 f_sacch_present(si6_specific);
1279
1280 /* release the channel */
1281 f_rsl_chan_deact();
1282 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1283}
1284testcase TC_sacch_chan_act() runs on test_CT {
1285 var ConnHdlr vc_conn;
1286 var ConnHdlrPars pars;
1287 f_init();
1288
1289 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1290 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1291 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1292 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1293 vc_conn.done;
1294 }
1295 /* TODO: do the above in parallel, rather than sequentially? */
1296 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1297}
1298
Harald Welte8b01c792019-05-19 22:51:25 +02001299/* verify that SACCH DL transmission is started only if MS power IE present
1300 * see section 4.1.3 of 3GPP TS 48.058 */
1301private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1302 var octetstring si5 := f_rnd_octstring(19);
Neels Hofmeyrdd597412020-11-03 20:35:00 +00001303 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
Harald Welte8b01c792019-05-19 22:51:25 +02001304
1305 f_l1_tune(L1CTL);
1306 RSL.clear;
1307
1308 /* Step 1: Activate ASYNC HO channel without MS power IE */
1309
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001310 var integer ho_ref := oct2int(f_rnd_octstring(1));
1311 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1312 RSL_IE_Body:{ handover_ref := ho_ref }));
1313 var RSL_IE_List addl_ies := {
1314 ho_ref_ie
1315 };
1316
Harald Welte8b01c792019-05-19 22:51:25 +02001317 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001318 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 +02001319 /* don't perform immediate assignment here, as we're testing non-IA case */
1320 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001321 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001322
1323 /* Verify that no DL SACCH is being received */
1324 f_sacch_missing(?);
1325
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001326 /* Send handover Access Burst and expect SACCH to start */
1327 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1328
1329 f_sacch_present(si5);
1330
Harald Welte8b01c792019-05-19 22:51:25 +02001331 f_rsl_chan_deact();
1332 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1333
1334
1335 /* Step 2: Activate ASYNC HO channel with MS power IE */
1336
1337 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001338 addl_ies := {
1339 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001340 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1341 };
1342 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1343 /* don't perform immediate assignment here, as we're testing non-IA case */
1344 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001345 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001346
1347 /* Verify that DL SACCH is being received */
1348 f_sacch_present(si5);
1349
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001350 /* Send handover Access Burst and expect SACCH to remain present */
1351 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1352
1353 f_sacch_present(si5);
1354
Harald Welte8b01c792019-05-19 22:51:25 +02001355 f_rsl_chan_deact();
1356 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1357}
1358testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1359 var ConnHdlr vc_conn;
1360 var ConnHdlrPars pars;
1361 f_init();
1362
1363 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1364 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1365 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1366 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1367 vc_conn.done;
1368 }
1369 /* TODO: do the above in parallel, rather than sequentially? */
1370 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1371}
1372
1373/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1374 * see section 4.1.4 of 3GPP TS 48.058 */
1375private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1376 var octetstring si5 := f_rnd_octstring(19);
Neels Hofmeyrdd597412020-11-03 20:35:00 +00001377 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1378
Harald Welte8b01c792019-05-19 22:51:25 +02001379 var RSL_IE_List addl_ies;
1380
1381 f_l1_tune(L1CTL);
1382 RSL.clear;
1383
1384 /* Step 1: Activate SYNC HO channel without MS power IE */
1385
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001386 var integer ho_ref := oct2int(f_rnd_octstring(1));
1387 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1388 RSL_IE_Body:{ handover_ref := ho_ref }));
1389 addl_ies := {
1390 ho_ref_ie
1391 };
1392
Harald Welte8b01c792019-05-19 22:51:25 +02001393 /* Activate channel on BTS side */
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001394 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 +02001395 /* don't perform immediate assignment here, as we're testing non-IA case */
1396 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001397 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001398
1399 /* Verify that no DL SACCH is being received */
1400 f_sacch_missing(?);
1401
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001402 /* Send handover Access Burst and expect SACCH to start */
1403 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1404
1405 f_sacch_present(si5);
1406
Harald Welte8b01c792019-05-19 22:51:25 +02001407 f_rsl_chan_deact();
1408 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1409
1410
1411 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1412
1413 /* Activate channel on BTS side */
1414 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001415 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001416 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1417 };
1418 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1419 /* don't perform immediate assignment here, as we're testing non-IA case */
1420 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001421 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001422
Neels Hofmeyrd55a3ac2020-11-09 00:54:34 +00001423 /* Verify that DL SACCH is being received, because MS Power IE was sent */
1424 f_sacch_present(si5);
Harald Welte8b01c792019-05-19 22:51:25 +02001425
Neels Hofmeyrd55a3ac2020-11-09 00:54:34 +00001426 /* Send handover Access Burst and expect SACCH to remain present */
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001427 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1428
1429 f_sacch_present(si5);
1430
Harald Welte8b01c792019-05-19 22:51:25 +02001431 f_rsl_chan_deact();
1432 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1433
1434
1435 /* Step 2b: Activate SYNC HO channel with TA IE */
1436
1437 /* Activate channel on BTS side */
1438 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001439 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001440 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1441 };
1442 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1443 /* don't perform immediate assignment here, as we're testing non-IA case */
1444 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001445 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001446
1447 /* Verify that no DL SACCH is being received */
1448 f_sacch_missing(?);
1449
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001450 /* Send handover Access Burst and expect SACCH to start */
1451 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1452
1453 f_sacch_present(si5);
1454
Harald Welte8b01c792019-05-19 22:51:25 +02001455 f_rsl_chan_deact();
1456 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1457
1458
1459 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1460
1461 /* Activate channel on BTS side */
1462 addl_ies := {
Neels Hofmeyrd34681b2020-11-03 20:35:00 +00001463 ho_ref_ie,
Harald Welte8b01c792019-05-19 22:51:25 +02001464 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1465 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1466 };
1467 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1468 /* don't perform immediate assignment here, as we're testing non-IA case */
1469 /* enable dedicated mode */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001470 f_l1ctl_est_dchan(L1CTL, g_pars);
Harald Welte8b01c792019-05-19 22:51:25 +02001471
1472 /* Verify that DL SACCH is being received */
1473 f_sacch_present(si5);
1474
Neels Hofmeyr76d1d1a2020-11-09 00:03:33 +00001475 /* Send handover Access Burst and expect SACCH to remain present */
1476 f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1477
1478 f_sacch_present(si5);
1479
Harald Welte8b01c792019-05-19 22:51:25 +02001480 f_rsl_chan_deact();
1481 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1482}
1483testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1484 var ConnHdlr vc_conn;
1485 var ConnHdlrPars pars;
1486 f_init();
1487
1488 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1489 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1490 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1491 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1492 vc_conn.done;
1493 }
1494 /* TODO: do the above in parallel, rather than sequentially? */
1495 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1496}
Harald Welte629cc6b2018-03-11 17:19:05 +01001497
1498
1499/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001500 * RACH Handling
1501 ***********************************************************************/
1502
Harald Welte8c24c2b2018-02-26 08:31:31 +01001503/* Send 1000 RACH requests and check their RA+FN on the RSL side */
Philipp Maier16ade782020-07-08 21:36:00 +02001504private function f_TC_rach_content(boolean emerg) runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001505 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001506 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001507 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001508
Harald Welte8c24c2b2018-02-26 08:31:31 +01001509 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001510 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001511 for (var integer i := 0; i < 1000; i := i+1) {
Neels Hofmeyrc897cfb2020-11-09 00:06:01 +00001512 var OCT1 ra;
Philipp Maier16ade782020-07-08 21:36:00 +02001513 if (emerg == true) {
1514 ra := f_rnd_ra_emerg();
1515 } else {
1516 ra := f_rnd_ra_cs();
1517 }
Harald Welte8c24c2b2018-02-26 08:31:31 +01001518 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1519 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001520 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001521 }
1522 fn_last := fn;
1523
1524 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001525 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001526 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001527 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001528 T.stop;
1529 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001530 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001531 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001532 }
1533 [] RSL_CCHAN.receive { repeat; }
1534 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001535 test_failed := true;
1536 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001537 }
1538 }
1539 }
Maxba06feb2019-03-05 10:52:46 +01001540 if (test_failed) {
1541 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001542 }
Maxba06feb2019-03-05 10:52:46 +01001543 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001544 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001545}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001546
Philipp Maier16ade782020-07-08 21:36:00 +02001547/* Normal variant */
1548testcase TC_rach_content() runs on test_CT {
1549 f_TC_rach_content(emerg := false);
1550}
1551
1552/* Emergency call variant */
1553testcase TC_rach_content_emerg() runs on test_CT {
1554 f_TC_rach_content(emerg := true);
1555}
1556
Harald Welte8c24c2b2018-02-26 08:31:31 +01001557/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1558testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001559 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001560 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001561 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001562 f_l1_tune(L1CTL);
1563
1564 var GsmFrameNumber fn_last := 0;
1565 for (var integer i := 0; i < 1000; i := i+1) {
1566 var OCT1 ra := f_rnd_ra_cs();
1567 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1568 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001569 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001570 }
1571 fn_last := fn;
1572 }
1573 var integer rsl_chrqd := 0;
1574 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001575 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001576 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001577 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001578 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001579 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001580 repeat;
1581 }
1582 [] RSL_CCHAN.receive { repeat; }
1583 [] T.timeout { }
1584 }
1585 if (rsl_chrqd == 1000) {
1586 setverdict(pass);
1587 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001588 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001589 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001590 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001591}
1592
Harald Welte3453ab42019-05-24 21:19:58 +02001593private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1594 var charstring bts_str := "bts " & int2str(bts_nr);
1595 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1596}
1597
1598/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1599private template integer tr_rach_slots_per_interval := (90 .. 130);
1600
1601/* Expect 0 RACH load on an idle BTS that has just started up */
1602testcase TC_rach_load_idle_thresh0() runs on test_CT {
1603 var ASP_RSL_Unitdata rx_ud;
1604
1605 f_init_vty_bsc();
1606 /* send load indications even at 0% load */
1607 f_vty_load_ind_thresh(0);
1608 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1609 f_sleep(2.0);
1610
1611 f_init();
1612
Harald Weltee37f9a52020-10-11 20:45:23 +02001613 /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
1614 alt {
1615 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
1616 [] RSL_CCHAN.receive { repeat }
1617 }
1618
Harald Welte3453ab42019-05-24 21:19:58 +02001619 timer T := 5.0;
1620 T.start;
1621 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001622 [] 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 +02001623 setverdict(pass);
1624 repeat;
1625 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001626 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001627 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1628 repeat;
1629 }
1630 [] RSL_CCHAN.receive {
1631 repeat;
1632 }
1633 [] T.timeout { }
1634 }
1635
1636 f_vty_load_ind_thresh(10);
1637 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1638}
1639
1640/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1641testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1642 var ASP_RSL_Unitdata rx_ud;
1643
1644 f_init_vty_bsc();
1645 f_init();
1646
1647 timer T := 5.0;
1648 T.start;
1649 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001650 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001651 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1652 repeat;
1653 }
1654 [] RSL_CCHAN.receive {
1655 repeat;
1656 }
1657 [] T.timeout {
1658 setverdict(pass);
1659 }
1660 }
1661
1662 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1663}
1664
1665/* Expect 0 RACH load on an idle BTS that has just started up */
1666testcase TC_rach_load_count() runs on test_CT {
1667 var ASP_RSL_Unitdata rx_ud;
1668 var integer load_access_count := 0;
1669
1670 f_init_vty_bsc();
1671 /* send load indications even at 0% load */
1672 f_vty_load_ind_thresh(0);
1673 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1674 f_sleep(2.0);
1675 f_init();
1676
1677 f_init_l1ctl();
1678 f_sleep(1.0);
1679 f_l1_tune(L1CTL);
1680
Harald Welte52ae1682020-10-11 20:45:55 +02001681 /* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
1682 alt {
1683 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
1684 [] RSL_CCHAN.receive { repeat }
1685 }
1686
Harald Welte3453ab42019-05-24 21:19:58 +02001687 var GsmFrameNumber fn_last := 0;
1688 for (var integer i := 0; i < 1000; i := i+1) {
1689 var OCT1 ra := f_rnd_ra_cs();
1690 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1691 if (fn == fn_last) {
1692 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1693 }
1694 fn_last := fn;
1695 }
1696
1697 timer T := 5.0;
1698 T.start;
1699 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001700 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
Harald Welte3453ab42019-05-24 21:19:58 +02001701 -> value rx_ud {
1702 var RSL_IE_Body ie;
1703 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1704 load_access_count := load_access_count + ie.rach_load.access_count;
1705 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1706 setverdict(fail, "Access count cannot be < Busy count");
1707 }
1708 repeat;
1709 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001710 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001711 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1712 repeat;
1713 }
1714 [] RSL_CCHAN.receive {
1715 repeat;
1716 }
1717 [] T.timeout { }
1718 }
1719 if (load_access_count == 1000) {
1720 setverdict(pass);
1721 } else {
1722 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1723 }
1724
1725 f_vty_load_ind_thresh(10);
1726 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1727}
1728
Harald Welte54a2a2d2018-02-26 09:14:05 +01001729private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001730 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001731 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy418066a2021-10-03 14:04:17 +06001732 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001733 f_sleep(0.5);
1734
1735 /* Transmit RACH request + wait for confirmation */
1736 var OCT1 ra := f_rnd_ra_cs();
1737 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1738
1739 /* Check for expected result */
1740 timer T := 1.5;
1741 T.start;
1742 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001743 [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welte54a2a2d2018-02-26 09:14:05 +01001744 setverdict(pass);
1745 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001746 [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001747 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001748 }
1749 [] RSL_CCHAN.receive { repeat; }
1750 [not expect_pass] T.timeout {
1751 setverdict(pass);
1752 }
1753 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001754 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001755 }
1756 }
1757}
1758
1759/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1760testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001761 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001762 f_init_l1ctl();
1763 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001764 f_sleep(1.0);
1765
1766 /* default max-ta is 63 (full range of GSM timing advance */
1767
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001768 /* We allow early arrival up to 2 symbols */
1769 f_rach_toffs(-1*256, true);
1770 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001771 f_rach_toffs(-10*256, false);
1772
1773 /* 0 / 32 / 63 bits is legal / permitted */
1774 f_rach_toffs(0, true);
1775 f_rach_toffs(32*256, true);
1776 f_rach_toffs(63*256, true);
1777
1778 /* more than 63 bits is not legal / permitted */
1779 f_rach_toffs(64*256, false);
1780 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001781 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001782}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001783
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001784private function f_TC_ho_rach(charstring id) runs on ConnHdlr {
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001785 var GsmFrameNumber fn;
1786 var RSL_Message rm;
1787
1788 f_l1_tune(L1CTL);
1789 RSL.clear;
1790
1791 /* Generate a random Handover Reference */
1792 var integer ho_ref := oct2int(f_rnd_octstring(1));
1793
1794 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1795 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1796 RSL_IE_Body:{ handover_ref := ho_ref }));
1797
1798 /* Activate a channel on the BTS side (no encryption) */
1799 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1800 act_type := t_RSL_IE_ActType_HO_SYNC);
1801
1802 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1803 * waiting for Immediate Assignment and sending Access Burst */
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07001804 f_l1ctl_est_dchan(L1CTL, g_pars);
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001805
1806 /* Send handover Access Burst */
1807 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1808
1809 /* TODO: test mismatching Handover Reference, and missing IE */
1810
1811 /* Wait for handover detection */
1812 timer T := 3.0;
1813 T.start;
1814 alt {
1815 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1816 log("Handover RACH has been detected: ", rm);
1817 setverdict(pass);
1818 }
1819 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1820 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1821 log2str("RSL_CHAN_RQD was not expected: ", rm));
1822 }
1823 [] RSL.receive { repeat; }
1824 [] T.timeout {
1825 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1826 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
1827 }
1828 }
1829
1830 /* Release the channel */
1831 f_rsl_chan_deact();
1832 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1833}
1834
1835/* Test handover RACH detection */
1836testcase TC_ho_rach() runs on test_CT {
1837 var ConnHdlrPars pars;
1838 var ConnHdlr vc_conn;
1839
1840 f_init();
1841
1842 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
1843 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1844 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1845 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
1846 vc_conn.done;
1847 }
1848
1849 /* TODO: do the above in parallel, rather than sequentially? */
1850 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1851}
1852
Harald Welte93640c62018-02-25 16:59:33 +01001853/***********************************************************************
1854 * Measurement Processing / Reporting
1855 ***********************************************************************/
1856
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001857private template (value) LapdmAddressField
1858ts_LapdmAddr(template (value) LapdmSapi sapi,
1859 template (value) boolean c_r) := {
Harald Welte70767382018-02-21 12:16:40 +01001860 spare := '0'B,
1861 lpd := 0,
1862 sapi := sapi,
1863 c_r := c_r,
1864 ea := true
1865}
1866
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001867private template (value) LapdmFrameAB
1868ts_LAPDm_AB(template (value) LapdmSapi sapi,
1869 template (value) GsmRrL3Message l3,
1870 template (value) boolean c_r := false,
1871 template (value) boolean p := false) := {
Harald Welte70767382018-02-21 12:16:40 +01001872 addr := ts_LapdmAddr(sapi, c_r),
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001873 ctrl := ts_LapdmCtrlUI(valueof(p)),
Harald Welte70767382018-02-21 12:16:40 +01001874 len := 0, /* overwritten */
1875 m := false,
1876 el := 1,
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001877 payload := enc_GsmRrL3Message(valueof(l3))
Harald Welte70767382018-02-21 12:16:40 +01001878}
1879
1880/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07001881private altstep as_l1_sacch() runs on ConnHdlr {
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001882 var template (value) LapdmFrameAB lb;
Harald Welte70767382018-02-21 12:16:40 +01001883 var L1ctlDlMessage l1_dl;
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001884
Harald Weltef8df4cb2018-03-10 15:15:08 +01001885 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001886 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Vadim Yanitskiy5351ccf2020-11-11 20:48:17 +07001887
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +01001888 lb := ts_LAPDm_AB(0, ts_MEAS_REP(g_pars.l1_pars.meas_valid,
Vadim Yanitskiycb57c1b2020-11-11 20:57:15 +07001889 g_pars.l1_pars.meas_ul.full.rxlev,
1890 g_pars.l1_pars.meas_ul.sub.rxlev,
1891 g_pars.l1_pars.meas_ul.full.rxqual,
1892 g_pars.l1_pars.meas_ul.sub.rxqual));
Harald Welte70767382018-02-21 12:16:40 +01001893 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001894
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001895 var template (value) SacchL1Header l1h := ts_SacchL1Header(
1896 g_pars.l1_pars.ms_power_level, false,
1897 g_pars.l1_pars.ms_actual_ta);
1898
Vadim Yanitskiyf105a5b2020-11-30 14:27:55 +01001899 /* According to 3GPP TS 44.018, section 10.5.2.20, we should pad with zeroes */
1900 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '00'O);
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001901
1902 log("Sending Measurement Report: ", l1h, l2);
1903 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01001904 repeat;
1905 }
1906}
1907
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07001908/* handle incoming downlink SACCH, decode the L1 header into the given record */
1909private altstep as_l1_sacch_l1h(inout SacchL1Header l1h,
1910 boolean do_apply := true)
1911runs on ConnHdlr
1912{
1913 var L1ctlDlMessage l1_dl;
1914
1915 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1916 /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
1917 l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2));
1918 log(%definitionId, "(): Rx SACCH L1 header: ", l1h);
1919
1920 if (do_apply) {
1921 /* Update TA and MS power to follow what BTS requests */
1922 f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl);
1923 }
1924 }
1925}
1926
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +07001927private altstep as_l1_dcch_loop() runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001928 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001929 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001930 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1931 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001932 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1933 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001934 repeat;
1935 }
1936}
1937
Vadim Yanitskiydc008112020-10-19 14:42:04 +07001938private altstep as_l1_tch_loop() runs on ConnHdlr {
1939 var L1ctlDlMessage l1_dl;
1940 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl {
1941 log("TCH received: ", l1_dl.payload.traffic_ind.data);
Philipp Maier149c3922020-10-22 17:29:36 +02001942
1943 /* occasionaly inject FACCH frames into the uplink */
1944 if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) {
1945 var octetstring pl := '010301'O;
1946 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1947 f_pad_oct(pl, 23, '2B'O)));
1948 } else {
1949 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id,
1950 l1_dl.payload.traffic_ind.data));
1951 }
1952
Vadim Yanitskiydc008112020-10-19 14:42:04 +07001953 repeat;
1954 }
1955}
1956
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07001957private type record MeasElem {
Harald Welte70767382018-02-21 12:16:40 +01001958 uint6_t rxlev,
1959 uint3_t rxqual
1960}
1961
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07001962private type record MeasElemFS {
Harald Welte70767382018-02-21 12:16:40 +01001963 MeasElem full,
1964 MeasElem sub
1965}
1966
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07001967private type record ConnL1Pars {
Harald Welte70767382018-02-21 12:16:40 +01001968 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001969 boolean toa256_enabled,
Vadim Yanitskiy7dad6082020-11-28 22:42:27 +01001970 boolean meas_valid,
Harald Welte70767382018-02-21 12:16:40 +01001971 MeasElemFS meas_ul,
1972 int16_t timing_offset_256syms,
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07001973 uint4_t bs_power_level,
Harald Welte70767382018-02-21 12:16:40 +01001974 uint5_t ms_power_level,
Philipp Maier149c3922020-10-22 17:29:36 +02001975 uint8_t ms_actual_ta,
1976 boolean facch_enabled
Harald Welte70767382018-02-21 12:16:40 +01001977}
1978
1979/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1980private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1981 return 63 + (toffs256s/256);
1982}
1983
Harald Welted5684392018-03-10 18:22:04 +01001984private function f_max(integer a, integer b) return integer {
1985 if (a > b) {
1986 return a;
1987 } else {
1988 return b;
1989 }
1990}
1991
1992private function f_min(integer a, integer b) return integer {
1993 if (a < b) {
1994 return a;
1995 } else {
1996 return b;
1997 }
1998}
1999
2000/* compute negative tolerance val-tolerance, ensure >= min */
2001private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
2002 val := val - tolerance;
2003 return f_max(val, min);
2004}
2005
2006/* compute positive tolerance val+tolerance, ensure <= max */
2007private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
2008 val := val + tolerance;
2009 return f_min(val, max);
2010}
2011
2012/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
2013private function f_tolerance(integer val, integer min, integer max, integer tolerance)
2014return template integer {
2015 var template integer ret;
2016 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
2017 return ret;
2018}
2019
2020
Harald Welte70767382018-02-21 12:16:40 +01002021/* build a template for matching measurement results against */
2022private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
2023 var ConnL1Pars l1p := g_pars.l1_pars;
2024 var template RSL_IE_UplinkMeas ul_meas := {
2025 len := 3,
2026 rfu := '0'B,
2027 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01002028 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01002029 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01002030 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01002031 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01002032 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
2033 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01002034 supp_meas_info := omit
2035 };
Harald Welte685d5982018-02-27 20:42:05 +01002036 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02002037 ul_meas.len := (3+8);
2038 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002039 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02002040 toa256_min := ?,
2041 toa256_max := ?,
2042 toa256_std_dev := ?
2043 }
Harald Welte685d5982018-02-27 20:42:05 +01002044 }
Harald Welte70767382018-02-21 12:16:40 +01002045 var template RSL_IE_BS_Power bs_power := {
2046 reserved := 0,
2047 epc := false,
2048 fpc := false,
2049 power_level := l1p.bs_power_level
2050 };
2051 var template RSL_IE_L1Info l1_info := {
2052 ms_power_lvl := l1p.ms_power_level,
2053 fpc := false,
2054 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002055 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01002056 };
2057 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002058 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01002059 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
2060 ?, t_toffs);
2061}
2062
Philipp Maierdd841d32019-12-17 14:44:54 +01002063/* build a template for matching measurement results that do not contain any
2064 * MS related measurement (l1_info, l3_info and ms timing offset). */
2065private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
2066 var ConnL1Pars l1p := g_pars.l1_pars;
2067 var template RSL_IE_UplinkMeas ul_meas := {
2068 len := 3,
2069 rfu := '0'B,
2070 dtx_d := l1p.dtx_enabled,
2071 rxlev_f_u := ?,
2072 reserved1 := '00'B,
2073 rxlev_s_u := ?,
2074 reserved2 := '00'B,
2075 rxq_f_u := ?,
2076 rxq_s_u := ?,
2077 supp_meas_info := omit
2078 };
2079 if (l1p.toa256_enabled) {
2080 ul_meas.len := (3+8);
2081 ul_meas.supp_meas_info := {
2082 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
2083 toa256_min := ?,
2084 toa256_max := ?,
2085 toa256_std_dev := ?
2086 }
2087 }
2088 var template RSL_IE_BS_Power bs_power := {
2089 reserved := 0,
2090 epc := false,
2091 fpc := false,
2092 power_level := l1p.bs_power_level
2093 };
2094
2095 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
2096}
2097
Harald Welte70767382018-02-21 12:16:40 +01002098/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002099private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01002100 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01002101 var boolean chan_est := false;
2102
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07002103 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01002104
2105 /* Receive osmocom specific measurement reports. This is the normal
2106 * case. Here we verify that the measurement reports we sent are
2107 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01002108 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
2109 /* increment counter of next to-be-expected meas rep */
2110 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2111 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01002112 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01002113
2114 /* The following two cases may only happen in the beginning
2115 * of the channel establishment phase. Once we have received
2116 * the "our" measurement report the first time, the channel
2117 * is established and empty or hardcoded TRXCON reports must
2118 * not occur anymore. */
2119 chan_est := true;
2120
2121 repeat;
2122 }
2123
2124 /* When the BTS has established the channel, the MS might need slightly
2125 * more time to establish the channel and actually start sending. The
2126 * result is then a measurement report that just lacks the measurement
2127 * information of the MS. This is normal and we tolerate this behavior. */
2128 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
2129 /* increment counter of next to-be-expected meas rep */
2130 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2131 /* Re-start the timer expecting the next MEAS RES */
2132 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01002133 repeat;
2134 }
Philipp Maierdd841d32019-12-17 14:44:54 +01002135
2136 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
2137 * measurements if the TTCN3 side does not supply measurement input in
2138 * time. In those cases TRXCON will either use a cached measurement
2139 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
2140 * report the templates above will not match. We tolerate this
2141 * behavior, but only once. */
2142 [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 +01002143 /* increment counter of next to-be-expected meas rep */
2144 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
2145 if (g_first_meas_res) {
2146 g_first_meas_res := false;
2147 repeat;
2148 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002149 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01002150 }
Harald Welte70767382018-02-21 12:16:40 +01002151 }
2152 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002153 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01002154 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02002155 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002156 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01002157 }
2158}
2159
Harald Weltee613f962018-04-18 22:38:16 +02002160private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
2161 select (rsl_alg_id) {
2162 case (RSL_ALG_ID_A5_0) { return 0; }
2163 case (RSL_ALG_ID_A5_1) { return 1; }
2164 case (RSL_ALG_ID_A5_2) { return 2; }
2165 case (RSL_ALG_ID_A5_3) { return 3; }
2166 case (RSL_ALG_ID_A5_4) { return 4; }
2167 case (RSL_ALG_ID_A5_5) { return 5; }
2168 case (RSL_ALG_ID_A5_6) { return 6; }
2169 case (RSL_ALG_ID_A5_7) { return 7; }
2170 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002171 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
2172 /* Make compiler happy by calling mtc.stop here. It is already
2173 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02002174 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02002175 }
2176 }
2177}
2178
2179private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
2180 select (rsl_alg_id) {
2181 case (RSL_ALG_ID_A5_1) { return '000'B; }
2182 case (RSL_ALG_ID_A5_2) { return '001'B; }
2183 case (RSL_ALG_ID_A5_3) { return '010'B; }
2184 case (RSL_ALG_ID_A5_4) { return '011'B; }
2185 case (RSL_ALG_ID_A5_5) { return '100'B; }
2186 case (RSL_ALG_ID_A5_6) { return '101'B; }
2187 case (RSL_ALG_ID_A5_7) { return '110'B; }
2188 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002189 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
2190 /* Make compiler happy by calling mtc.stop here. It is already
2191 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02002192 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02002193 }
2194 }
2195}
2196
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02002197/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
2198private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
2199 var GsmFrameNumber fn;
2200 timer T := 8.0;
2201
2202 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
2203 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
2204
2205 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
2206 /* Send the actual RACH */
2207 fn := f_L1CTL_RACH(L1CTL, ra);
2208
2209 T.start;
2210 alt {
2211 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
2212 [] T.timeout {
2213 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
2214 }
2215 }
2216 T.stop
2217 return fn;
2218}
Harald Weltee613f962018-04-18 22:38:16 +02002219
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002220/* Tune to a dedicated channel: L1CTL only */
2221private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) {
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002222 if (not pars.fhp.enabled) {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002223 pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc,
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +07002224 mp_trx_pars[0].arfcn));
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002225 } else {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002226 pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc,
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002227 pars.fhp.maio_hsn.hsn,
2228 pars.fhp.maio_hsn.maio,
2229 pars.fhp.ma));
Vadim Yanitskiy6c71c172020-07-13 21:49:48 +07002230 }
2231}
2232
Harald Welte70767382018-02-21 12:16:40 +01002233/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02002234private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01002235 var GsmFrameNumber fn;
2236 var ImmediateAssignment imm_ass;
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002237 var ChannelDescription ch_desc;
Harald Welte70767382018-02-21 12:16:40 +01002238 var integer ra := 23;
2239
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02002240 /* Send RACH request and wait for ChanReq */
2241 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01002242
2243 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02002244 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01002245
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002246 /* Craft channel description (with or without frequency hopping parameters) */
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002247 if (g_pars.fhp.enabled) {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002248 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002249 } else {
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07002250 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc));
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002251 }
2252
Harald Welte70767382018-02-21 12:16:40 +01002253 /* Send IMM.ASS via CCHAN */
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002254 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map));
Harald Welte70767382018-02-21 12:16:40 +01002255 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
2256
2257 /* receive IMM.ASS on MS side */
2258 var ImmediateAssignment ia_um;
2259 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07002260
2261 /* Make sure that IMM.ASS contains hopping parameters (if enabled) */
2262 if (ch_desc.h != ia_um.chan_desc.h) {
2263 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch");
2264 }
2265
Harald Welte70767382018-02-21 12:16:40 +01002266 /* enable dedicated mode */
Vadim Yanitskiyca813922020-09-12 19:08:31 +07002267 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.fhp.ma);
Harald Weltee613f962018-04-18 22:38:16 +02002268 /* enable encryption, if requested */
2269 if (encr_enable) {
2270 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
2271 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
2272 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01002273
Vadim Yanitskiy52787bf2020-10-19 17:34:52 +07002274 /* Send TCH Mode Request to the L1 if needed */
2275 if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) {
2276 var L1ctlTchMode tch_mode;
2277
2278 select (g_pars.chan_mode.coding_alg_rate) {
2279 case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; }
2280 case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; }
2281 case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; }
2282 case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; }
2283 case else {
2284 log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate,
2285 " is not supported by the L1, falling back to signalling");
2286 tch_mode := L1CTL_CHAN_MODE_SIGN;
2287 }
2288 }
2289
2290 f_L1CTL_TCH_MODE(L1CTL, tch_mode);
2291 }
2292
Harald Weltefa45e9e2018-03-10 18:59:03 +01002293 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01002294}
2295
Vadim Yanitskiydd228c42021-07-04 02:37:30 +02002296/* Initialize and start the RTP emulation component for a ConnHdlr */
2297friend function f_rtpem_activate(inout octetstring payload,
2298 RtpemConfig cfg := c_RtpemDefaultCfg,
2299 RtpemMode mode := RTPEM_MODE_BIDIR)
2300runs on ConnHdlr {
2301 /* Step 0: initialize, connect and start the emulation component */
2302 vc_RTPEM := RTP_Emulation_CT.create(testcasename() & "-RTPEM");
2303 map(vc_RTPEM:RTP, system:RTP);
2304 map(vc_RTPEM:RTCP, system:RTCP);
2305 connect(vc_RTPEM:CTRL, self:RTPEM_CTRL);
2306 connect(vc_RTPEM:DATA, self:RTPEM_DATA);
2307 vc_RTPEM.start(RTP_Emulation.f_main());
2308
2309 /* Step 1: configure the RTP parameters */
2310 var integer payload_len := 0;
2311 var octetstring hdr := ''O;
2312
2313 select (g_pars.chan_mode) {
2314 case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)) /* TCH/FS */
2315 { payload_len := 33; hdr := 'D0'O; }
2316 case (tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)) /* TCH/HS */
2317 { payload_len := 15; hdr := '00'O; }
2318 case (tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)) /* TCH/EFS */
2319 { payload_len := 31; hdr := 'C0'O; }
2320 case else { /* FIXME: also handle TCH/AFS and TCH/AHS */
2321 setverdict(fail, "Unhandled RSL channel mode := ", g_pars.chan_mode);
2322 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2323 }
2324 }
2325
2326 /* Pad the payload to conform the expected length */
2327 payload := f_pad_oct(hdr & payload, payload_len, '00'O);
2328 cfg.tx_fixed_payload := payload;
2329 f_rtpem_configure(RTPEM_CTRL, cfg);
2330
2331 /* Step 2: bind the RTP emulation to the configured address */
2332 var PortNumber rtpem_bind_port := mp_rtpem_bind_port;
2333 f_rtpem_bind(RTPEM_CTRL, mp_rtpem_bind_ip, rtpem_bind_port);
2334
2335 /* Step 3: send CRCX with the configured address/port to the IUT */
2336 var RSL_Message rsl_pdu := f_rsl_transceive_ret(
2337 ts_RSL_IPA_CRCX(g_chan_nr, f_inet_addr(mp_rtpem_bind_ip), rtpem_bind_port),
2338 tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2339 "IPA CRCX ACK");
2340
2341 /* Step 4: connect to the IUT's address/port parsed from CRCX ACK */
2342 var HostName local_addr := f_inet_ntoa(rsl_pdu.ies[2].body.ipa_local_ip);
2343 var PortNumber local_port := rsl_pdu.ies[3].body.ipa_local_port;
2344 f_rtpem_connect(RTPEM_CTRL, local_addr, local_port);
2345
2346 /* Step 5: set the given RTP emulation mode */
2347 f_rtpem_mode(RTPEM_CTRL, mode);
2348}
2349
Harald Welte70767382018-02-21 12:16:40 +01002350/* establish DChan, verify existance + contents of measurement reports */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002351private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002352 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002353 RSL.clear;
2354
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07002355 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02002356 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002357 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002358 }
Harald Welte70767382018-02-21 12:16:40 +01002359
2360 f_est_dchan();
2361
2362 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
2363 * RSL measurement reports on Abis side */
2364 timer T := 8.0;
2365 T.start;
2366 alt {
2367 [] as_l1_sacch();
2368 [] as_meas_res();
Vadim Yanitskiya4f88c62020-10-19 14:38:37 +07002369 [] as_l1_dcch_loop();
Vadim Yanitskiydc008112020-10-19 14:42:04 +07002370 [] as_l1_tch_loop();
Harald Welte70767382018-02-21 12:16:40 +01002371 [] L1CTL.receive { repeat; }
2372 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002373 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01002374 * of any earlier errors, so if we reach this timeout, we're good */
2375 setverdict(pass);
2376 }
2377 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002378 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01002379 }
2380 }
2381 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01002382 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01002383}
Harald Welte0472ab42018-03-12 15:02:26 +01002384
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002385/* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */
2386private function f_wait_ramp_up() runs on ConnHdlr return integer {
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002387 var L1ctlDlMessage l1_dl;
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002388 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2389 timer Tup := 10.0;
2390 Tup.start;
2391 alt {
2392 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2393 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2394 log("Received rx_level=", rx_lvl);
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002395
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002396 if (rx_lvl != max_rx_lvl) {
2397 repeat;
2398 }
2399 Tup.stop;
2400 }
2401 [] L1CTL.receive { repeat; }
2402 [] Tup.timeout {
2403 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2404 log2str("Didn't reach full power ", max_rx_lvl));
2405 }
2406 }
2407 return max_rx_lvl;
2408}
2409
2410/* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */
2411private function f_verify_ramp_up() runs on ConnHdlr {
2412 var L1ctlDlMessage l1_dl;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002413 var integer initial_rx_lvl := -1;
2414 var integer last_rx_lvl := -1;
2415 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2416
2417 timer T := 2.0;
2418 alt {
2419 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2420 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2421 log("Received rx_level=", rx_lvl);
2422 if (initial_rx_lvl == -1) {
2423 initial_rx_lvl := rx_lvl;
2424 last_rx_lvl := rx_lvl;
2425
2426 /* Expect a somehow low value during first received messages */
2427 if (initial_rx_lvl >= max_rx_lvl / 2) {
2428 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2429 log2str("Detected high initial tx power during ramp up: ",
2430 initial_rx_lvl , ", full power is", max_rx_lvl));
2431 }
2432 }
2433
2434 /* received Rx level bigger than maximum allowed power by CN */
2435 if (rx_lvl > max_rx_lvl) {
2436 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2437 log2str("Detected Tx power higher than full power: ",
2438 rx_lvl , " > ", max_rx_lvl));
2439 }
2440
2441 /* Make sure it never decreases, since we are rumping up */
2442 if (last_rx_lvl > rx_lvl) {
2443 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2444 log2str("Detected Tx power decrease during ramp up: ",
2445 last_rx_lvl , " -> ", rx_lvl));
2446 }
2447
2448 if (rx_lvl == max_rx_lvl and not T.running) {
2449 /* We reached the maximum power, start timer and receive
2450 /* a few more to make sure we don't surpass it */
2451 log("Reached full power, wating a bit more until success");
2452 T.start;
2453 }
2454
2455 last_rx_lvl := rx_lvl;
2456 repeat;
2457 }
2458 [] L1CTL.receive { repeat; }
2459 [] T.timeout { }
2460 }
2461
2462 /* We didn't increase tx power during ramp up */
2463 if (initial_rx_lvl < last_rx_lvl) {
2464 log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl);
2465 } else {
2466 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2467 log2str("No Tx power increase during whole ramp up: ",
2468 initial_rx_lvl , " -> ", last_rx_lvl));
2469 }
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002470}
2471
2472/* verify BTS ramps power down to rx_level 0 */
2473private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr {
2474 var L1ctlDlMessage l1_dl;
2475 var integer last_rx_lvl := max_rx_lvl;
2476
2477 timer Tdown := 5.0;
2478 Tdown.start;
2479 alt {
2480 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2481 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2482 log("Received rx_level=", rx_lvl);
2483
2484 /* received Rx level bigger than maximum allowed power by CN */
2485 if (rx_lvl > max_rx_lvl) {
2486 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2487 log2str("Detected Tx power higher than full power: ",
2488 rx_lvl , " > ", max_rx_lvl));
2489 }
2490
2491 /* Make sure it never increases, since we are rumping down */
2492 if (last_rx_lvl < rx_lvl) {
2493 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2494 log2str("Detected Tx power increase during ramp up: ",
2495 last_rx_lvl , " -> ", rx_lvl));
2496 }
2497
2498 last_rx_lvl := rx_lvl;
2499 if (last_rx_lvl != 0) {
2500 repeat;
2501 }
2502 /* we reached power level 0, we are done */
2503 Tdown.stop;
2504 }
2505 [] L1CTL.receive { repeat; }
2506 [] Tdown.timeout { }
2507 }
2508
2509 /* We didn't increase tx power during ramp down */
2510 if (max_rx_lvl > last_rx_lvl) {
2511 log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl);
2512 } else {
2513 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2514 log2str("No Tx power decrease during whole ramp down: ",
2515 max_rx_lvl , " -> ", last_rx_lvl));
2516 }
2517}
2518
2519/* Verify Tx power reduction and ramping up during BTS bring up */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002520private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002521 f_l1_tune(L1CTL);
2522 RSL.clear;
2523
2524 f_verify_ramp_up();
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002525
2526 setverdict(pass);
2527}
2528testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT {
2529 var ConnHdlr vc_conn;
2530 var ConnHdlrPars pars;
2531 f_init();
2532 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2533 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars,
2534 pcu_comp := false, trxc_comp := true);
2535 vc_conn.done;
2536 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2537}
2538
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002539/* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002540private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002541 f_connhdlr_init_vty_bsc();
2542
2543 f_l1_tune(L1CTL);
2544 RSL.clear;
2545
2546 /* Wait until BTS is started and at full power */
2547 var integer max_rx_lvl := f_wait_ramp_up();
2548 log("Reached nominal level ", max_rx_lvl, ", shutting down OML link");
2549
2550 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2551 f_verify_ramp_down(max_rx_lvl);
2552
2553 setverdict(pass);
2554}
2555testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT {
2556 var ConnHdlr vc_conn;
2557 var ConnHdlrPars pars;
2558 f_init();
2559 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2560 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars,
2561 pcu_comp := false, trxc_comp := true);
2562 vc_conn.done;
2563 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2564}
2565
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002566/* Verify Tx power:
2567 * + ramping down during ADM state UNLOCKED->LOCKED
2568 * + ramping up during ADM state LOCKED->UNLOCKED
2569 */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002570private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr {
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002571 var L1ctlDlMessage l1_dl;
2572 var integer last_rx_lvl;
2573
2574 f_connhdlr_init_vty_bsc();
2575
2576 f_l1_tune(L1CTL);
2577 RSL.clear;
2578
2579 /* Wait until BTS is started and at full power */
2580 var integer max_rx_lvl := f_wait_ramp_up();
2581 log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED");
2582
2583 log("ADM STATE UNLOCKED->LOCKED");
2584 f_vty_enter_cfg_trx(BSCVTY);
2585 f_vty_transceive(BSCVTY, "rf_locked 1");
2586 last_rx_lvl := max_rx_lvl;
2587 f_verify_ramp_down(max_rx_lvl);
2588
2589 /* Let some time after we received 0dBm, then check we don't receive BCCH
2590 * anymore because scheduler has stopped after ramping down */
2591 f_sleep(2.0);
2592 L1CTL.clear;
2593 timer Tlocked := 2.0;
2594 Tlocked.start;
2595 alt {
2596 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2597 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2598 log2str("Received data_ind during rf_locked: ", l1_dl));
2599 }
2600 [] L1CTL.receive { repeat; }
2601 [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); }
2602 }
2603
2604 log("ADM STATE LOCKED->UNLOCKED");
2605 f_vty_transceive(BSCVTY, "rf_locked 0");
2606 f_verify_ramp_up();
2607 setverdict(pass);
2608}
2609testcase TC_tx_power_ramp_adm_state_change() runs on test_CT {
2610 var ConnHdlr vc_conn;
2611 var ConnHdlrPars pars;
2612 f_init();
2613 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2614 vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars,
2615 pcu_comp := false, trxc_comp := true);
2616 vc_conn.done;
2617 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2618}
2619
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002620private function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002621 timer T := 8.0;
2622 T.start;
2623 var RSL_Message rsl;
2624 alt {
2625 [] as_l1_sacch();
2626 [] L1CTL.receive { repeat; }
2627 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
2628 if (rsl.ies[3].body.bs_power.power_level == level) {
2629 setverdict(pass)
2630 } else {
2631 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
2632 }
2633 }
2634 [] T.timeout {
2635 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
2636 }
2637 }
2638}
2639
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002640/* See if the RSL MEASurement RESult contains expeced BS power level
2641 * set _during_ the CHANnel ACTIVation procedure. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002642private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002643 f_l1_tune(L1CTL);
2644 RSL.clear;
2645
2646 if (mp_bts_trxc_port != -1) {
2647 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2648 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2649 }
2650
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002651 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002652 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2653 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2654
2655 f_est_dchan(more_ies :={valueof(pwr)});
2656
2657 f_check_meas_bs_power_level(pwr_var);
2658
2659 f_rsl_chan_deact();
2660 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2661}
2662
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002663/* See if the RSL MEASurement RESult contains expeced BS power level
2664 * set _after_ the CHANnel ACTIVation procedure. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002665private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002666 f_l1_tune(L1CTL);
2667 RSL.clear;
2668
2669 if (mp_bts_trxc_port != -1) {
2670 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2671 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2672 }
2673
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002674 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002675 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2676
2677 f_est_dchan();
2678
2679 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2680
2681 f_check_meas_bs_power_level(pwr_var);
2682
2683 f_rsl_chan_deact();
2684 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2685}
2686
2687testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2688 var ConnHdlr vc_conn;
2689 var ConnHdlrPars pars;
2690 f_init();
2691 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2692 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2693 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2694 pcu_comp := false, trxc_comp := true);
2695 vc_conn.done;
2696 }
2697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2698}
2699
2700testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2701 var ConnHdlr vc_conn;
2702 var ConnHdlrPars pars;
2703 f_init();
2704 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2705 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2706 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
2707 pcu_comp := false, trxc_comp := true);
2708 vc_conn.done;
2709 }
2710 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2711}
2712
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002713/* Target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
2714 * second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds.
2715 * These power levels are valid for all bands and require no special handling. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002716private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002717 var uint5_t pwr_var := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002718 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02002719
2720 f_trxc_fake_rssi(rxlev2dbm(10));
2721 f_l1_tune(L1CTL);
2722 RSL.clear;
2723
2724 var RSL_IE_List addl_ies;
2725 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2726
2727 addl_ies := {
2728 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2729 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2730 };
2731
2732 /* establish with power parameters */
2733 f_est_dchan(more_ies := addl_ies);
2734
2735 /* set a high value to ensure L1 power control level increases */
2736 f_trxc_fake_rssi(rxlev2dbm(20));
2737
2738 timer T2 := 6.0;
2739 T2.start;
2740 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002741 [] as_l1_sacch_l1h(l1h) {
2742 if (l1h.ms_power_lvl < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002743 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002744 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002745 T2.stop;
2746 }
2747 [] L1CTL.receive { repeat; }
2748 [] T2.timeout {
2749 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2750 "Power Level in L1 header has not increased sufficiently");
2751 }
2752 }
2753
2754 /* set a low value to ensure L1 power control level decreases */
2755 f_trxc_fake_rssi(rxlev2dbm(0));
2756
2757 timer T4 := 6.0;
2758 T4.start;
2759 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002760 [] as_l1_sacch_l1h(l1h) {
2761 if (l1h.ms_power_lvl > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002762 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002763 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002764 T4.stop;
2765 setverdict(pass, "Power level in L1 decreased/increased as expected");
2766 }
2767 [] L1CTL.receive { repeat; }
2768 [] T4.timeout {
2769 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2770 "Power Level in L1 header has not decreased sufficiently");
2771 }
2772 }
2773
2774 f_rsl_chan_deact();
2775 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2776
2777}
2778
2779/* check that we do not exceed the max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002780private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002781 var uint5_t pwr_var := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002782 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02002783
2784 /* set a low value to ensure power increases */
2785 f_trxc_fake_rssi(rxlev2dbm(10));
2786 f_l1_tune(L1CTL);
2787 RSL.clear;
2788
2789 var RSL_IE_List addl_ies;
2790 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2791
2792 addl_ies := {
2793 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2794 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2795 };
2796
2797 /* establish with power parameters */
2798 f_est_dchan(more_ies := addl_ies);
2799
2800 timer T1 := 10.0;
2801 T1.start;
2802 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002803 [] as_l1_sacch_l1h(l1h) { repeat; }
Eric Wild61edb7e2019-06-03 12:38:31 +02002804 [] L1CTL.receive { repeat; }
2805 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002806 if (not isbound(l1h)) {
2807 setverdict(fail, "No SACCH blocks were received");
2808 } else if (l1h.ms_power_lvl != pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002809 setverdict(fail, "Power level in L1 header should not have changed");
2810 }
2811 }
2812 }
2813
2814 f_rsl_chan_deact();
2815 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2816
2817}
2818
2819/* see if we reach the band max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002820private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002821 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02002822 var uint5_t pwr_var := 15;
2823 var uint5_t pwr_max_var := f_get_max_power_from_band();
2824
2825 /* set a low value to ensure power increases */
2826 f_trxc_fake_rssi(rxlev2dbm(10));
2827 f_l1_tune(L1CTL);
2828 RSL.clear;
2829
2830 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2831 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2832
2833 /* establish with fixed power level */
2834 f_est_dchan(more_ies :={valueof(pwr)});
2835
2836 /* check our initial power level */
2837 f_wait_for_l1_power_level(pwr_var);
2838
2839 /* update power param to enable power loop
2840 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
2841 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
2842
2843 /* wait, then check that our power level was reduced */
2844 timer T1 := 10.0;
2845 T1.start;
2846 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002847 [] as_l1_sacch_l1h(l1h) { repeat; }
Eric Wild61edb7e2019-06-03 12:38:31 +02002848 [] L1CTL.receive { repeat; }
2849 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002850 if (not isbound(l1h)) {
2851 setverdict(fail, "No SACCH blocks were received");
2852 } else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002853 setverdict(pass, "Power level in L1 header reduced as expected");
2854 } else {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002855 setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ",
2856 "reach the expected value := ", pwr_max_var);
Eric Wild61edb7e2019-06-03 12:38:31 +02002857 }
2858 }
2859 }
2860
2861 f_rsl_chan_deact();
2862 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2863
2864}
2865
2866/* see if we reach the band min power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002867private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002868 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02002869
2870 /* set a high value to ensure power decreases */
2871 f_trxc_fake_rssi(rxlev2dbm(50));
2872 f_l1_tune(L1CTL);
2873 RSL.clear;
2874
2875 var uint5_t pwr_var := 5;
2876 var uint5_t pwr_target_val := 15;
2877
2878 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2879 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2880
2881 /* establish with fixed power level */
2882 f_est_dchan(more_ies :={valueof(pwr)});
2883
2884 /* check our initial power level */
2885 f_wait_for_l1_power_level(pwr_var);
2886
2887 /* update power param to enable power loop
2888 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01002889 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02002890
2891 /* wait, then check that our power level was increased */
2892 timer T1 := 10.0;
2893 T1.start;
2894 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002895 [] as_l1_sacch_l1h(l1h) { repeat; }
Eric Wild61edb7e2019-06-03 12:38:31 +02002896 [] L1CTL.receive { repeat; }
2897 [] T1.timeout {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002898 if (not isbound(l1h)) {
2899 setverdict(fail, "No SACCH blocks were received");
2900 } else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) {
2901 setverdict(pass, "Power level increased to lowest power value");
Eric Wild61edb7e2019-06-03 12:38:31 +02002902 } else {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002903 setverdict(fail, "Power level NOT increased to lowest power value");
Eric Wild61edb7e2019-06-03 12:38:31 +02002904 }
2905 }
2906 }
2907
2908 f_rsl_chan_deact();
2909 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2910
2911}
2912
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002913/* See if the power level remains constant when MS Power Parameters IE
2914 * is _absent_ in the CHANnel ACTIVation message. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002915private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002916 var SacchL1Header l1h;
Eric Wild280ccb82019-06-17 11:11:52 +02002917
2918 /* set a high value to ensure power decreases */
2919 f_trxc_fake_rssi(rxlev2dbm(50));
2920 f_l1_tune(L1CTL);
2921 RSL.clear;
2922
2923 var uint5_t pwr_var := 5;
2924
2925 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2926 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2927
2928 /* establish with fixed power level */
2929 f_est_dchan(more_ies :={valueof(pwr)});
2930
2931 /* check our initial power level */
2932 f_wait_for_l1_power_level(pwr_var);
2933
2934 /* wait, then check that our power level did not change */
2935 timer T1 := 10.0;
2936 T1.start;
2937 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002938 [] as_l1_sacch_l1h(l1h, do_apply := false) {
2939 if (l1h.ms_power_lvl != pwr_var) {
Eric Wild280ccb82019-06-17 11:11:52 +02002940 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2941 "BS power control should not be active unless we receive a power parameters IE!");
2942 }
2943 repeat;
2944 }
2945 [] L1CTL.receive { repeat; }
2946 [] T1.timeout { setverdict(pass); }
2947 }
2948
2949 f_rsl_chan_deact();
2950 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2951
2952}
2953
Vadim Yanitskiy6860e862021-06-30 00:16:26 +02002954/* See if the power level remains constant when MS Power Parameters IE
2955 * is _absent_ in the CHANnel ACTIVation and MS Power Control messages. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002956private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002957 var SacchL1Header l1h;
Eric Wild095024b2019-06-17 15:08:57 +02002958
2959 /* set a high value to ensure power decreases */
2960 f_trxc_fake_rssi(rxlev2dbm(50));
2961 f_l1_tune(L1CTL);
2962 RSL.clear;
2963
2964 var uint5_t pwr_var := 5;
2965
2966 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2967 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2968
2969 /* establish with fixed power level */
2970 f_est_dchan(more_ies :={valueof(pwr)});
2971
2972 /* check our initial power level */
2973 f_wait_for_l1_power_level(pwr_var);
2974
2975 /* pwr control without power params IE, should NOT activate MS power control*/
2976 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2977
2978 /* wait, then check that our power level did not change */
2979 timer T1 := 10.0;
2980 T1.start;
2981 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002982 [] as_l1_sacch_l1h(l1h, do_apply := false) {
2983 if (l1h.ms_power_lvl != pwr_var) {
Eric Wild095024b2019-06-17 15:08:57 +02002984 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2985 "BS power control should not be active unless we receive a power parameters IE!");
2986 }
2987 repeat;
2988 }
2989 [] L1CTL.receive { repeat; }
2990 [] T1.timeout { setverdict(pass); }
2991 }
2992
2993 f_rsl_chan_deact();
2994 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2995
2996}
2997
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07002998private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07002999 var SacchL1Header l1h;
Eric Wild61edb7e2019-06-03 12:38:31 +02003000 timer T0 := 10.0;
3001 T0.start;
3002 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003003 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3004 if (l1h.ms_power_lvl != level) {
Eric Wild61edb7e2019-06-03 12:38:31 +02003005 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3006 "Power level in L1 header != signaled (RSL) power level.");
3007 }
3008 }
3009 [] L1CTL.receive { repeat; }
3010 [] T0.timeout {
3011 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3012 "Timeout waiting for initial power level");
3013 }
3014 }
3015 T0.stop;
3016}
3017
3018private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
3019 var IntegerRecord min_dbm_level;
3020 var IntegerRecord max_dbm_level;
3021 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3022
3023 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
3024 if (min_dbm_level[i] == level) {
3025 return true;
3026 }
3027 }
3028 return false;
3029}
3030
3031private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
3032 var IntegerRecord min_dbm_level;
3033 var IntegerRecord max_dbm_level;
3034 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3035
3036 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
3037 if (max_dbm_level[i] == level) {
3038 return true;
3039 }
3040 }
3041 return false;
3042}
3043
3044private function f_get_max_power_from_band() runs on ConnHdlr return integer {
3045 var IntegerRecord min_dbm_level;
3046 var IntegerRecord max_dbm_level;
3047 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
3048 return max_dbm_level[0];
3049}
3050
3051type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003052private template charstring BtsBand_allGSM := pattern "GSM???";
Eric Wild61edb7e2019-06-03 12:38:31 +02003053private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
3054 // 45.005 4.1.1
3055 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
3056 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
3057 2, 1, 0};
3058 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
3059 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
3060 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
3061 var IntegerRecord rv;
3062
3063 select(band){
3064 case (BtsBand_allGSM){
3065 rv := gsm_power;
3066 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
3067 max_dbm_level := {2, 1, 0};
3068 }
3069 case("DCS1800"){
3070 rv := dcs_power;
3071 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
3072 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
3073 }
3074 case("PCS1900"){
3075 rv := pcs_power;
3076 min_dbm_level := {15};
3077 max_dbm_level := {30};
3078 }
Harald Welte194b6912020-10-11 21:01:55 +02003079 case else {
3080 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band);
3081 }
Eric Wild61edb7e2019-06-03 12:38:31 +02003082 }
3083
3084 return rv;
3085}
3086
3087private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
Harald Weltec935fad2020-10-11 21:02:54 +02003088 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 +02003089}
3090
3091testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
3092 var ConnHdlr vc_conn;
3093 var ConnHdlrPars pars;
3094 f_init();
3095 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3096 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3097 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3098 pars.bts0_band := f_vty_get_bts0_band();
3099 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
3100 vc_conn.done;
3101 }
3102 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3103 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3104}
3105
3106testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
3107 var ConnHdlr vc_conn;
3108 var ConnHdlrPars pars;
3109 f_init();
3110 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
3111 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3112 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3113 pars.bts0_band := f_vty_get_bts0_band();
3114 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
3115 vc_conn.done;
3116 }
3117 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3118 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3119}
3120
3121testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
3122 var ConnHdlr vc_conn;
3123 var ConnHdlrPars pars;
3124 f_init();
3125 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
3126 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3127 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3128 pars.bts0_band := f_vty_get_bts0_band();
3129 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
3130 vc_conn.done;
3131 }
3132 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3133 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3134}
3135
3136testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
3137 var ConnHdlr vc_conn;
3138 var ConnHdlrPars pars;
3139 f_init();
3140 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3141 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3142 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3143 pars.bts0_band := f_vty_get_bts0_band();
3144 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
3145 vc_conn.done;
3146 }
3147 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3148 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3149}
3150
Eric Wild280ccb82019-06-17 11:11:52 +02003151testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
3152 var ConnHdlr vc_conn;
3153 var ConnHdlrPars pars;
3154 f_init();
3155 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3156 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3157 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3158 pars.bts0_band := f_vty_get_bts0_band();
3159 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
3160 vc_conn.done;
3161 }
3162 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3163 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3164}
3165
Eric Wild095024b2019-06-17 15:08:57 +02003166testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
3167 var ConnHdlr vc_conn;
3168 var ConnHdlrPars pars;
3169 f_init();
3170 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
3171 for (var integer tn := 1; tn <= 1; tn := tn+1) {
3172 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3173 pars.bts0_band := f_vty_get_bts0_band();
3174 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
3175 vc_conn.done;
3176 }
3177 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
3178 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3179}
3180
Philipp Maier149c3922020-10-22 17:29:36 +02003181function f_TC_meas_res_speech_tchf(boolean facch_enabled) runs on test_CT {
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003182 var template RSL_IE_ChannelMode ch_mode;
3183 var ConnHdlr vc_conn;
3184 var ConnHdlrPars pars;
3185 f_init();
3186 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1);
3187 for (var integer tn := 1; tn <= 1; tn := tn + 1) {
3188 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode));
Philipp Maier149c3922020-10-22 17:29:36 +02003189 pars.l1_pars.facch_enabled := facch_enabled;
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003190 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3191 pcu_comp := false, trxc_comp := true);
3192 vc_conn.done;
3193 }
3194 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3195}
Philipp Maier149c3922020-10-22 17:29:36 +02003196
3197testcase TC_meas_res_speech_tchf() runs on test_CT {
3198 f_TC_meas_res_speech_tchf(false);
3199}
3200
3201testcase TC_meas_res_speech_tchf_facch() runs on test_CT {
3202 f_TC_meas_res_speech_tchf(true);
3203}
3204
3205function f_TC_meas_res_speech_tchh(boolean facch_enabled) runs on test_CT {
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003206 var template RSL_IE_ChannelMode ch_mode;
3207 var ConnHdlr vc_conn;
3208 var ConnHdlrPars pars;
3209 f_init();
3210 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
3211 for (var integer ss := 0; ss <= 1; ss := ss + 1) {
3212 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
Philipp Maier149c3922020-10-22 17:29:36 +02003213 pars.l1_pars.facch_enabled := facch_enabled;
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003214 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3215 pcu_comp := false, trxc_comp := true);
3216 vc_conn.done;
3217 }
3218 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3219}
Philipp Maier149c3922020-10-22 17:29:36 +02003220
3221testcase TC_meas_res_speech_tchh() runs on test_CT {
3222 f_TC_meas_res_speech_tchh(false)
3223}
3224
3225testcase TC_meas_res_speech_tchh_facch() runs on test_CT {
3226 f_TC_meas_res_speech_tchh(true)
3227}
3228
Vadim Yanitskiy780bc072020-10-20 02:16:01 +07003229testcase TC_meas_res_speech_tchh_toa256() runs on test_CT {
3230 var template RSL_IE_ChannelMode ch_mode;
3231 var ConnHdlr vc_conn;
3232 var ConnHdlrPars pars;
3233 f_init();
3234 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
3235 ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
3236 for (var integer ss := 0; ss <= 1; ss := ss + 1) {
3237 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
3238 pars.l1_pars.toa256_enabled := true;
3239 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3240 pcu_comp := false, trxc_comp := true);
3241 vc_conn.done;
3242 }
3243 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3244}
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07003245
Harald Welte70767382018-02-21 12:16:40 +01003246testcase TC_meas_res_sign_tchf() runs on test_CT {
3247 var ConnHdlr vc_conn;
3248 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003249 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003250 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003251 for (var integer tn := 1; tn <= 4; tn := tn+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003252 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_F)));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07003253 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3254 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003255 vc_conn.done;
3256 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003257 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003258}
3259testcase TC_meas_res_sign_tchh() runs on test_CT {
3260 var ConnHdlr vc_conn;
3261 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003262 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003263 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003264 for (var integer ss := 0; ss <= 1; ss := ss+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003265 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
Eric Wild5b9ef142019-07-11 19:28:02 +02003266 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3267 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003268 vc_conn.done;
3269 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003270 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003271}
3272testcase TC_meas_res_sign_sdcch4() runs on test_CT {
3273 var ConnHdlr vc_conn;
3274 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003275 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003276 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003277 for (var integer ss := 0; ss <= 3; ss := ss+1) {
3278 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02003279 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3280 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003281 vc_conn.done;
3282 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003283 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003284}
3285testcase TC_meas_res_sign_sdcch8() runs on test_CT {
3286 var ConnHdlr vc_conn;
3287 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003288 f_init();
Pau Espin Pedrol93a7b8b2021-10-08 16:57:50 +02003289 f_vty_config(BTSVTY, "bts 0", "no supp-meas-info toa256");
Harald Welte70767382018-02-21 12:16:40 +01003290 for (var integer ss := 0; ss <= 7; ss := ss+1) {
3291 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02003292 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3293 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01003294 vc_conn.done;
3295 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003296 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01003297}
Harald Welte685d5982018-02-27 20:42:05 +01003298testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
3299 var ConnHdlr vc_conn;
3300 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003301 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01003302 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
3303 for (var integer ss := 0; ss <= 1; ss := ss+1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07003304 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
Harald Welte685d5982018-02-27 20:42:05 +01003305 pars.l1_pars.toa256_enabled := true;
Vadim Yanitskiy0b652192020-10-20 02:39:02 +07003306 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
3307 pcu_comp := false, trxc_comp := true);
Harald Welte685d5982018-02-27 20:42:05 +01003308 vc_conn.done;
3309 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003310 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01003311}
3312
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003313/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
3314 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003315private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003316 var SacchL1Header l1h;
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003317 var RSL_IE_MS_Power ms_power;
3318 var RSL_Message rsl;
3319 var uint5_t power_level := 0;
3320
3321 f_l1_tune(L1CTL);
3322 RSL.clear;
3323
3324 f_est_dchan();
3325
3326 ms_power.reserved := 0;
3327 ms_power.fpc_epc := false;
3328
3329 /* Send the first power control command. This will disable any BTS/TRX
3330 * internal power control and switch the MS (which is not in scope of
3331 * this test) to a constant power level. We start with a power level
3332 * of 0 */
3333 ms_power.power_level := power_level;
3334 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
3335 RSL.send(rsl);
3336
3337 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003338 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3339 if (l1h.ms_power_lvl != power_level) {
3340 setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
3341 "match the signaled (RSL) power level := ", power_level);
3342 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003343 }
3344
3345 /* Signal a new power level via RSL for the next turn. */
3346 if (power_level < 31) {
3347 power_level := power_level + 1;
3348 ms_power.power_level := power_level;
3349 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
3350 RSL.send(rsl);
3351 repeat;
3352 }
3353
3354 }
3355
3356 /* Ignore all other blocks */
3357 [] L1CTL.receive { repeat; }
3358
3359 }
3360
3361 f_rsl_chan_deact();
3362 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3363
3364 setverdict(pass);
3365}
3366
3367testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
3368 var ConnHdlr vc_conn;
3369 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003370 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01003371
3372 for (var integer tn := 1; tn <= 4; tn := tn+1) {
3373 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
3374 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
3375 vc_conn.done;
3376 }
3377 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3378}
Harald Welte70767382018-02-21 12:16:40 +01003379
Pau Espin Pedrol188bfd22020-06-03 20:32:45 +02003380/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
Eric Wild6833cc92019-05-23 19:34:44 +02003381TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003382private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
Eric Wild6833cc92019-05-23 19:34:44 +02003383 var uint5_t ta_to_test := 16;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003384 var SacchL1Header l1h;
Eric Wild6833cc92019-05-23 19:34:44 +02003385
3386 f_l1_tune(L1CTL);
3387 RSL.clear;
3388
3389 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07003390 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02003391
3392 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
3393
3394
3395 alt {
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003396 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3397 if (l1h.actual_ta != ta_to_test) {
Eric Wild6833cc92019-05-23 19:34:44 +02003398 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
3399 }
3400
3401 }
3402
3403 /* Ignore all other blocks */
3404 [] L1CTL.receive { repeat; }
3405
3406 }
3407
3408 f_rsl_chan_deact();
3409 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3410
3411 setverdict(pass);
3412}
3413
3414testcase TC_rsl_chan_initial_ta() runs on test_CT {
3415 var ConnHdlr vc_conn;
3416 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003417 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02003418 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07003419 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
3420 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02003421 vc_conn.done;
3422 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3423}
3424
Eric Wilde57e1a62019-05-28 13:30:55 +02003425/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003426private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
Eric Wilde57e1a62019-05-28 13:30:55 +02003427 var uint5_t ms_power_level := 7;
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003428 var SacchL1Header l1h;
Eric Wilde57e1a62019-05-28 13:30:55 +02003429
3430 var RSL_IE_MS_Power ms_power;
3431 ms_power.reserved := 0;
3432 ms_power.fpc_epc := false;
3433 ms_power.power_level := ms_power_level;
3434
3435 f_l1_tune(L1CTL);
3436 RSL.clear;
3437
3438 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
3439
3440 timer T := 1.0;
3441 T.start;
3442 alt {
3443 /* Pick all SACCH blocks for checking */
Vadim Yanitskiyab5769c2020-11-11 07:02:28 +07003444 [] as_l1_sacch_l1h(l1h, do_apply := false) {
3445 if (l1h.ms_power_lvl != ms_power_level) {
3446 setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
3447 "match the signaled (RSL) power level := ", ms_power_level);
Eric Wilde57e1a62019-05-28 13:30:55 +02003448 }
3449 }
3450 /* Ignore all other blocks */
3451 [] L1CTL.receive { repeat; }
3452 [] T.timeout {
3453 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
3454 }
3455 }
3456
3457 f_rsl_chan_deact();
3458 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3459 setverdict(pass);
3460}
3461
3462testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
3463 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3464 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
3465}
3466
Harald Welte0472ab42018-03-12 15:02:26 +01003467/* 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 +01003468private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01003469 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01003470 RSL.clear;
3471
3472 f_est_dchan();
3473 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01003474 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01003475
3476 timer T := 40.0;
3477 T.start;
3478 alt {
3479 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
3480 setverdict(pass)
3481 }
3482 [] RSL.receive { repeat };
3483 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003484 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01003485 }
3486 }
3487 f_rsl_chan_deact();
3488}
3489testcase TC_conn_fail_crit() runs on test_CT {
3490 var ConnHdlr vc_conn;
3491 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003492 f_init();
Harald Welte70767382018-02-21 12:16:40 +01003493 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
3494 pars.t_guard := 60.0;
3495 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
3496 vc_conn.done;
3497}
3498
Harald Welte93640c62018-02-25 16:59:33 +01003499/***********************************************************************
3500 * Paging
3501 ***********************************************************************/
3502
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003503private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
Harald Welte68e495b2018-02-25 00:05:57 +01003504 if (tmsi == 'FFFFFFFF'O) {
3505 return true;
3506 } else {
3507 return false;
3508 }
3509}
Harald Welte70767382018-02-21 12:16:40 +01003510
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003511private type record allowedFn { integer frame_nr }
3512private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
3513private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
3514private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
3515private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
3516private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
3517private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
3518private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
3519private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
3520private function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
Philipp Maier82cb0b12018-08-31 14:41:39 +02003521{
3522 var integer frame_nr_51;
3523 frame_nr_51 := frame_nr mod 51
3524
3525 var allowedFn fn_check;
3526 fn_check.frame_nr := frame_nr_51;
3527
3528 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003529 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003530 return;
3531 }
3532
3533 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
3534 return;
3535 }
3536 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
3537 return;
3538 }
3539 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
3540 return;
3541 }
3542 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
3543 return;
3544 }
3545 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
3546 return;
3547 }
3548 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
3549 return;
3550 }
3551 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
3552 return;
3553 }
3554 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
3555 return;
3556 }
3557
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003558 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003559 return;
3560}
3561
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003562private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs,
3563 inout integer num_paging_rcv_ids,
3564 PagingTestCfg cfg)
Harald Welte68e495b2018-02-25 00:05:57 +01003565runs on test_CT {
3566 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01003567 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003568 repeat;
3569 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01003570 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01003571 var octetstring without_plen :=
3572 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
3573 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02003574
3575 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
3576
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07003577 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
3578 /* Ignore empty RR Paging Request (PCH filling) messages.
3579 * TODO: does it make sense to count them? */
3580 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003581 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3582 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003583 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003584 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3585 }
3586 } else if (match(rr, tr_PAGING_REQ2)) {
3587 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3588 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
3589 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3590 }
3591 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
3592 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3593 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003594 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003595 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3596 }
3597 } else if (match(rr, tr_PAGING_REQ3)) {
3598 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3599 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
3600 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3601 }
3602 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
3603 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3604 }
3605 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
3606 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3607 }
3608 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
3609 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3610 }
3611 }
3612 repeat;
3613 }
3614}
3615
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003616private type record PagingTestCfg {
Harald Welte68e495b2018-02-25 00:05:57 +01003617 boolean combined_ccch,
3618 integer bs_ag_blks_res,
3619 float load_factor,
Philipp Maierca058272021-06-23 10:35:23 +02003620 /* Mix in a paging request through the PCU socket for every Nth (ps_load_modulus)
3621 * paging command that is issued via RSL. */
3622 integer ps_load_modulus,
3623 /* Wait until the paging queue inside the BTS is congested before starting to add
3624 * pagings via the PCU socket (0 = disabled) */
3625 boolean ps_wait_cong,
3626 /* Maximum time to wait until the paging queue is drained at the end of the test.
3627 * This usually takes about 15s (size: 200, ~ 13 per s -> 15s), it is recommended
3628 * to set this value to 18s, however the draining process may take significantly
3629 * longer when the queue contains paging requests for PS as those are implemented
3630 * as immediate assignments and require an entire MAC block alone. */
3631 float queue_drain_timeout,
Harald Welte68e495b2018-02-25 00:05:57 +01003632 boolean exp_load_ind,
3633 boolean exp_overload,
3634 boolean use_tmsi
3635}
3636
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07003637private type record PagingTestState {
Harald Welte68e495b2018-02-25 00:05:57 +01003638 integer num_paging_sent,
3639 integer num_paging_rcv_msgs,
3640 integer num_paging_rcv_ids,
Philipp Maierca058272021-06-23 10:35:23 +02003641 integer num_overload,
3642 /* When free space inside the paging queue reaches more than 2 thirds
3643 * of its capacity cong_detected is set to true. */
3644 boolean cong_detected
Harald Welte68e495b2018-02-25 00:05:57 +01003645}
3646
Harald Welte68e495b2018-02-25 00:05:57 +01003647/* Helper function for paging related testing */
3648private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Philipp Maierca058272021-06-23 10:35:23 +02003649 /* Using the PCU socket affects the timing of the paging processing. We only
3650 * activate the PCU socket if we do paging load tests that include additional
3651 * paging load that is introduced through the PCU socket. */
3652 if (cfg.ps_load_modulus > 0) {
3653 f_init_with_pcuif();
3654 } else {
3655 f_init();
3656 }
Harald Welte68e495b2018-02-25 00:05:57 +01003657 f_init_l1ctl();
3658 f_l1_tune(L1CTL);
3659
Philipp Maierca058272021-06-23 10:35:23 +02003660 var octetstring imm_ass := f_rnd_octstring(23);
3661 var ASP_RSL_Unitdata load_ind;
3662
Harald Welte68e495b2018-02-25 00:05:57 +01003663 var PagingTestState st := {
3664 num_paging_sent := 0,
3665 num_paging_rcv_msgs := 0,
3666 num_paging_rcv_ids := 0,
Philipp Maierca058272021-06-23 10:35:23 +02003667 num_overload := 0,
3668 cong_detected := false
Harald Welte68e495b2018-02-25 00:05:57 +01003669 };
3670
3671 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
3672 var float max_pch_imsi_per_sec;
3673 if (cfg.use_tmsi) {
3674 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
3675 } else {
3676 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
3677 }
3678 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
3679 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003680 var float time_total := 20.0;
3681 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
3682 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01003683
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003684 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
3685 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01003686
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003687 timer T_itv := 0.0;
3688 T_itv.start;
3689 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01003690 alt {
3691 /* check for presence of CCCH LOAD IND (paging load) */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003692 [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Harald Welte68e495b2018-02-25 00:05:57 +01003693 st.num_overload := st.num_overload + 1;
3694 repeat;
3695 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003696 [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01003698 }
Philipp Maierca058272021-06-23 10:35:23 +02003699 [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 +01003700 log("Rx LOAD_IND");
Philipp Maierca058272021-06-23 10:35:23 +02003701
3702 /* Detect paging congestion: The logic inside the BTS will diagnose the
3703 * paging queue as congested when the fill state is more than 66% (which
3704 * is two thirds fill state, or approx. 66 of 200 paging slots. When a
3705 * paging congestion is detected pagings that are issued through the PCU
3706 * socket (PS) are dropped in order to prefer the CS related pagings. */
3707 if (load_ind.rsl.ies[1].body.paging_load < 66) {
3708 st.cong_detected := true;
3709 }
3710
Harald Welte68e495b2018-02-25 00:05:57 +01003711 /* FIXME: analyze/verify interval + contents */
3712 repeat;
3713 }
Vadim Yanitskiy2372db62021-06-09 00:50:11 +02003714 /* ignore other RSL messages like RF RESource INDication */
3715 [] RSL_CCHAN.receive { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01003716 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02003717 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003718 [] L1CTL.receive { repeat; }
Philipp Maierca058272021-06-23 10:35:23 +02003719 /* Only relevant when testing including with PCU sock connected */
3720 [] PCU.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003721 [] T_itv.timeout {
3722 /* Send paging cmds based on elapsed time */
3723 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
3724 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003725 var MobileIdentityV mi;
3726
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003727 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003728 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003729 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003730 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003731 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003732 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003733
3734 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003735 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 +02003736
Philipp Maierca058272021-06-23 10:35:23 +02003737 /* Add additional pagings through the PCU socket interface. */
3738 if (cfg.ps_load_modulus > 0 and st.num_paging_sent mod cfg.ps_load_modulus == 0) {
3739 if (st.cong_detected == true or cfg.ps_wait_cong == false) {
3740 f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H, wait_for_cnf := false);
3741 }
3742 }
3743
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003744 st.num_paging_sent := st.num_paging_sent + 1;
3745 }
3746 if (st.num_paging_sent < pkt_total) {
3747 /* Wait for interval to next PAGING COMMAND */
3748 var float time_now := T_total.read;
3749 var float next_sched := int2float(st.num_paging_sent)*interval;
3750 if (next_sched > time_now) {
3751 T_itv.start(next_sched - time_now);
3752 } else {
3753 T_itv.start(0.0);
3754 }
3755 } else {
3756 /* We are done, no need to keep counting */
3757 T_total.stop;
3758 }
3759 }
3760 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01003761 }
3762 }
3763
Philipp Maierca058272021-06-23 10:35:23 +02003764 timer T_wait := cfg.queue_drain_timeout
Harald Welte68e495b2018-02-25 00:05:57 +01003765 T_wait.start;
3766 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02003767 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003768 [] L1CTL.receive { repeat; }
3769 /* 65535 == empty paging queue, we can terminate*/
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003770 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
Philipp Maierca058272021-06-23 10:35:23 +02003771 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) -> value load_ind { repeat; }
Vadim Yanitskiy2372db62021-06-09 00:50:11 +02003772 /* ignore other RSL messages like RF RESource INDication */
3773 [] RSL_CCHAN.receive { repeat; }
Philipp Maierca058272021-06-23 10:35:23 +02003774 /* Only relevant when testing including with PCU sock connected */
3775 [] PCU.receive { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01003776 [] T_wait.timeout {
Philipp Maierca058272021-06-23 10:35:23 +02003777 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 +01003778 }
Harald Welte68e495b2018-02-25 00:05:57 +01003779 }
3780
3781 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
3782 " rcvd_ids=", st.num_paging_rcv_ids);
3783 return st;
3784}
3785
3786/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
3787 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3788 * - that CCCH LOAD IND (PCH) are being generated
3789 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3790testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003791 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003792 var PagingTestCfg cfg := {
3793 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003794 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003795 load_factor := 0.8,
Philipp Maierca058272021-06-23 10:35:23 +02003796 ps_load_modulus := 0,
3797 ps_wait_cong := false,
3798 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01003799 exp_load_ind := true,
3800 exp_overload := false,
3801 use_tmsi := false
3802 };
3803 var PagingTestState st := f_TC_paging(cfg);
3804 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003805 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3806 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003807 } else {
3808 setverdict(pass);
3809 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003810 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003811}
3812
3813/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
3814 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3815 * - that CCCH LOAD IND (PCH) are being generated
3816 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3817testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003818 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003819 var PagingTestCfg cfg := {
3820 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003821 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003822 load_factor := 0.8,
Philipp Maierca058272021-06-23 10:35:23 +02003823 ps_load_modulus := 0,
3824 ps_wait_cong := false,
3825 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01003826 exp_load_ind := true,
3827 exp_overload := false,
3828 use_tmsi := true
3829 };
3830 var PagingTestState st := f_TC_paging(cfg);
3831 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003832 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3833 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003834 } else {
3835 setverdict(pass);
3836 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003837 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003838}
3839
3840/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
3841 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3842 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3843 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3844testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003845 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003846 var PagingTestCfg cfg := {
3847 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003848 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003849 load_factor := 2.0,
Philipp Maierca058272021-06-23 10:35:23 +02003850 ps_load_modulus := 0,
3851 ps_wait_cong := false,
3852 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01003853 exp_load_ind := true,
3854 exp_overload := true,
3855 use_tmsi := false
3856 };
3857 var PagingTestState st := f_TC_paging(cfg);
3858 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3859 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003860 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003861 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003862 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 +01003863 } else {
3864 setverdict(pass);
3865 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003866 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003867}
3868
3869/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
3870 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3871 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3872 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3873testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003874 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003875 var PagingTestCfg cfg := {
3876 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003877 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003878 load_factor := 2.0,
Philipp Maierca058272021-06-23 10:35:23 +02003879 ps_load_modulus := 0,
3880 ps_wait_cong := false,
3881 queue_drain_timeout := 18.0,
Harald Welte68e495b2018-02-25 00:05:57 +01003882 exp_load_ind := true,
3883 exp_overload := true,
3884 use_tmsi := true
3885 };
3886 var PagingTestState st := f_TC_paging(cfg);
3887 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
3888 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003889 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003890 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003891 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 +01003892 } else {
3893 setverdict(pass);
3894 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003895 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003896}
3897
Philipp Maierca058272021-06-23 10:35:23 +02003898/* Same as above, but with additional paging load created by PS pagings that
3899 * are issued through the PCU socket. The additional load is introduced when
3900 * the paging queue is already two thirds full. Since the BTS implements a
3901 * prioritization logic that drops the pagings from the PCU under in those
3902 * congestive sitautions the behaviour on the PS side is expected to be
3903 * unaffected and match the behavior of TC_paging_imsi_200percent() */
3904testcase TC_paging_imsi_200percent_with_ps() runs on test_CT {
3905 var SystemInformation si3 := valueof(ts_SI3_default);
3906 var PagingTestCfg cfg := {
3907 combined_ccch := true,
3908 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
3909 load_factor := 2.0,
3910 ps_load_modulus := 16,
3911 ps_wait_cong := true,
3912 queue_drain_timeout := 18.0,
3913 exp_load_ind := true,
3914 exp_overload := true,
3915 use_tmsi := false
3916 };
3917 var PagingTestState st := f_TC_paging(cfg);
3918 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3919 * slots and will fully drain that buffer before returning */
3920 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
3921 if (not match(st.num_paging_rcv_ids, tpl)) {
3922 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
3923 } else {
3924 setverdict(pass);
3925 }
3926 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3927}
3928
3929
Harald Welte68e495b2018-02-25 00:05:57 +01003930
Harald Welte93640c62018-02-25 16:59:33 +01003931/***********************************************************************
3932 * Immediate Assignment / AGCH
3933 ***********************************************************************/
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +07003934private const MobileAllocationLV c_MA_null := {
Harald Weltee8d750e2018-06-10 21:41:35 +02003935 len := 0,
3936 ma := ''B
3937}
Harald Welte93640c62018-02-25 16:59:33 +01003938
Harald Weltee8d750e2018-06-10 21:41:35 +02003939private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
3940 return int2str(num_tx) & " sent, "
3941 & int2str(num_rx) & " received, "
3942 & int2str(num_del) & " deleted";
3943}
3944
3945private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
3946 var L1ctlDlMessage l1_dl;
3947 timer T := 10.0;
3948 var integer num_tx := 0;
3949 var integer num_rx := 0;
3950 var integer num_del := 0;
3951 var charstring res_str;
3952 var float rx_ratio;
3953
Harald Welte10474062019-05-30 16:48:17 +02003954 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02003955 f_init_l1ctl();
3956 f_l1_tune(L1CTL);
3957
3958 for (var integer i := 0; i < num_total; i := i+1) {
Vadim Yanitskiy42d8bd52020-11-15 20:41:02 +07003959 var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0),
Vadim Yanitskiy3191d732020-11-15 20:45:01 +07003960 mp_trx_pars[0].arfcn,
3961 mp_tsc_def));
Harald Weltee8d750e2018-06-10 21:41:35 +02003962 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
3963 var octetstring ia_enc := enc_GsmRrMessage(ia);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003964 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02003965 num_tx := num_tx+1;
3966 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01003967 }
3968 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02003969 T.start;
3970 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003971 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
Harald Weltee8d750e2018-06-10 21:41:35 +02003972 num_del := num_del+1;
3973 repeat;
3974 }
3975 [] RSL_CCHAN.receive {
3976 repeat;
3977 }
3978 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
Harald Weltee8d750e2018-06-10 21:41:35 +02003979 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
3980 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
3981 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003982 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02003983 } else {
3984 num_rx := num_rx+1;
3985 }
3986 repeat;
3987 }
3988 [] L1CTL.receive { repeat; }
3989 [] T.timeout { }
3990 }
3991 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
3992 log("AGCH test: " & res_str);
3993 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003994 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02003995 }
3996 rx_ratio := int2float(num_rx) / int2float(num_tx);
3997 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003998 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 +02003999 } else {
4000 setverdict(pass);
4001 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004002 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004003}
4004
Harald Weltee8d750e2018-06-10 21:41:35 +02004005/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
4006testcase TC_imm_ass_1000_20ms() runs on test_CT {
4007 f_TC_imm_ass(1000, 0.02, 0.25);
4008}
4009
4010/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
4011testcase TC_imm_ass_200_0ms() runs on test_CT {
4012 f_TC_imm_ass(200, 0.0, 0.05);
4013}
4014
4015/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
4016testcase TC_imm_ass_200_76ms() runs on test_CT {
4017 f_TC_imm_ass(150, 0.076, 1.00);
4018}
4019
4020
4021
Harald Welte48494ca2018-02-25 16:59:50 +01004022/***********************************************************************
4023 * BCCH
4024 ***********************************************************************/
4025
4026/* tuple of Frame Number + decoded SI */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004027private type record SystemInformationFn {
Harald Welte48494ca2018-02-25 16:59:50 +01004028 GsmFrameNumber frame_number,
4029 SystemInformation si
4030}
4031
4032/* an arbitrary-length vector of decoded SI + gsmtap header */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004033private type record of SystemInformationFn SystemInformationVector;
Harald Welte48494ca2018-02-25 16:59:50 +01004034
4035/* an array of SI-vectors indexed by TC value */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004036private type SystemInformationVector SystemInformationVectorPerTc[8];
Harald Welte48494ca2018-02-25 16:59:50 +01004037
4038/* determine if a given SI vector contains given SI type at least once */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004039private function f_si_vecslot_contains(SystemInformationVector arr,
4040 RrMessageType key,
4041 boolean bcch_ext := false)
4042return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004043 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
4044 var integer fn_mod51 := arr[i].frame_number mod 51;
4045 if (not bcch_ext and fn_mod51 == 2 or
4046 bcch_ext and fn_mod51 == 6) {
4047 if (arr[i].si.header.message_type == key) {
4048 return true;
4049 }
4050 }
4051 }
4052 return false;
4053}
4054
4055/* 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 +07004056private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr,
4057 integer tc, RrMessageType key,
4058 boolean ext_bcch := false)
4059{
Harald Welte48494ca2018-02-25 16:59:50 +01004060 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004061 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004062 }
4063}
4064
4065/* check if a given SI vector contains given SI type at least once on any TC */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004066private function f_si_vec_contains(SystemInformationVectorPerTc arr,
4067 RrMessageType key)
4068return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004069 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
4070 if (f_si_vecslot_contains(arr[tc], key) or
4071 f_si_vecslot_contains(arr[tc], key, true)) {
4072 return true;
4073 }
4074 }
4075 return false;
4076}
4077
4078/* determine if a given SI vector contains given SI type at least N of M times */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004079private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr,
4080 RrMessageType key,
4081 boolean bcch_ext := false,
4082 integer n := 1, integer m := 4)
4083return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004084 var integer count := 0;
4085 if (sizeof(arr) < m) {
Harald Weltea616ec92020-10-11 21:28:00 +02004086 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: "
4087 & int2str(sizeof(arr)) & " < " & int2str(m));
Harald Welte48494ca2018-02-25 16:59:50 +01004088 }
4089 for (var integer i:= 0; i < m; i := i + 1) {
4090 var integer fn_mod51 := arr[i].frame_number mod 51;
4091 if (not bcch_ext and fn_mod51 == 2 or
4092 bcch_ext and fn_mod51 == 6) {
4093 if (arr[i].si.header.message_type == key) {
4094 count := count + 1;
4095 }
4096 }
4097 }
4098 if (count >= n) {
4099 return true;
4100 } else {
4101 return false;
4102 }
4103}
4104
4105/* 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 +07004106private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr,
4107 integer tc, RrMessageType key,
4108 boolean ext_bcch := false,
4109 integer n, integer m)
4110{
Harald Welte48494ca2018-02-25 16:59:50 +01004111 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004112 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004113 }
4114}
4115
4116/* determine if a given SI vector contains given SI type at least once */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004117private function f_si_vecslot_contains_only(SystemInformationVector arr,
4118 RrMessageType key,
4119 boolean bcch_ext := false)
4120return boolean {
Harald Welte48494ca2018-02-25 16:59:50 +01004121 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
4122 var integer fn_mod51 := arr[i].frame_number mod 51;
4123 if (not bcch_ext and fn_mod51 == 2 or
4124 bcch_ext and fn_mod51 == 6) {
4125 if (arr[i].si.header.message_type != key) {
4126 return false;
4127 }
4128 }
4129 }
4130 return true;
4131}
4132
4133/* ensure a given TC slot of the SI vector contains only given SI type */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004134private function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr,
4135 integer tc, RrMessageType key,
4136 boolean ext_bcch := false)
4137{
Harald Welte48494ca2018-02-25 16:59:50 +01004138 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004139 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01004140 }
4141}
4142
4143/* SI configuration of cell, against which we validate actual SI messages */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004144private type set SystemInformationConfig {
Harald Welte48494ca2018-02-25 16:59:50 +01004145 boolean bcch_extended,
4146 boolean si1_present,
4147 boolean si2bis_present,
4148 boolean si2ter_present,
4149 boolean si2quater_present,
4150 boolean si7_present,
4151 boolean si8_present,
4152 boolean si9_present,
4153 boolean si13_present,
4154 boolean si13alt_present,
4155 boolean si15_present,
4156 boolean si16_present,
4157 boolean si17_present,
4158 boolean si2n_present,
4159 boolean si21_present,
4160 boolean si22_present
4161}
4162
4163/* 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 +07004164private function f_validate_si_scheduling(SystemInformationConfig cfg,
4165 SystemInformationVectorPerTc si_per_tc)
4166{
Harald Welte48494ca2018-02-25 16:59:50 +01004167 var integer i;
4168 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
4169 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004170 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01004171 }
4172 }
4173 if (cfg.si1_present) {
4174 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
4175 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
4176 * when TC = 0, it can assume that System Information Type 1 is not in use. */
4177 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
4178 /* make sure *ALL* contain SI1 */
4179 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
4180 }
4181 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
4182 /* iii) A SI 2 message will be sent at least every time TC = 1 */
4183 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
4184 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
4185 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
4186 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
4187
4188 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
4189 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
4190 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
4191 * consecutive occurrences of TC = 4. */
4192 if (cfg.si2bis_present and not cfg.si2ter_present) {
4193 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
4194 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
4195 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
4196 } else if (cfg.si2ter_present and cfg.si2bis_present) {
4197 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
4198 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
4199 }
4200
4201 if (cfg.si7_present or cfg.si8_present) {
4202 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
4203 * if System Information type 4 does not contain all information needed for cell
4204 * selection and reselection. */
4205 if (not cfg.bcch_extended) {
4206 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
4207 }
4208 if (cfg.si7_present) {
4209 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
4210 }
4211 if (cfg.si8_present) {
4212 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
4213 }
4214 }
4215
4216 if (cfg.si2quater_present) {
4217 /* iii) System information type 2 quater is sent if needed, as determined by the system
4218 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
4219 * and 2ter are used, otherwise it shall be sent at least once within any of 4
4220 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
4221 * within any of 4 consecutive occurrences of TC = 5. */
4222 if (not (cfg.bcch_extended)) {
4223 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
4224 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
4225 } else {
4226 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
4227 }
4228 } else {
4229 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
4230 }
4231 }
4232 if (cfg.si9_present) {
4233 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
4234 * in system information type 3 as defined in 3GPP TS 44.018. */
4235 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
4236 }
4237 if (cfg.si13_present) {
4238 /* vii) System Information type 13 is only related to the GPRS service. System Information
4239 * Type 13 need only be sent if GPRS support is indicated in one or more of System
4240 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
4241 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
4242 * In the case that the message is sent on the BCCH Norm, it is sent at least once
4243 * within any of 4 consecutive occurrences of TC=4. */
4244 if (not cfg.bcch_extended) {
4245 log("not-bccch-extended");
4246 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
4247 } else {
4248 log("bccch-extended");
4249 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
4250 }
4251 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004252 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01004253 }
4254 }
4255 if (cfg.si16_present or cfg.si17_present) {
4256 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
4257 * should not be sent in a cell where network sharing is used (see rule xv). */
4258 if (cfg.si22_present) {
4259 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
4260 }
4261 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004262 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01004263 }
4264 if (not cfg.bcch_extended) {
4265 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
4266 }
4267 if (cfg.si16_present) {
4268 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
4269 }
4270 if (cfg.si17_present) {
4271 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
4272 }
4273 }
4274
4275 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
4276 * broadcast information. The frequency with which they are sent is determined by the
4277 * system operator. System Information type 9 identifies the scheduling of System
4278 * Information type 18 and 20 messages. */
4279
4280 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
4281 * Information Type 19 is present, then its scheduling shall be indicated in System
4282 * Information Type 9. */
4283
4284 if (cfg.si15_present) {
4285 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
4286 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
4287 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
4288 * 4 consecutive occurrences of TC = 1. */
4289 if (not cfg.bcch_extended) {
4290 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
4291 } else {
4292 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
4293 }
4294 }
4295 if (cfg.si13alt_present) {
4296 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
4297 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
4298 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
4299 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
4300 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
4301 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
4302 * of TC = 4. */
4303 if (cfg.si13_present) {
4304 testcase.stop("Error: Cannot have SI13alt and SI13");
4305 }
4306 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004307 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01004308 }
4309 if (not cfg.bcch_extended) {
4310 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
4311 } else {
4312 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
4313 }
4314 }
4315 if (cfg.si2n_present) {
4316 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
4317 * as determined by the system operator. In the case that the message is sent on the
4318 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
4319 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
4320 * consecutive occurrences of TC = 4. */
4321 if (not cfg.bcch_extended) {
4322 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
4323 } else {
4324 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
4325 }
4326 }
4327 if (cfg.si21_present) {
4328 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
4329 * determined by the system operator. If Extended Access Barring is in use in the cell
4330 * then this message is sent at least once within any of 4 consecutive occurrences of
4331 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
4332 * cell then this message shall only be sent on BCCH Ext. */
4333 if (not cfg.bcch_extended) {
4334 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
4335 } else {
4336 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
4337 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004338 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01004339 }
4340 }
4341 }
4342 if (cfg.si22_present) {
4343 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
4344 * should not be sent in a cell where SoLSA is used (see rule viii). System
4345 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
4346 * =2 and TC=6. */
4347 if (cfg.si16_present or cfg.si17_present) {
4348 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
4349 }
4350 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
4351 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004352 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01004353 }
4354 if (not cfg.bcch_extended) {
4355 testcase.stop("Error: SI22 requires BCCH Extd!");
4356 } else {
4357 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
4358 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
4359 }
4360 }
4361}
4362
4363/* sample Systme Information for specified duration via L1CTL */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07004364private function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0)
4365return SystemInformationVectorPerTc {
Harald Welte48494ca2018-02-25 16:59:50 +01004366 timer T := duration;
4367 var SystemInformationVectorPerTc si_per_tc;
4368 var L1ctlDlMessage l1_dl;
4369
4370 /* initialize all per-TC vectors empty */
4371 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
4372 si_per_tc[i] := {};
4373 }
4374
4375 /* flush all previous L1 queued msgs */
4376 pt.clear;
4377
4378 T.start;
4379 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004380 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07004381 var SystemInformationFn sig := { frame_number := l1_dl.dl_info.frame_nr };
4382 if (dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, sig.si) != 0) {
4383 log("Ignoring non-RR or invalid SI ", l1_dl);
Harald Welte48494ca2018-02-25 16:59:50 +01004384 repeat;
4385 }
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07004386
Harald Welte48494ca2018-02-25 16:59:50 +01004387 var integer tc := f_gsm_compute_tc(sig.frame_number);
4388 log("SI received at TC=", tc, ": ", sig.si);
4389 /* append to the per-TC bucket */
4390 si_per_tc[tc] := si_per_tc[tc] & { sig };
4391 repeat;
4392 }
4393 [] pt.receive { repeat; }
4394 [] T.timeout { }
4395 }
4396
4397 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
4398 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
4399 }
4400 log("si_per_tc=", si_per_tc);
4401 return si_per_tc;
4402}
4403
4404/* helper function: Set given SI via RSL + validate scheduling.
4405 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
Harald Welte9b965d52020-10-11 21:28:22 +02004406private function f_TC_si_sched(float duration := 8.0) runs on test_CT {
Harald Welte48494ca2018-02-25 16:59:50 +01004407 var SystemInformationVectorPerTc si_per_tc;
4408 f_init_l1ctl();
4409 f_l1_tune(L1CTL);
4410
4411 /* Sample + Validate Scheduling */
Harald Welte9b965d52020-10-11 21:28:22 +02004412 si_per_tc := f_l1_sample_si(L1CTL, duration);
Harald Welte48494ca2018-02-25 16:59:50 +01004413 f_validate_si_scheduling(si_cfg, si_per_tc);
4414
4415 setverdict(pass);
4416}
4417
4418testcase TC_si_sched_default() runs on test_CT {
4419 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01004420 /* 2+3+4 are mandatory and set in f_init() */
4421 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004422 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01004423}
4424
4425testcase TC_si_sched_1() runs on test_CT {
4426 f_init();
4427 si_cfg.si1_present := true;
4428 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004429 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004430 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004431}
4432
4433testcase TC_si_sched_2bis() runs on test_CT {
4434 f_init();
4435 si_cfg.si2bis_present := true;
4436 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4437 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004438 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004439}
4440
4441testcase TC_si_sched_2ter() runs on test_CT {
4442 f_init();
4443 si_cfg.si2ter_present := true;
4444 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4445 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004446 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004447}
4448
4449testcase TC_si_sched_2ter_2bis() runs on test_CT {
4450 f_init();
4451 si_cfg.si2bis_present := true;
4452 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4453 si_cfg.si2ter_present := true;
4454 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4455 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004456 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004457}
4458
4459testcase TC_si_sched_2quater() runs on test_CT {
4460 f_init();
4461 si_cfg.si2quater_present := true;
Vadim Yanitskiy3bb3b602020-10-24 21:24:05 +07004462 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O);
Harald Welte9b965d52020-10-11 21:28:22 +02004463 f_TC_si_sched(16.0);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004464 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004465}
4466
4467testcase TC_si_sched_13() runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01004468 /* NOTE: PCUIF connection is not used in this test case, but
4469 * without it the IUT would not broadcast SI13 (see OS#3075). */
4470 f_init_with_pcuif();
Harald Welte48494ca2018-02-25 16:59:50 +01004471 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02004472 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004473 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004474 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004475}
4476
4477testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01004478 /* NOTE: PCUIF connection is not used in this test case, but
4479 * without it the IUT would not broadcast SI13 (see OS#3075). */
4480 f_init_with_pcuif();
Harald Welte48494ca2018-02-25 16:59:50 +01004481 si_cfg.si2bis_present := true;
4482 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
4483 si_cfg.si2ter_present := true;
4484 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
4485 si_cfg.si2quater_present := true;
Vadim Yanitskiy3bb3b602020-10-24 21:24:05 +07004486 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607b10004864982eddb8d555867ee3c95540b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01004487 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02004488 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte9b965d52020-10-11 21:28:22 +02004489 f_TC_si_sched(16.0);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004490 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01004491}
4492
4493
Harald Welte68e495b2018-02-25 00:05:57 +01004494testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004495 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01004496 /* FIXME: enable / disable individual BCCH info */
4497 //ts_RSL_BCCH_INFO(si_type, info);
4498 /* expect no ERROR REPORT after either of them *
4499 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004500 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01004501}
4502
Harald Welte93640c62018-02-25 16:59:33 +01004503/***********************************************************************
4504 * Low-Level Protocol Errors / ERROR REPORT
4505 ***********************************************************************/
4506
Harald Welte01d982c2018-02-25 01:31:40 +01004507private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
4508 timer T := 5.0;
4509 T.start;
4510 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004511 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
Harald Welte01d982c2018-02-25 01:31:40 +01004512 setverdict(pass);
4513 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004514 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004515 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004516 }
4517 [] RSL_CCHAN.receive {
4518 repeat;
4519 }
4520 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004521 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004522 }
4523 }
4524}
4525
4526/* Provoke a protocol error (message too short) and match on ERROR REPORT */
4527testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004528 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004529 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4530 rsl.ies := omit;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004531 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004532
4533 f_exp_err_rep(RSL_ERR_PROTO);
4534}
4535
4536/* Provoke a mandatory IE error and match on ERROR REPORT */
4537testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004538 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004539
4540 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4541 rsl.ies := { rsl.ies[0] };
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004542 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004543
4544 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
4545}
4546
4547/* Provoke an IE content error and match on ERROR REPORT */
4548testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004549 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004550 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4551 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004552 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004553
4554 f_exp_err_rep(RSL_ERR_IE_CONTENT);
4555}
4556
Harald Welteee25aae2019-05-19 14:32:37 +02004557/* attempt to activate channel with wrong RSL Message Discriminator IE */
4558function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
4559 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4560 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
4561 RSL.send(rsl);
4562 f_rslem_unregister(0, g_chan_nr);
4563}
4564testcase TC_err_rep_wrong_mdisc() runs on test_CT {
4565 var ConnHdlr vc_conn;
4566 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4567
Harald Welte10474062019-05-30 16:48:17 +02004568 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004569
4570 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
4571 vc_conn.done;
4572 f_exp_err_rep(RSL_ERR_MSG_DISCR);
4573
4574 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4575}
4576
4577/* Send messages with wrong message type */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004578private function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004579 var template (value) RSL_Message rsl_tx;
4580 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4581 rsl_tx.msg_type := RSL_MT_NOT_CMD;
4582 RSL.send(rsl_tx);
4583 f_rslem_unregister(0, g_chan_nr);
4584}
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004585private function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004586 var template (value) RSL_Message rsl_tx;
4587 /* we first have to activate the dedicated channel */
4588 f_rsl_chan_act(g_pars.chan_mode);
4589 /* ... to then send an invalid RLL message */
4590 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
4591 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
4592 RSL.send(rsl_tx);
4593 f_rslem_unregister(0, g_chan_nr);
4594}
4595testcase TC_err_rep_wrong_msg_type() runs on test_CT {
4596 var ConnHdlr vc_conn;
4597 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4598 var template (value) RSL_Message rsl_tx;
4599
Harald Welte10474062019-05-30 16:48:17 +02004600 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004601
4602 /* Common Channel with wrong message type */
4603 RSL_CCHAN.clear;
4604 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4605 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004606 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02004607 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4608
4609 /* TRX Management */
4610 RSL_CCHAN.clear;
4611 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
4612 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004613 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02004614 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4615
4616 /* Dedicated Channel */
4617 RSL_CCHAN.clear;
4618 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
4619 vc_conn.done;
4620 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4621
4622 /* RLL */
4623 RSL_CCHAN.clear;
4624 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
4625 vc_conn.done;
4626 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4627}
4628
4629/* Send messages in wrong sequence (RLL to an inactive lchan) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004630private function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004631 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
4632 f_rslem_unregister(0, g_chan_nr);
4633}
4634testcase TC_err_rep_wrong_sequence() runs on test_CT {
4635 var ConnHdlr vc_conn;
4636 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4637
Harald Welte10474062019-05-30 16:48:17 +02004638 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004639
4640 RSL_CCHAN.clear;
4641 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
4642 vc_conn.done;
4643 f_exp_err_rep(RSL_ERR_MSG_SEQ);
4644}
4645
Harald Welte93640c62018-02-25 16:59:33 +01004646/***********************************************************************
4647 * IPA CRCX/MDCX/DLCS media stream handling
4648 ***********************************************************************/
4649
Harald Weltea871a382018-02-25 02:03:14 +01004650/* Send IPA DLCX to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004651private function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01004652 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4653 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01004654}
4655testcase TC_ipa_dlcx_not_active() runs on test_CT {
4656 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004657 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01004658 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
4659 vc_conn.done;
4660}
Harald Welte68e495b2018-02-25 00:05:57 +01004661
Harald Weltea3f1df92018-02-25 12:49:55 +01004662/* Send IPA CRCX twice to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004663private function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01004664 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4665 "IPA CRCX ACK");
4666 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
4667 "IPA CRCX NACK");
4668}
4669testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
4670 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004671 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01004672 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
4673 vc_conn.done;
4674}
4675
4676/* Regular sequence of CRCX/MDCX/DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004677private function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01004678 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4679 "IPA CRCX ACK");
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02004680 var OCT4 remote_ip := f_rnd_octstring(4);
Harald Weltea3f1df92018-02-25 12:49:55 +01004681 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
4682 var uint7_t rtp_pt2 := f_rnd_int(127);
4683 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
4684 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4685 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4686 "IPA MDCX ACK");
4687 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4688 "IPA DLCX ACK");
4689}
4690testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
4691 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004692 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01004693 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
4694 vc_conn.done;
4695}
4696
Harald Welte3ae11da2018-02-25 13:36:06 +01004697/* Sequence of CRCX, 2x MDCX, DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004698private function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte3ae11da2018-02-25 13:36:06 +01004699 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4700 "IPA CRCX ACK");
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02004701 var OCT4 remote_ip := f_rnd_octstring(4);
Harald Welte3ae11da2018-02-25 13:36:06 +01004702 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
4703 var uint7_t rtp_pt2 := f_rnd_int(127);
4704 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
4705 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4706 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4707 "IPA MDCX ACK");
4708 /* Second MDCX */
Vadim Yanitskiyfc631642021-07-03 02:42:45 +02004709 remote_ip := f_rnd_octstring(4);
Harald Welte3ae11da2018-02-25 13:36:06 +01004710 remote_port := f_rnd_int(c_UINT16_MAX);
4711 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4712 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4713 "IPA MDCX ACK");
4714 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4715 "IPA DLCX ACK");
4716}
4717testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
4718 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004719 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01004720 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
4721 vc_conn.done;
4722}
4723
Harald Welte9912eb52018-02-25 13:30:15 +01004724/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004725private function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
Harald Welte9912eb52018-02-25 13:30:15 +01004726 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
4727 "IPA CRCX NACK");
4728}
4729testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
4730 var ConnHdlrPars pars;
4731 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02004732 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01004733
4734 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
4735 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
4736 vc_conn.done;
4737
4738 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
4739 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
4740 vc_conn.done;
4741}
4742
Harald Weltea3f1df92018-02-25 12:49:55 +01004743
Harald Welte883340c2018-02-28 18:59:29 +01004744/***********************************************************************
4745 * PCU Socket related tests
4746 ***********************************************************************/
4747
Harald Welte07bd2d22019-05-25 11:03:30 +02004748/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004749friend 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 +01004750runs on test_CT {
4751 timer T := 3.0;
4752
4753 /* we don't expect any RTS.req before PDCH are active */
4754 T.start;
4755 alt {
4756 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004757 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01004758 }
4759 [] PCU.receive { repeat; }
4760 [] T.timeout { }
4761 }
4762
4763 /* Send PDCH activate request for known PDCH timeslot */
4764 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
4765
4766 /* we now expect RTS.req for this timeslot (only) */
4767 T.start;
4768 alt {
4769 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
4770 setverdict(pass);
4771 }
4772 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4773 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004774 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01004775 }
4776 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004777 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01004778 }
4779 [] PCU.receive { repeat; }
4780 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004781 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004782 }
4783 [not exp_success] T.timeout {
4784 setverdict(pass);
4785 }
4786 }
4787}
4788
Harald Welte07bd2d22019-05-25 11:03:30 +02004789/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004790friend 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 +01004791runs on test_CT {
4792 timer T := 3.0;
4793
4794 /* Send PDCH activate request for known PDCH timeslot */
4795 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 +02004796 /* wait for some time as there is no PCUIF_DEACT_RESP or the like, so we don't know
4797 * when it will actually have been executed in the BTS */
4798 f_sleep(1.0);
Harald Welte883340c2018-02-28 18:59:29 +01004799 PCU.clear;
4800 /* we now expect no RTS.req for this timeslot */
4801 T.start;
4802 alt {
4803 [] 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 +02004804 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004805 }
4806 [] PCU.receive { repeat; }
4807 [] T.timeout {
4808 setverdict(pass);
4809 }
4810 }
4811}
4812
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004813friend function f_init_with_pcuif() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004814 f_init();
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01004815 map(self:PCU, system:PCU);
4816 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
Max2c6f5632019-03-18 17:25:17 +01004817 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
4818}
4819
Harald Welte883340c2018-02-28 18:59:29 +01004820/* PDCH activation via PCU socket; check for presence of RTS.req */
4821testcase TC_pcu_act_req() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004822 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004823
Harald Welte883340c2018-02-28 18:59:29 +01004824 f_TC_pcu_act_req(0, 0, 7, true);
4825}
4826
4827/* PDCH activation via PCU socket on non-PDCU timeslot */
4828testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004829 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004830
Harald Welte883340c2018-02-28 18:59:29 +01004831 f_TC_pcu_act_req(0, 0, 1, false);
4832}
4833
4834/* PDCH activation via PCU socket on wrong BTS */
4835testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004836 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004837
Harald Welte883340c2018-02-28 18:59:29 +01004838 f_TC_pcu_act_req(23, 0, 7, false);
4839}
4840
4841/* PDCH activation via PCU socket on wrong TRX */
4842testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004843 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004844
Harald Welte883340c2018-02-28 18:59:29 +01004845 f_TC_pcu_act_req(0, 23, 7, false);
4846}
4847
4848/* PDCH deactivation via PCU socket; check for absence of RTS.req */
4849testcase TC_pcu_deact_req() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004850 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004851
Harald Welte883340c2018-02-28 18:59:29 +01004852 /* Activate PDCH */
4853 f_TC_pcu_act_req(0, 0, 7, true);
4854 f_sleep(1.0);
4855 /* and De-Activate again */
4856 f_TC_pcu_deact_req(0, 0, 7);
4857}
4858
4859/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
4860testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004861 f_init_with_pcuif();
Max2c6f5632019-03-18 17:25:17 +01004862
Harald Welte883340c2018-02-28 18:59:29 +01004863 f_TC_pcu_deact_req(0, 0, 1);
4864}
4865
4866/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
Philipp Maier94c08482021-02-01 17:36:05 +01004867function f_TC_pcu_ver_siXX(octetstring si, RSL_IE_SysinfoType rsl_si_type) runs on test_CT {
Harald Welte883340c2018-02-28 18:59:29 +01004868 var PCUIF_send_data sd;
4869 timer T:= 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01004870 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01004871
4872 /* Set SI13 via RSL */
Philipp Maier94c08482021-02-01 17:36:05 +01004873 f_rsl_bcch_fill_raw(rsl_si_type, si);
Max2c6f5632019-03-18 17:25:17 +01004874
Harald Welte883340c2018-02-28 18:59:29 +01004875 T.start;
4876 alt {
4877 [] 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 +01004878 if (substr(sd.data.u.data_ind.data, 0, lengthof(si)) == si) {
Harald Welte883340c2018-02-28 18:59:29 +01004879 setverdict(pass);
4880 } else {
4881 repeat;
4882 }
4883 }
4884 [] PCU.receive { repeat; }
4885 [] T.timeout {
Philipp Maier94c08482021-02-01 17:36:05 +01004886 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI");
Harald Welte883340c2018-02-28 18:59:29 +01004887 }
4888 }
4889}
4890
Philipp Maier94c08482021-02-01 17:36:05 +01004891/* Test the PCU->BTS Version and BTS->PCU SI1 handshake */
4892testcase TC_pcu_ver_si1() runs on test_CT {
4893 const octetstring si1 := '550111132A252B27CC29AA11BB33CC'O;
4894 f_TC_pcu_ver_siXX(si1, RSL_SYSTEM_INFO_1);
4895}
4896
4897/* Test the PCU->BTS Version and BTS->PCU SI3 handshake */
4898testcase TC_pcu_ver_si3() runs on test_CT {
4899 const octetstring si3 := '49012223242526272929AABBCC'O;
4900 f_TC_pcu_ver_siXX(si3, RSL_SYSTEM_INFO_3);
4901}
4902
4903/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
4904testcase TC_pcu_ver_si13() runs on test_CT {
4905 const octetstring si13 := '01010203040506070909'O;
4906 f_TC_pcu_ver_siXX(si13, RSL_SYSTEM_INFO_13);
4907}
4908
Harald Welte883340c2018-02-28 18:59:29 +01004909private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
4910
4911/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02004912friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01004913 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
4914runs on test_CT
4915{
4916 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
4917 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
4918}
4919
4920/* 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 +02004921friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
4922 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01004923runs on test_CT
4924{
4925 var PCUIF_send_data sd;
4926
4927 timer T := 3.0;
4928 T.start;
4929 alt {
4930 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4931 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
4932 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
4933 sd.data.u.rts_req.fn, sapi, data);
4934 }
4935 [] PCU.receive { repeat; }
4936 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004937 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01004938 }
4939 }
4940}
4941
4942/* Send DATA.req on invalid BTS */
4943testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004944 var TfiUsfArr tua := f_TfiUsfArrInit();
4945 var octetstring data := '0000'O & f_rnd_octstring(21);
4946
4947 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004948
Harald Welte883340c2018-02-28 18:59:29 +01004949 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004950 f_TfiUsfArrSet(tua, 7, 0);
4951 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4952 f_sleep(1.0);
4953
4954 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004955}
4956
4957/* Send DATA.req on invalid TRX */
4958testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004959 var TfiUsfArr tua := f_TfiUsfArrInit();
4960 var octetstring data := '0000'O & f_rnd_octstring(21);
4961
4962 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004963
Harald Welte883340c2018-02-28 18:59:29 +01004964 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004965 f_TfiUsfArrSet(tua, 7, 0);
4966 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4967 f_sleep(1.0);
4968
4969 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004970}
4971
4972/* Send DATA.req on invalid timeslot */
4973testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004974 var TfiUsfArr tua := f_TfiUsfArrInit();
4975 var octetstring data := '0000'O & f_rnd_octstring(21);
4976
4977 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004978
Harald Welte883340c2018-02-28 18:59:29 +01004979 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004980 f_TfiUsfArrSet(tua, 7, 0);
4981 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4982 f_sleep(1.0);
4983
4984 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004985}
4986
4987/* Send DATA.req on timeslot that hasn't been activated */
4988testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004989 var TfiUsfArr tua := f_TfiUsfArrInit();
4990 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01004991
Harald Welte7162a612019-05-26 12:56:09 +02004992 f_virtphy_common();
4993
4994 f_TfiUsfArrSet(tua, 7, 0);
4995 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4996 f_sleep(1.0);
4997
4998 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004999}
5000
Harald Weltead033dc2019-05-25 17:28:16 +02005001private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02005002 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
5003 boolean wait_rts := true)
5004runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02005005 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02005006 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02005007
5008 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02005009 if (wait_rts) {
5010 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
5011 } else {
5012 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
5013 }
Harald Weltead033dc2019-05-25 17:28:16 +02005014
5015 T.start;
5016 alt {
Harald Welte7162a612019-05-26 12:56:09 +02005017 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02005018 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
5019 setverdict(pass);
5020 }
Harald Welte7162a612019-05-26 12:56:09 +02005021 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
5022 setverdict(fail, "Received unexpected ", rx_dl);
5023 }
Harald Weltead033dc2019-05-25 17:28:16 +02005024 [] L1CTL.receive {
5025 repeat;
5026 }
Harald Welte7162a612019-05-26 12:56:09 +02005027 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02005028 setverdict(fail, "Timeout waiting for ", data);
5029 }
Harald Welte7162a612019-05-26 12:56:09 +02005030 [not expect_data] T.timeout {
5031 setverdict(pass);
5032 }
Harald Weltead033dc2019-05-25 17:28:16 +02005033 }
5034}
5035
5036private function f_disable_dynamic_ts() runs on test_CT
5037{
5038 f_init_vty_bsc();
5039 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
5040 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
5041 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
5042 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005043 f_init_with_pcuif();
Harald Weltead033dc2019-05-25 17:28:16 +02005044}
5045
5046private function f_virtphy_common() runs on test_CT {
5047 f_disable_dynamic_ts();
5048 f_init_l1ctl();
5049 f_l1_tune(L1CTL);
5050}
5051
5052testcase TC_pcu_data_req_pdtch() runs on test_CT {
5053 var TfiUsfArr tua := f_TfiUsfArrInit();
5054 var octetstring data := '0000'O & f_rnd_octstring(21);
5055
5056 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005057
Harald Welte883340c2018-02-28 18:59:29 +01005058 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02005059 f_TfiUsfArrSet(tua, 7, 0);
5060 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5061 f_sleep(1.0);
5062
5063 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01005064}
5065
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005066/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01005067testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02005068 var TfiUsfArr tua := f_TfiUsfArrInit();
5069 var octetstring data := '0000'O & f_rnd_octstring(21);
5070
5071 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01005072
Harald Welte883340c2018-02-28 18:59:29 +01005073 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02005074 f_TfiUsfArrSet(tua, 7, 0);
5075 f_L1CTL_TBF_CFG(L1CTL, false, tua);
5076 f_sleep(1.0);
5077
5078 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01005079}
5080
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005081private function f_TC_pcu_ptcch_ul(uint16_t ra)
5082runs on test_CT {
5083 var template PCUIF_Message pcu_rach_ind;
5084 var PCUIF_send_data sd;
5085 var GsmFrameNumber fn;
5086 timer T;
5087
5088 /* Send an Access Burst on PTCCH/U over the Um-interface */
5089 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
5090 chan_nr := ts_RslChanNr_PDCH(7),
5091 link_id := ts_RslLinkID_OSMO_PTCCH(0));
5092
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005093 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
5094 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005095
5096 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
5097 T.start(52.0 * 4.615 / 1000.0);
5098 alt {
5099 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
5100 log("Rx an Access Burst on the PCU interface: ", sd.data);
5101 setverdict(pass);
5102 T.stop;
5103 }
5104 [] PCU.receive { repeat; }
5105 [] T.timeout {
5106 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
5107 /* Keep going, that's not the end of the world */
5108 }
5109 }
5110}
5111
5112testcase TC_pcu_ptcch() runs on test_CT {
5113 var L1ctlDlMessage dl;
5114 var octetstring data;
5115 timer T;
5116
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005117 f_init_with_pcuif();
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005118 f_init_l1ctl();
5119 f_l1_tune(L1CTL);
5120
5121 /* Activate PDCH channel on TS7 */
5122 f_TC_pcu_act_req(0, 0, 7, true);
5123
5124 /* Tune trxcon to that PDCH channel */
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005125 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiy13a29d52020-07-15 14:41:54 +07005126 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005127 { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); }
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005128 f_l1ctl_est_dchan(L1CTL, pars);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07005129
5130 /* Verify PTCCH/U: send several access bursts, make sure they're received */
5131 for (var integer i := 0; i < 16; i := i + 1) {
5132 log("Sending an Access Burst towards the L1CTL interface");
5133 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
5134 }
5135
5136 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
5137 data := f_rnd_octstring(23);
5138
5139 /* Verify PTCCH/D: send a random data block, make sure it's received */
5140 log("Sending a PTCCH/D block towards the PCU interface: ", data);
5141 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
5142
5143 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
5144 * let's give it more time in case if we miss the beginning. */
5145 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
5146 alt {
5147 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
5148 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
5149 link_id := tr_RslLinkID_OSMO_PTCCH(?),
5150 frame := data)) -> value dl {
5151 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
5152 setverdict(pass);
5153 T.stop;
5154 }
5155 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
5156 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
5157 link_id := tr_RslLinkID_OSMO_PTCCH(?),
5158 l2_data := data)) -> value dl {
5159 log("Rx PTCCH/D data block on L1CTL: ", dl);
5160 setverdict(pass);
5161 T.stop;
5162 }
5163 [] L1CTL.receive { repeat; }
5164 [] T.timeout {
5165 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
5166 }
5167 }
5168}
5169
Harald Welte883340c2018-02-28 18:59:29 +01005170/* Send AGCH from PCU; check it appears on Um side */
5171testcase TC_pcu_data_req_agch() runs on test_CT {
5172 timer T := 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005173 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005174 f_init_l1ctl();
5175 f_l1_tune(L1CTL);
5176
5177 f_TC_pcu_act_req(0, 0, 7, true);
5178 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
5179
5180 T.start;
5181 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01005182 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01005183 setverdict(pass);
5184 }
5185 [] L1CTL.receive { repeat; }
5186 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005187 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01005188 }
5189 }
5190}
5191
Harald Welte928622b2019-05-26 13:22:59 +02005192/* Send AGCH from PCU; check it appears on Um side */
5193testcase TC_pcu_data_req_pch() runs on test_CT {
5194 timer T := 3.0;
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005195 f_init_with_pcuif();
Harald Welte928622b2019-05-26 13:22:59 +02005196 f_init_l1ctl();
5197 f_l1_tune(L1CTL);
5198
5199 f_TC_pcu_act_req(0, 0, 7, true);
5200 /* three characters prefix: last 3 digits of IMSI as ASCII */
5201 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
5202
5203 T.start;
5204 alt {
5205 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
5206 setverdict(pass);
5207 }
5208 [] L1CTL.receive { repeat; }
5209 [] T.timeout {
5210 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
5211 }
5212 }
5213}
5214
Harald Welte883340c2018-02-28 18:59:29 +01005215/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
5216testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
5217 var octetstring imm_ass := f_rnd_octstring(23);
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005218 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005219 f_init_l1ctl();
5220 f_l1_tune(L1CTL);
5221
5222 /* append 3 last imsi digits so BTS can compute pagng group */
5223 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
5224
5225 timer T := 0.5;
5226 T.start;
5227 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01005228 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01005229 /* TODO: verify paging group */
5230 setverdict(pass);
5231 }
5232 [] L1CTL.receive { repeat; }
5233 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01005235 }
5236 }
5237}
5238
5239/* Send RACH from Um side, expect it to show up on PCU socket */
5240testcase TC_pcu_rach_content() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005241 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005242 f_init_l1ctl();
5243 f_l1_tune(L1CTL);
5244
5245 var GsmFrameNumber fn_last := 0;
5246 for (var integer i := 0; i < 1000; i := i+1) {
5247 var OCT1 ra := f_rnd_ra_ps();
5248 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
5249 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005250 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01005251 }
5252 fn_last := fn;
5253
5254 timer T := 2.0;
5255 T.start;
5256 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005257 [] 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 +01005258 T.stop;
5259 }
5260 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005261 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01005262 }
5263 [] PCU.receive { repeat; }
5264 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005265 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01005266 }
5267 }
5268 }
5269 setverdict(pass);
5270}
5271
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005272/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
5273 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
5274testcase TC_pcu_ext_rach_content() runs on test_CT {
5275 var template PCUIF_Message pcu_rach_ind;
5276 var GsmFrameNumber fn_last := 0;
5277 var L1ctlRachSynchSeq synch_seq;
5278 var PCUIF_BurstType pcu_bt;
5279 var GsmFrameNumber fn;
5280 var BIT11 ra11;
5281
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005282 f_init_with_pcuif();
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005283 f_init_l1ctl();
5284 f_l1_tune(L1CTL);
5285
5286 for (var integer i := 0; i < 1000; i := i+1) {
5287 /* We need to test both TS1 & TS2 */
5288 if (i rem 2 == 0) {
5289 synch_seq := RACH_SYNCH_SEQ_TS1;
5290 pcu_bt := BURST_TYPE_1;
5291 } else {
5292 synch_seq := RACH_SYNCH_SEQ_TS2;
5293 pcu_bt := BURST_TYPE_2;
5294 }
5295
5296 ra11 := f_rnd_ra11_ps();
5297 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
5298 if (fn == fn_last) {
5299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5300 "Two RACH in same FN?!?");
5301 }
5302 fn_last := fn;
5303
5304 /* Compose the expected message */
5305 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07005306 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005307 ra := bit2int(ra11),
5308 is_11bit := 1,
5309 burst_type := pcu_bt,
5310 fn := fn);
5311
5312 timer T := 2.0;
5313 T.start;
5314 alt {
5315 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
5316 T.stop;
5317 }
5318 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
5319 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
5320 }
5321 [] PCU.receive { repeat; }
5322 [] T.timeout {
5323 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
5324 }
5325 }
5326 }
5327 setverdict(pass);
5328}
5329
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005330private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
5331runs on test_CT {
5332 var template PCUIF_send_data sdt;
5333 var PCUIF_send_data sd;
5334 var int16_t lqual_cb;
5335 timer T := 1.0;
5336
5337 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
5338 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
5339
5340 /* Send a random PDTCH frame over Um */
5341 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
5342 '0000'O & f_rnd_octstring(21)));
5343
5344 T.start;
5345 alt {
5346 /* If expected link quality is above the threshold */
5347 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
5348 lqual_cb := sd.data.u.data_ind.lqual_cb;
5349 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
5350
5351 /* Make sure the actual link quality matches the expected value */
5352 if (not match(lqual_cb, lqual_cb_exp)) {
5353 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
5354 "expected value ", lqual_cb_exp));
5355 } else {
5356 setverdict(pass);
5357 }
5358 }
5359 /* If expected link quality is below the threshold */
5360 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
5361 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5362 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
5363 }
5364 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
5365 [] PCU.receive { repeat; }
5366 [lqual_cb_exp < thresh] T.timeout {
5367 log("Rx nothing, as expected");
5368 setverdict(pass);
5369 }
5370 [lqual_cb_exp >= thresh] T.timeout {
5371 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5372 "Timeout waiting for PCUIF_DATA.ind");
5373 }
5374 }
5375}
5376
5377/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
5378testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005379 f_init_with_pcuif();
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005380 PCU.clear;
5381
5382 f_init_l1ctl();
5383 f_l1_tune(L1CTL);
5384
5385 /* Activate a PDCH channel on TS7 */
5386 f_TC_pcu_act_req(0, 0, 7, true);
5387
5388 /* Tune trxcon to that PDCH channel on TS7 */
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005389 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_PDCH(7), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiy13a29d52020-07-15 14:41:54 +07005390 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005391 { f_resolve_fh_params(pars.fhp, pars.chan_nr.tn); }
Vadim Yanitskiy1d55dee2020-07-14 21:19:09 +07005392 f_l1ctl_est_dchan(L1CTL, pars);
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005393
5394 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
5395 for (var int16_t i := -256; i <= 1280; i := i + 128) {
5396 var TrxcMessage ret;
5397
Vadim Yanitskiy418066a2021-10-03 14:04:17 +06005398 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, ts_TRXC_FAKE_CI(i));
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07005399
5400 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
5401 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
5402 }
5403}
5404
Harald Welte883340c2018-02-28 18:59:29 +01005405/* Send PAGING via RSL, expect it to shw up on PCU socket */
5406testcase TC_pcu_paging_from_rsl() runs on test_CT {
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005407 f_init_with_pcuif();
Harald Welte883340c2018-02-28 18:59:29 +01005408
5409 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005410 var MobileIdentityLV mi_lv;
5411 var octetstring mi_lv_enc;
5412 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01005413 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005414
Harald Welte883340c2018-02-28 18:59:29 +01005415 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005416 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01005417 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005418 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01005419 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005420
5421 /* Fancy encoding for PCUIF */
5422 mi_lv := valueof(ts_MI_LV(mi));
5423 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
5424 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01005425
5426 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07005427 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01005428 T.start;
5429 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07005430 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01005431 }
5432 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005433 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01005434 }
5435 [] PCU.receive { repeat; }
5436 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005437 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01005438 }
5439 }
5440 }
5441 setverdict(pass);
5442}
5443
Harald Welted66c9b82019-05-25 09:03:15 +02005444/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
5445testcase TC_pcu_time_ind() runs on test_CT {
5446 var PCUIF_send_data pcu_sd;
5447 var integer num_time_ind := 0;
5448 var integer first_fn, last_fn;
5449 var float test_duration := 5.0;
5450 timer T;
5451
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005452 f_init_with_pcuif();
Harald Welted66c9b82019-05-25 09:03:15 +02005453 f_TC_pcu_act_req(0, 0, 7, true);
5454
5455 PCU.clear;
5456 T.start(test_duration);
5457 alt {
5458 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
5459 num_time_ind := num_time_ind + 1;
5460 if (not isbound(first_fn)) {
5461 first_fn := pcu_sd.data.u.time_ind.fn;
5462 }
5463 last_fn := pcu_sd.data.u.time_ind.fn;
5464 repeat;
5465 }
5466 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
5467 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
5468 repeat;
5469 }
5470 [] PCU.receive {
5471 repeat;
5472 }
5473 [] T.timeout {}
5474 }
5475 var integer fn_expired := last_fn - first_fn;
5476 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
5477
5478 /* verify the number of frames expired matches our expectation */
5479 const float c_GSM_FN_DURATION_MS := 4.61538;
5480 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02005481 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02005482 if (not match(fn_expired, t_fn_expected)) {
5483 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
5484 }
5485
5486 /* There are three TIME.ind in every fn MOD 13 */
5487 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
5488 /* Add some tolerance */
5489 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
5490 if (not match(num_time_ind, t_time_ind_exp)) {
5491 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
5492 }
5493
5494 setverdict(pass);
5495}
5496
Harald Welte4832c862019-05-25 14:57:18 +02005497/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
5498testcase TC_pcu_rts_req() runs on test_CT {
5499 var PCUIF_send_data pcu_sd;
5500 var integer first_fn, last_fn;
5501 var integer num_rts_pdtch := 0;
5502 var integer num_rts_ptcch := 0;
5503 var float test_duration := 5.0;
5504 timer T;
5505
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005506 f_init_with_pcuif();
Harald Welte4832c862019-05-25 14:57:18 +02005507 f_TC_pcu_act_req(0, 0, 7, true);
5508
5509 PCU.clear;
5510 T.start(test_duration);
5511 alt {
5512 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
5513 -> value pcu_sd {
5514 num_rts_pdtch := num_rts_pdtch + 1;
5515 if (not isbound(first_fn)) {
5516 first_fn := pcu_sd.data.u.rts_req.fn;
5517 }
5518 last_fn := pcu_sd.data.u.rts_req.fn;
5519 repeat;
5520 }
5521 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
5522 -> value pcu_sd {
5523 num_rts_ptcch := num_rts_ptcch + 1;
5524 if (not isbound(first_fn)) {
5525 first_fn := pcu_sd.data.u.rts_req.fn;
5526 }
5527 last_fn := pcu_sd.data.u.rts_req.fn;
5528 repeat;
5529 }
5530 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
5531 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
5532 repeat;
5533 }
5534 [] PCU.receive {
5535 repeat;
5536 }
5537 [] T.timeout {}
5538 }
5539 var integer fn_expired := last_fn - first_fn;
5540 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
5541 ", num_rts_ptcch=", num_rts_ptcch);
5542
5543 /* verify the number of frames expired matches our expectation */
5544 const float c_GSM_FN_DURATION_MS := 4.61538;
5545 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02005546 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02005547 if (not match(fn_expired, t_fn_expected)) {
5548 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
5549 }
5550
5551 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
5552 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
5553 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
5554 if (not match(num_rts_ptcch, t_ptcch_exp)) {
5555 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
5556 t_ptcch_exp);
5557 }
5558
5559 /* We have 12 PDTCH blocks every 52-multiframe */
5560 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
5561 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
5562 if (not match(num_rts_pdtch, t_pdtch_exp)) {
5563 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
5564 t_pdtch_exp);
5565 }
5566
5567 setverdict(pass);
5568}
5569
Harald Welte07bd2d22019-05-25 11:03:30 +02005570/* test for generating Abis side OML ALERT from the PCU */
5571testcase TC_pcu_oml_alert() runs on test_CT {
5572 var PCUIF_send_data pcu_sd;
5573 var integer num_time_ind := 0;
5574 var integer first_fn, last_fn;
5575 var float test_duration := 5.0;
5576 timer T;
5577
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005578 f_init_with_pcuif();
Harald Welte07bd2d22019-05-25 11:03:30 +02005579 f_TC_pcu_act_req(0, 0, 7, true);
5580
5581 /* re-connect CTRL port from BTS to BSC */
5582 f_ipa_ctrl_stop();
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01005583 f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
Harald Welte07bd2d22019-05-25 11:03:30 +02005584
5585 /* Send that OML Alert */
5586 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
5587
5588 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
5589 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
5590 setverdict(pass);
5591}
5592
Harald Welteeaa9a862019-05-26 23:01:08 +02005593/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
5594private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
5595 var PCUIF_Message first_info;
5596 var integer pcu_conn_id := -1;
5597 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5598 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
5599 var OCT4 tlli := '01020304'O;
5600 var OCT1 cause := '23'O;
5601 timer T := 5.0;
5602
5603 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5604
5605 f_l1_tune(L1CTL);
5606 RSL.clear;
5607
5608 f_est_dchan();
5609 L1CTL.clear;
5610
5611 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
5612
5613 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
5614 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
5615 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
5616
5617 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
5618 T.start;
5619 alt {
5620 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
5621 setverdict(pass);
5622 }
5623 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
5624 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
5625 }
5626 [] PCU.receive {
5627 repeat;
5628 }
5629 [] T.timeout {
5630 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
5631 }
5632 }
Alexander Couzensa0634832019-06-07 00:28:56 +02005633
5634 /* release the channel */
5635 f_rsl_chan_deact();
5636 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5637 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02005638}
5639testcase TC_pcu_rr_suspend() runs on test_CT {
5640 var ConnHdlrPars pars;
5641 var ConnHdlr vc_conn;
5642
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005643 f_init_with_pcuif();
Harald Welteeaa9a862019-05-26 23:01:08 +02005644
5645 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
5646 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
5647 vc_conn.done;
5648}
Harald Welte07bd2d22019-05-25 11:03:30 +02005649
Harald Weltea2e0e942019-05-27 18:12:53 +02005650/* Ensure that PCUIF socket can accept only a single connection */
5651testcase TC_pcu_socket_connect_multi() runs on test_CT {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005652 var boolean connected := false;
5653 var UD_connect_result cr;
5654 var integer cid;
Harald Weltea2e0e942019-05-27 18:12:53 +02005655 timer T := 5.0;
5656
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005657 var template UD_Result tr_ok := { result_code := SUCCESS, err := omit };
5658 var template UD_Result tr_err := { result_code := ERROR, err := ? };
5659
Harald Weltea2e0e942019-05-27 18:12:53 +02005660 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005661 f_init_with_pcuif();
Harald Weltea2e0e942019-05-27 18:12:53 +02005662
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005663 /* try to establish a second connection */
Harald Weltea2e0e942019-05-27 18:12:53 +02005664 PCU.send(UD_connect:{mp_pcu_socket, -1});
5665 T.start;
5666 alt {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005667 /* the IUT will first accept() the new connection, and close() it immediately */
5668 [not connected] PCU.receive(UD_connect_result:{ id := ?, result := tr_ok }) -> value cr {
5669 log("BTS has accept()ed connection");
5670 connected := true;
5671 cid := cr.id;
5672 repeat;
5673 }
5674 [connected] PCU.receive(UD_connect_result:{ id := cid, result := tr_err }) {
5675 log("BTS has close()d connection");
Harald Weltea2e0e942019-05-27 18:12:53 +02005676 setverdict(pass);
5677 }
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005678 /* ignore other messages related to the first connection */
5679 [] PCU.receive { repeat; }
Harald Weltea2e0e942019-05-27 18:12:53 +02005680 [] T.timeout {
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005681 setverdict(fail, "Timeout waiting for connection result");
Harald Weltea2e0e942019-05-27 18:12:53 +02005682 }
5683 }
Vadim Yanitskiy94bbe992021-03-23 07:23:34 +01005684
Harald Weltea2e0e942019-05-27 18:12:53 +02005685 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5686}
5687
Harald Weltec8effb72019-05-27 18:23:04 +02005688/* Ensure that PCUIF socket can disconnect + reconnect */
5689testcase TC_pcu_socket_reconnect() runs on test_CT {
5690 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005691 f_init_with_pcuif();
Harald Weltec8effb72019-05-27 18:23:04 +02005692
5693 f_sleep(1.0);
5694
5695 f_pcuif_close(PCU, g_pcu_conn_id);
5696 g_pcu_conn_id := -1;
5697
5698 f_sleep(1.0);
5699
5700 /* re-connect */
5701 PCU.clear;
5702 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5703 setverdict(pass);
5704
5705 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5706}
5707
Harald Weltebe030482019-05-27 22:29:35 +02005708/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005709private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
5710runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02005711 var L1ctlDlMessage l1_dl;
5712 var SystemInformation si;
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07005713 var integer rc;
Harald Weltebe030482019-05-27 22:29:35 +02005714 timer T := 5.0;
5715 T.start;
5716 alt {
5717 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Vadim Yanitskiycb478ec2020-07-11 02:37:17 +07005718 rc := dec_SystemInformationSafe(l1_dl.payload.data_ind.payload, si);
5719 if (rc != 0 or si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02005720 repeat;
5721 }
5722 }
5723 [] pt.receive {
5724 repeat;
5725 }
5726 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005727 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5728 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02005729 }
5730 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005731 return si;
Harald Weltebe030482019-05-27 22:29:35 +02005732}
5733
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005734/* Check if GPRS Indicator is present in RR System Information of a given type */
5735private function f_si_has_gprs_indicator(RrMessageType si_type)
5736runs on test_CT return boolean {
5737 var SystemInformation si := f_get_si(L1CTL, si_type);
5738
5739 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +02005740 return si.payload.si3.rest_octets.gprs_ind.presence == '1'B;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005741 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
Neels Hofmeyra5f0ed22020-07-06 02:39:40 +02005742 return si.payload.si4.rest_octets.gprs_ind.presence == '1'B;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005743 }
5744
5745 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
5746 return false;
Harald Weltebe030482019-05-27 22:29:35 +02005747}
5748
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005749/* Make sure that GPRS Indicator is absent when the PCU is not connected */
5750private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
5751runs on test_CT {
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005752 f_init();
Harald Weltebe030482019-05-27 22:29:35 +02005753 f_init_l1ctl();
5754 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02005755 f_sleep(2.0);
5756 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005757
5758 if (f_si_has_gprs_indicator(si_type)) {
5759 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02005760 } else {
5761 setverdict(pass);
5762 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005763
Harald Weltebe030482019-05-27 22:29:35 +02005764 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5765}
5766
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005767testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
5768 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
5769}
Harald Weltebe030482019-05-27 22:29:35 +02005770
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005771testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
5772 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
5773}
5774
5775/* Ensure that GPRS capability is advertised after PCU socket connect */
5776private function f_TC_pcu_socket_connect(RrMessageType si_type)
5777runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005778 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005779 f_init_with_pcuif();
Harald Weltebe030482019-05-27 22:29:35 +02005780 f_init_l1ctl();
5781 f_l1_tune(L1CTL);
5782
5783 f_sleep(2.0);
5784 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005785
5786 if (not f_si_has_gprs_indicator(si_type)) {
5787 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02005788 } else {
5789 setverdict(pass);
5790 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005791
Harald Weltebe030482019-05-27 22:29:35 +02005792 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5793}
5794
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005795testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
5796 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
5797}
Harald Weltebe030482019-05-27 22:29:35 +02005798
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005799testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
5800 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
5801}
5802
5803/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
5804private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
5805runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005806 /* this (among other things) establishes the first connection to the PCUIF socket */
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005807 f_init_with_pcuif();
Harald Weltebe030482019-05-27 22:29:35 +02005808 f_init_l1ctl();
5809 f_l1_tune(L1CTL);
5810
5811 f_pcuif_close(PCU, g_pcu_conn_id);
5812 g_pcu_conn_id := -1;
5813
5814 f_sleep(1.0);
5815
5816 /* re-connect */
5817 PCU.clear;
5818 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5819
5820 f_sleep(2.0);
5821 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005822
5823 if (f_si_has_gprs_indicator(si_type)) {
5824 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02005825 } else {
5826 setverdict(pass);
5827 }
5828
5829 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5830}
5831
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005832testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
5833 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
5834}
5835
5836testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
5837 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
5838}
5839
Oliver Smithf5239c72019-08-28 10:01:25 +02005840/* 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) */
5841testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
5842 var SystemInformation si3 := valueof(ts_SI3_default);
5843
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005844 f_init_with_pcuif();
Oliver Smithf5239c72019-08-28 10:01:25 +02005845
Harald Welte76220222020-10-11 20:32:44 +02005846 /* actually give the BTS some time to fully come up and to send a PCU INFO IND with the correct
5847 * information */
5848 timer T := 2.0;
5849 T.start;
5850 alt {
5851 [] as_pcu_info_ind(PCU, g_pcu_conn_id, g_pcu_last_info) { repeat; }
5852 [] T.timeout {}
5853 }
5854
Oliver Smithf5239c72019-08-28 10:01:25 +02005855 /* Verify cell_id */
5856 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
5857 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
5858 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02005859 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
5860 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
5861 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02005862 }
5863
5864 /* Verify LAC */
5865 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
5866 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
5867 if (lac_si3 != lac_pcu) {
5868 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
5869 }
5870
5871 setverdict(pass);
5872}
Harald Welted66c9b82019-05-25 09:03:15 +02005873
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005874/* Verify hopping parameters in the INFO.ind message (version >= 10) */
5875testcase TC_pcu_info_ind_fh_params() runs on test_CT {
5876 var PCUIF_info_ind info_ind;
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005877 var FreqHopPars fhp;
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005878
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005879 f_init_with_pcuif();
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005880
5881 info_ind := g_pcu_last_info.u.info_ind;
5882
5883 for (var integer i := 0; i < mp_transceiver_num; i := i + 1) {
5884 for (var integer tn := 0; tn < 8; tn := tn + 1) {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005885 if (info_ind.trx[i].pdch_mask[tn] != '1'B) {
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005886 /* Skip inactive timeslots */
5887 continue;
5888 }
5889
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005890 if (mp_freq_hop_enabled and mp_transceiver_num > 1)
Vadim Yanitskiy7e1d0a22020-09-17 19:48:11 +07005891 { f_resolve_fh_params(fhp, tn, trx_nr := i); }
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005892 else
5893 { fhp.enabled := false; }
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005894
5895 var template PCUIF_InfoTrxTs tr_ts;
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005896 if (fhp.enabled) {
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005897 tr_ts := tr_PCUIF_InfoTrxTsH1(
Vadim Yanitskiyca813922020-09-12 19:08:31 +07005898 hsn := fhp.maio_hsn.hsn,
5899 maio := fhp.maio_hsn.maio,
5900 ma := f_pad_bit(fhp.ma_map.ma, 64, '0'B),
Vadim Yanitskiyaa553ed2020-09-17 19:44:32 +07005901 ma_bit_len := mp_transceiver_num);
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005902 } else {
5903 tr_ts := tr_PCUIF_InfoTrxTsH0;
5904 }
5905
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005906 var PCUIF_InfoTrxTs ts := info_ind.trx[i].ts[tn];
Vadim Yanitskiy7faef072020-08-03 04:22:04 +07005907 log("Checking timeslot #", tn, " of trx#", i, ": ", ts);
5908 if (not match(ts, tr_ts)) {
5909 setverdict(fail, "Hopping parameters do not match: ",
5910 "received ", ts, " vs expected ", tr_ts);
5911 } else {
5912 setverdict(pass);
5913 }
5914 }
5915 }
5916}
5917
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005918/* Verify IPv4 NSVC address in the INFO.ind message */
Alexander Couzens5283f552020-07-28 15:39:04 +02005919testcase TC_pcu_socket_nsvc_ipv4() runs on test_CT {
5920 f_init_vty_bsc();
5921 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127");
5922 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5923
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005924 f_init_with_pcuif();
Alexander Couzens5283f552020-07-28 15:39:04 +02005925
5926 var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr;
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005927 var template PCUIF_RemoteAddr tr_remote_addr := {
5928 addr_type := { PCUIF_ADDR_TYPE_IPV4, ? },
Vadim Yanitskiy216021a2021-03-24 15:51:06 +01005929 addr := { f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O), ? }
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005930 };
Alexander Couzens5283f552020-07-28 15:39:04 +02005931
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005932 if (not match(remote_addr, tr_remote_addr)) {
5933 setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr);
Alexander Couzens5283f552020-07-28 15:39:04 +02005934 }
5935
5936 setverdict(pass);
5937}
5938
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005939/* Verify IPv4 NSVC address in the INFO.ind message */
Alexander Couzens5283f552020-07-28 15:39:04 +02005940testcase TC_pcu_socket_nsvc_ipv6() runs on test_CT {
5941 f_init_vty_bsc();
5942 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip fd00::ca:ff:ee");
5943
Vadim Yanitskiyec9e9812021-03-21 23:02:44 +01005944 f_init_with_pcuif();
Alexander Couzens5283f552020-07-28 15:39:04 +02005945
5946 var PCUIF_RemoteAddr remote_addr := g_pcu_last_info.u.info_ind.remote_addr;
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005947 var template PCUIF_RemoteAddr tr_remote_addr := {
5948 addr_type := { PCUIF_ADDR_TYPE_IPV6, ? },
5949 addr := { f_inet6_addr("fd00::ca:ff:ee"), ? }
5950 };
Alexander Couzens5283f552020-07-28 15:39:04 +02005951
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01005952 if (not match(remote_addr, tr_remote_addr)) {
5953 setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr);
Alexander Couzens5283f552020-07-28 15:39:04 +02005954 }
5955
5956 setverdict(pass);
5957}
5958
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01005959/* Verify coding of two NSVCs in the INFO.ind message */
5960testcase TC_pcu_socket_two_nsvc() runs on test_CT {
5961 f_init_vty_bsc();
5962
5963 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 nsvci 1234");
5964 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 local udp port 1234");
5965 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote ip 127.127.127.127");
5966 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 0 remote udp port 1234");
5967
5968 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 nsvci 5678");
5969 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 local udp port 5678");
5970 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote ip fd00::ca:ff:ee");
5971 f_vty_config2(BSCVTY, {"network", "bts 0"} , "gprs nsvc 1 remote udp port 5678");
5972
Vadim Yanitskiyc1981b72021-03-23 03:01:49 +01005973 f_init_with_pcuif();
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01005974
5975 var PCUIF_info_ind info_ind := g_pcu_last_info.u.info_ind;
5976 var PCUIF_RemoteAddr remote_addr := info_ind.remote_addr;
5977 var template PCUIF_RemoteAddr tr_remote_addr := {
5978 addr_type := { PCUIF_ADDR_TYPE_IPV4, PCUIF_ADDR_TYPE_IPV6 },
Vadim Yanitskiy216021a2021-03-24 15:51:06 +01005979 addr := {
5980 f_pad_oct(f_inet_addr("127.127.127.127"), 16, '00'O),
5981 f_inet6_addr("fd00::ca:ff:ee")
5982 }
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01005983 };
5984
5985 if (not match(info_ind.nsvci, { 1234, 5678 }))
5986 { setverdict(fail, "NSVCI ", info_ind.nsvci, " does not match { 1234, 5678 }"); }
5987 if (not match(remote_addr, tr_remote_addr))
5988 { setverdict(fail, "NSVC address ", remote_addr, " does not match ", tr_remote_addr); }
5989 if (not match(info_ind.local_port, { 1234, 5678 }))
5990 { setverdict(fail, "NSVC lport ", info_ind.local_port, " does not match { 1234, 5678 }"); }
5991 if (not match(info_ind.remote_port, { 1234, 5678 }))
5992 { setverdict(fail, "NSVC rport ", info_ind.remote_port, " does not match { 1234, 5678 }"); }
5993
5994 setverdict(pass);
5995}
5996
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02005997/* Verify periodic interference reports on PDCH */
5998testcase TC_pcu_interf_ind() runs on test_CT {
5999 var template PCUIF_Message tr_interf_ind;
6000 var template PCUIF_interf ts_interf;
6001 var integer interf_ind_num := 0;
6002 var PCUIF_send_data sd;
6003 timer T;
6004
6005 f_init_with_pcuif();
6006 f_TC_pcu_act_req(0, 0, 7, true);
6007
6008 /* We need trxcon for NOPE indications */
6009 f_init_l1ctl();
6010 f_l1_tune(L1CTL);
6011
6012 /* Expect -120 .. -90 dBm on TS7 of BTS0/TRX0 */
6013 ts_interf := { 0, 0, 0, 0, 0, 0, 0, (90..120) };
6014 tr_interf_ind := tr_PCUIF_INTERF_IND(
6015 bts_nr := 0,
6016 trx_nr := 0,
6017 fn := ?,
6018 interf := ts_interf
6019 );
6020
6021 /* 4 SACCH periods => 4 reports (plus some guard time) */
6022 var float Tval := int2float(4 * 480) / 1000.0 + 0.5;
6023
6024 /* Let it some time to stabilize */
6025 f_sleep(0.5);
6026 PCU.clear;
6027
6028 T.start(Tval);
6029 alt {
6030 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_interf_ind)) -> value sd {
6031 /* Check TDMA frame number period */
6032 if (sd.data.u.interf_ind.fn mod 104 != 0) {
6033 setverdict(fail, "Odd TDMA frame number := ",
6034 sd.data.u.interf_ind.fn);
6035 }
6036 interf_ind_num := interf_ind_num + 1;
6037 if (interf_ind_num < 4)
6038 { repeat; }
6039 }
6040 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_INTERF_IND(0, 0))) -> value sd {
6041 setverdict(fail, "Received unexpected interference report: ", sd.data);
6042 }
6043 [] PCU.receive { repeat; }
6044 [] T.timeout {
6045 setverdict(fail, "Timeout waiting for interference reports");
6046 }
6047 }
6048
6049 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
6050}
6051
Harald Welte3d04ae62018-04-04 20:29:05 +02006052/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02006053 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02006054 ***********************************************************************/
6055
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006056private altstep as_pcuif_check_pdch_mask(integer pcu_conn_id, BIT1 exp,
6057 integer bts_nr, integer trx_nr)
Harald Welte3d04ae62018-04-04 20:29:05 +02006058runs on ConnHdlr {
6059 var PCUIF_send_data sd;
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006060
6061 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01006062 var BIT8 pdch_mask := sd.data.u.info_ind.trx[trx_nr].pdch_mask;
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006063 if (substr(pdch_mask, g_chan_nr.tn, 1) != exp) {
6064 repeat;
6065 }
6066 }
6067}
6068
6069private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6070runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006071 /* Expect BTS to immediately acknowledge activation as PDCH */
6072 PCU.clear;
6073 f_rsl_chan_act(g_pars.chan_mode);
6074 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006075 timer T_wait := 2.0;
6076 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02006077 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006078 [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr);
Harald Welte3d04ae62018-04-04 20:29:05 +02006079 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006080 [] T_wait.timeout {
6081 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6082 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
6083 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006084 }
6085 /* try to activate this PDCH from the PCU point of view */
6086 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6087 /* FIXME: is there a response? */
6088}
6089
6090private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6091runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006092 /* Send RSL CHAN REL (deactivate) */
6093 PCU.clear;
6094 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
6095 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006096 timer T_wait := 2.0;
6097 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02006098 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006099 [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr);
Harald Welte3d04ae62018-04-04 20:29:05 +02006100 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02006101 [] T_wait.timeout {
6102 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6103 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
6104 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006105 }
6106 /* Emulate PCU asking BTS to deactivate PDCH */
6107 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6108 alt {
6109 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
6110 setverdict(pass);
6111 }
6112 [] RSL.receive { repeat; }
6113 }
6114}
6115
6116/* Activate Osmocom-style dynamic PDCH from BSC side */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006117private function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006118 var PCUIF_Message first_info;
6119 var integer ts_nr := g_chan_nr.tn;
6120 var integer trx_nr := 0;
6121 var integer bts_nr := 0;
6122 var integer pcu_conn_id := -1;
6123
6124 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6125
6126 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6127 f_sleep(3.0);
6128 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6129 setverdict(pass);
6130}
6131testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
6132 var ConnHdlrPars pars;
6133 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006134 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006135
6136 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6137 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
6138 vc_conn.done;
6139}
6140
6141/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006142private function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006143 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02006144 var integer pcu_conn_id := -1;
6145
6146 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6147
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02006148 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
6149 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
6150 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02006151 setverdict(pass);
6152}
6153testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
6154 var ConnHdlrPars pars;
6155 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006156 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006157
6158 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6159 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
6160 vc_conn.done;
6161}
6162
6163/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006164private function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006165 var PCUIF_Message first_info;
6166 var integer ts_nr := g_chan_nr.tn;
6167 var integer trx_nr := 0;
6168 var integer bts_nr := 0;
6169 var integer pcu_conn_id := -1;
6170
6171 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6172
6173 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02006174 /* Send a second Chan Activ and expect it to be NACKed */
6175 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
6176 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02006177 setverdict(pass);
6178}
6179testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
6180 var ConnHdlrPars pars;
6181 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006182 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006183
6184 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6185 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
6186 vc_conn.done;
6187}
6188
6189/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006190private function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006191 var PCUIF_Message first_info;
6192 var integer ts_nr := g_chan_nr.tn;
6193 var integer trx_nr := 0;
6194 var integer bts_nr := 0;
6195 var integer pcu_conn_id := -1;
6196 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
6197
6198 /* register for the TCH/F channel number */
6199 f_rslem_register(0, chan_nr);
6200
6201 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6202
6203 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
6204 "RSL CHAN ACT");
6205 setverdict(pass);
6206}
6207testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
6208 var ConnHdlrPars pars;
6209 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006210 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006211
6212 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6213 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
6214 vc_conn.done;
6215}
6216
6217/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006218private function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02006219 var PCUIF_Message first_info;
6220 var integer ts_nr := g_chan_nr.tn;
6221 var integer trx_nr := 0;
6222 var integer bts_nr := 0;
6223 var integer pcu_conn_id := -1;
6224 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
6225 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
6226
6227 /* register for the TCH/H channel numbers */
6228 f_rslem_register(0, chan_nr[0]);
6229 f_rslem_register(0, chan_nr[1]);
6230
6231 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6232
6233 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
6234 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
6235 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
6236 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
6237 setverdict(pass);
6238}
6239testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
6240 var ConnHdlrPars pars;
6241 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006242 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02006243
6244 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6245 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
6246 vc_conn.done;
6247}
6248
Pau Espin Pedrol8e57ac12021-06-29 17:04:24 +02006249/* try to RSL CHAN ACT the SDCCH8 on an osmocom-style PDCH */
6250private function f_TC_dyn_osmo_pdch_sdcch8_act(charstring id) runs on ConnHdlr {
6251 var PCUIF_Message first_info;
6252 var integer ts_nr := g_chan_nr.tn;
6253 var integer trx_nr := 0;
6254 var integer bts_nr := 0;
6255 var integer pcu_conn_id := -1;
6256 var RslChannelNr chan_nr[8] := { valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 0)),
6257 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 1)),
6258 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 2)),
6259 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 3)),
6260 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 4)),
6261 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 5)),
6262 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 6)),
6263 valueof(t_RslChanNr_SDCCH8(g_chan_nr.tn, 7)) };
6264
6265 /* register for the TCH/H channel numbers */
6266 for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) {
6267 f_rslem_register(0, chan_nr[i]);
6268 }
6269
6270 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6271
6272 for (var integer i := 0; i < lengthof(chan_nr); i := i + 1) {
6273 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[i], g_pars.chan_mode),
6274 tr_RSL_CHAN_ACT_ACK(chan_nr[i]), "RSL CHAN ACT [" & int2str(i) & "]");
6275 }
6276 setverdict(pass);
6277}
6278testcase TC_dyn_osmo_pdch_sdcch8_act() runs on test_CT {
6279 var ConnHdlrPars pars;
6280 var ConnHdlr vc_conn;
6281 f_init();
6282
6283 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
6284 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_sdcch8_act), pars, true);
6285 vc_conn.done;
6286}
6287
Vadim Yanitskiy64043d82021-10-03 15:00:20 +06006288/* Reproduce a race condition described in OS#5245 */
6289private function f_rsl_chan_act_deact(charstring id) runs on ConnHdlr {
6290 f_rsl_chan_act(g_pars.chan_mode);
6291 f_sleep(1.0);
6292 f_rsl_chan_deact();
6293 setverdict(pass);
6294}
6295testcase TC_dyn_osmo_pdch_tchh_race_act() runs on test_CT {
6296 var ConnHdlrPars pars[2];
6297 var ConnHdlr vc_conn[2];
6298 var TrxcMessage rsp;
6299
6300 f_init();
6301
6302 /* Configure an artificial delay of 200 ms for TRXC RSP messages */
6303 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6304 ts_TRXC_FAKE_TRXC_DELAY(200));
6305
6306 /* Activate all sub-channels of TCH/H on TS4 immediately in hope that the second
6307 * CHANnel ACTIVation message will be handled before the PHY responds to 'SETSLOT' */
6308 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6309 /* TS4 is an Osmocom style dynamic timeslot, we want it to be TCH/H */
6310 pars[i] := valueof(t_Pars(t_RslChanNr_Lm(4, i), ts_RSL_ChanMode_SIGN));
6311 vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact),
6312 pars[i], l1ctl := false);
6313 }
6314
6315 /* Wait for all components to finish */
6316 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6317 vc_conn[i].done;
6318 }
6319
6320 /* Disable the artificial delay for TRXC RSP messages */
6321 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6322 ts_TRXC_FAKE_TRXC_DELAY(0));
6323}
6324testcase TC_dyn_osmo_pdch_sdcch8_race_act() runs on test_CT {
6325 var ConnHdlrPars pars[8];
6326 var ConnHdlr vc_conn[8];
6327 var TrxcMessage rsp;
6328
6329 f_init();
6330
6331 /* Configure an artificial delay of 200 ms for TRXC RSP messages */
6332 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6333 ts_TRXC_FAKE_TRXC_DELAY(200));
6334
6335 /* Activate all sub-channels of SDCCH/8 on TS4 immediately in hope that subsequent
6336 * CHANnel ACTIVation messages will be handled before the PHY responds to 'SETSLOT' */
6337 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6338 /* TS4 is an Osmocom style dynamic timeslot, we want it to be SDCCH/8 */
6339 pars[i] := valueof(t_Pars(t_RslChanNr_SDCCH8(4, i), ts_RSL_ChanMode_SIGN));
6340 vc_conn[i] := f_start_handler(refers(f_rsl_chan_act_deact),
6341 pars[i], l1ctl := false);
6342 }
6343
6344 /* Wait for all components to finish */
6345 for (var integer i := 0; i < sizeof(pars); i := i + 1) {
6346 vc_conn[i].done;
6347 }
6348
6349 /* Disable the artificial delay for TRXC RSP messages */
6350 rsp := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
6351 ts_TRXC_FAKE_TRXC_DELAY(0));
6352}
6353
Harald Welte9bbbfb52018-04-05 09:33:19 +02006354/***********************************************************************
6355 * IPA Style Dynamic Timeslot Support
6356 ***********************************************************************/
6357
6358private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6359runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006360 /* Expect BTS to immediately acknowledge activation as PDCH */
6361 PCU.clear;
6362 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
6363 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006364 timer T_wait := 2.0;
6365 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02006366 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006367 [] as_pcuif_check_pdch_mask(pcu_conn_id, '1'B, bts_nr, trx_nr);
Harald Welte9bbbfb52018-04-05 09:33:19 +02006368 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006369 [] T_wait.timeout {
6370 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6371 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
6372 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02006373 }
6374 /* try to activate this PDCH from the PCU point of view */
6375 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6376 /* FIXME: is there a response? */
6377
6378 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
6379}
6380
6381private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
6382runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006383 /* Send RSL CHAN REL (deactivate) */
6384 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
6385 PCU.clear;
6386 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006387 timer T_wait := 2.0;
6388 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02006389 alt {
Vadim Yanitskiyb1ebcc02020-07-19 17:43:02 +07006390 [] as_pcuif_check_pdch_mask(pcu_conn_id, '0'B, bts_nr, trx_nr);
Harald Welte9bbbfb52018-04-05 09:33:19 +02006391 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01006392 [] T_wait.timeout {
6393 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
6394 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
6395 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02006396 }
6397 /* Emulate PCU asking BTS to deactivate PDCH */
6398 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
6399 alt {
6400 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
6401 setverdict(pass);
6402 }
6403 [] RSL.receive { repeat; }
6404 }
6405}
6406
6407/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006408private function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006409 var PCUIF_Message first_info;
6410 var integer ts_nr := g_chan_nr.tn;
6411 var integer trx_nr := 0;
6412 var integer bts_nr := 0;
6413 var integer pcu_conn_id := -1;
6414
6415 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6416
6417 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6418 f_sleep(3.0);
6419 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6420
6421 setverdict(pass);
6422
6423}
6424testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
6425 var ConnHdlrPars pars;
6426 var ConnHdlr vc_conn;
6427 f_init();
6428
6429 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6430 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
6431 vc_conn.done;
6432}
6433
6434/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006435private function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006436 var PCUIF_Message first_info;
6437 var integer ts_nr := g_chan_nr.tn;
6438 var integer trx_nr := 0;
6439 var integer bts_nr := 0;
6440 var integer pcu_conn_id := -1;
6441
6442 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6443
6444 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
6445 "RSL CHAN ACT");
6446 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
6447 "RF CHAN REL", true);
6448 setverdict(pass);
6449}
6450testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
6451 var ConnHdlrPars pars;
6452 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006453 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006454
6455 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6456 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
6457 vc_conn.done;
6458}
6459
6460/* 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 +07006461private function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006462 var PCUIF_Message first_info;
6463 var integer ts_nr := g_chan_nr.tn;
6464 var integer trx_nr := 0;
6465 var integer bts_nr := 0;
6466 var integer pcu_conn_id := -1;
6467
6468 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6469
6470 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
6471 "RSL CHAN ACT");
6472
6473 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
6474 alt {
6475 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
6476 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006477 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02006478 }
6479 [] RSL.receive { repeat; }
6480 }
6481
6482 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
6483 "RF CHAN REL", true);
6484 setverdict(pass);
6485}
6486testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
6487 var ConnHdlrPars pars;
6488 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006489 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006490
6491 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6492 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
6493 vc_conn.done;
6494}
6495
6496/* 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 +07006497private function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02006498 var PCUIF_Message first_info;
6499 var integer ts_nr := g_chan_nr.tn;
6500 var integer trx_nr := 0;
6501 var integer bts_nr := 0;
6502 var integer pcu_conn_id := -1;
6503
6504 /* register for the TCH/F channel number */
6505 f_rslem_register(0, g_chan_nr);
6506
6507 f_init_pcu(PCU, id, pcu_conn_id, first_info);
6508
6509 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
6510
6511 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
6512 "RSL CHAN ACT");
6513
6514 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
6515
6516 setverdict(pass);
6517}
6518testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
6519 var ConnHdlrPars pars;
6520 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006521 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02006522
6523 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
6524 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
6525 vc_conn.done;
6526}
6527
6528
Harald Welte0472ab42018-03-12 15:02:26 +01006529/***********************************************************************
6530 * LAPDm / RLL related
6531 ***********************************************************************/
6532
6533private function f_tx_lapdm(template (value) LapdmFrame l,
6534 template (value) RslLinkId link_id) runs on ConnHdlr {
6535 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006536 var template (value) SacchL1Header l1h;
6537
6538 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01006539 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006540 /* Compose dummy L1 header */
6541 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta);
6542 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 +02006543 } else {
6544 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07006545 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 +01006546 }
Harald Welte0472ab42018-03-12 15:02:26 +01006547}
6548
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006549friend type record RllTestCase {
Harald Welte0472ab42018-03-12 15:02:26 +01006550 uint3_t sapi,
6551 RslLinkId link_id,
6552 octetstring l3,
6553 boolean exp
6554}
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006555friend type record of RllTestCase RllTestCases;
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006556friend template RllTestCase t_EITC(template (present) uint3_t sapi,
6557 template (present) RslLinkId id,
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006558 octetstring l3, boolean exp) := {
Harald Welte0472ab42018-03-12 15:02:26 +01006559 sapi := sapi,
6560 link_id := id,
6561 l3 := l3,
6562 exp := exp
6563}
6564
6565/* execute the same callback function with a set of different parameters (tcs) on a
6566 * variety of logical channels */
6567private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
6568 var ConnHdlrPars pars;
6569 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02006570 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01006571
6572 /* test on each of the channels we have */
6573 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
6574 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
6575
6576 /* test each of the test cases on the current channel */
6577 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
6578 pars.spec.rll := tcs[j];
6579 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
6580 vc_conn := f_start_handler(fn, pars);
6581 vc_conn.done;
6582 }
6583 }
6584
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006585 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01006586}
6587
6588/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
6589private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
6590 var RllTestCase tc := g_pars.spec.rll;
6591 timer T := 3.0;
6592
6593 f_l1_tune(L1CTL);
6594 RSL.clear;
6595
6596 /* activate the logical channel */
6597 f_est_dchan();
6598 L1CTL.clear;
6599
6600 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
6601 T.start;
6602 alt {
6603 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
6604 if (tc.exp) {
6605 setverdict(pass);
6606 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006607 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01006608 }
6609 }
6610 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
6611 if (tc.exp) {
6612 setverdict(pass);
6613 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006614 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01006615 }
6616 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07006617 /* We also expect to receive the measurements */
6618 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01006619 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006620 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01006621 }
6622 [not tc.exp] T.timeout {
6623 setverdict(pass);
6624 }
6625 }
6626
6627 f_rsl_chan_deact();
6628 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6629 f_rslem_unregister(0, g_chan_nr);
6630}
6631testcase TC_rll_est_ind() runs on test_CT {
6632 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02006633 /* SAPI0 establishment (contention resolution) */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006634 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02006635 /* normal SAPI0 establishment */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006636 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01006637 /* SAPI 3 doesn't support contention resolution */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006638 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), '01020304'O, false)),
6639 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), '01020304'O, false)),
Harald Welte0472ab42018-03-12 15:02:26 +01006640 /* normal SAPI3 establishment on main DCCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006641 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01006642 /* normal SAPI3 establishment on SACCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006643 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006644 };
6645 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
6646}
6647
6648/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
6649private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
6650 var RllTestCase tc := g_pars.spec.rll;
6651 var L1ctlDlMessage dl;
6652 timer T := 3.0;
6653
6654 f_l1_tune(L1CTL);
6655 RSL.clear;
6656
6657 /* activate the logical channel */
6658 f_est_dchan();
6659 L1CTL.clear;
6660
6661 /* Send a RSL EST REQ for SAPI3 on main DCCH */
6662 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
6663 T.start;
6664 alt {
Vadim Yanitskiy0310f632021-06-01 01:22:24 +02006665 [] as_l1_exp_lapdm(tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O));
Harald Welte0472ab42018-03-12 15:02:26 +01006666 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006667 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01006668 }
6669 }
6670
6671 f_rsl_chan_deact();
6672 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6673 f_rslem_unregister(0, g_chan_nr);
6674}
6675testcase TC_rll_est_req_DCCH_3() runs on test_CT {
6676 var RllTestCases tcs := {
6677 /* normal SAPI3 establishment on main DCCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006678 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))//,
Harald Welte0472ab42018-03-12 15:02:26 +01006679 };
6680 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
6681}
6682testcase TC_rll_est_req_ACCH_3() runs on test_CT {
6683 var RllTestCases tcs := {
6684 /* normal SAPI3 establishment on SACCH */
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006685 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006686 }
6687 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
6688}
6689
6690/* altstep to receive a LAPDm frame matching the given template */
Vadim Yanitskiy7368a102021-06-01 01:25:08 +02006691friend altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
Harald Welte0472ab42018-03-12 15:02:26 +01006692 var L1ctlDlMessage dl;
6693 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
6694 var LapdmFrame lapdm;
6695 var octetstring l2 := dl.payload.data_ind.payload;
6696 if (dl.dl_info.link_id.c == SACCH) {
6697 /* remove L1 header */
6698 l2 := substr(l2, 2, lengthof(l2)-2);
6699 }
6700 if (ischosen(exp.ab)) {
6701 lapdm.ab := dec_LapdmFrameAB(l2);
6702 } else if (ischosen(exp.b4)) {
6703 lapdm.b4 := dec_LapdmFrameB4(l2);
6704 } else if (ischosen(exp.bbis)) {
6705 lapdm.bbis := dec_LapdmFrameBbis(l2);
6706 }
6707 log("Rx LAPDm ", lapdm);
6708 if (match(lapdm, exp)) {
6709 setverdict(pass);
6710 } else {
6711 repeat;
6712 }
6713 }
6714 [] L1CTL.receive { repeat; }
6715}
6716private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
6717 timer T := t;
6718 T.start;
6719 alt {
6720 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006721 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01006722 }
6723 [] as_l1_exp_lapdm(exp);
6724 }
6725}
6726
6727/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
6728private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
6729 /* send SABM from MS -> BTS */
6730 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
6731 /* expect RLL EST IND on Abis */
6732 alt {
6733 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
6734 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
6735 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006736 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01006737 }
6738 [] RSL.receive { repeat; }
6739 }
6740 /* expect UA from BTS -> MS */
6741 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
6742}
6743
6744/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
6745private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
6746 var RllTestCase tc := g_pars.spec.rll;
6747
6748 f_l1_tune(L1CTL);
6749 RSL.clear;
6750
6751 /* activate the logical channel */
6752 f_est_dchan();
6753 L1CTL.clear;
6754
6755 /* first establish the link-layer */
6756 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
6757
6758 /* then send the DISC */
6759 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
6760 /* ... and expect the REL IND on the RSL side */
6761 alt {
6762 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
6763 setverdict(pass);
6764 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07006765 /* We also expect to receive the measurements */
6766 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01006767 }
6768
6769 /* release the channel */
6770 f_rsl_chan_deact();
6771 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6772 f_rslem_unregister(0, g_chan_nr);
6773}
6774testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
6775 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006776 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006777 };
6778 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6779}
6780
6781testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
6782 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006783 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006784 };
6785 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6786}
6787testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
6788 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006789 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006790 };
6791 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6792}
6793testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
6794 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006795 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006796 };
6797 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6798}
6799
6800/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
6801private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
6802 var RllTestCase tc := g_pars.spec.rll;
6803 f_l1_tune(L1CTL);
6804 RSL.clear;
6805
6806 /* activate the logical channel */
6807 f_est_dchan();
6808 L1CTL.clear;
6809
6810 /* first establish the link-layer */
6811 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
6812
6813 /* then send the REL REQ via RSL */
6814 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
6815 /* ... and expect the DISC on the Um side */
6816 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02006817 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01006818 /* FIXME: send a UA in resposne to the DISC */
6819 }
6820 }
6821
6822 /* release the channel */
6823 f_rsl_chan_deact();
6824 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6825 f_rslem_unregister(0, g_chan_nr);
6826}
6827testcase TC_rll_rel_req() runs on test_CT {
6828 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006829 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), '01020304'O, true)),
6830 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), ''O, true)),
6831 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), ''O, true)),
6832 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), ''O, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006833 };
6834 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
6835}
6836
Vadim Yanitskiy89be0602020-07-04 21:20:57 +07006837/* TODO: test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
Harald Welte0472ab42018-03-12 15:02:26 +01006838testcase TC_rll_data_req() runs on test_CT {
6839}
6840
Vadim Yanitskiy89be0602020-07-04 21:20:57 +07006841/* TODO: test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
Harald Welte0472ab42018-03-12 15:02:26 +01006842testcase TC_rll_data_ind() runs on test_CT {
6843}
6844
6845/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
6846private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
6847 var RllTestCase tc := g_pars.spec.rll;
6848
6849 f_l1_tune(L1CTL);
6850 RSL.clear;
6851
6852 f_est_dchan();
6853 L1CTL.clear;
6854
6855 /* Send UNITDATA REQ on RSL side */
6856 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
6857 /* Expect it to arrive on the other side */
6858 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02006859 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01006860 } else {
Harald Weltee613f962018-04-18 22:38:16 +02006861 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01006862 }
6863
6864 /* release the channel */
6865 f_rsl_chan_deact();
6866 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6867 f_rslem_unregister(0, g_chan_nr);
6868}
6869testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
6870 var octetstring l3 := f_rnd_octstring(15);
6871 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006872 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)),
6873 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006874 };
6875 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
6876}
6877testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
6878 var octetstring l3 := f_rnd_octstring(19);
6879 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006880 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)),
6881 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006882 };
6883 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
6884}
6885
6886/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
6887private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
6888 var RllTestCase tc := g_pars.spec.rll;
6889
6890 f_l1_tune(L1CTL);
6891 RSL.clear;
6892
6893 f_est_dchan();
6894 L1CTL.clear;
6895
6896 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02006897 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01006898 /* Expdct RLL UNITDATA IND on RSL side */
6899 alt {
6900 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
6901 setverdict(pass);
6902 }
6903 [] RSL.receive { repeat; }
6904 }
6905
6906 /* release the channel */
6907 f_rsl_chan_deact();
6908 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6909 f_rslem_unregister(0, g_chan_nr);
6910}
6911testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02006912 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01006913 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006914 valueof(t_EITC(0, ts_RslLinkID_DCCH(0), l3, true)),
6915 valueof(t_EITC(3, ts_RslLinkID_DCCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006916 };
6917 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
6918}
6919testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
6920 var octetstring l3 := f_rnd_octstring(18);
6921 var RllTestCases tcs := {
Vadim Yanitskiy1b9a7f62021-06-01 01:56:37 +02006922 valueof(t_EITC(0, ts_RslLinkID_SACCH(0), l3, true)),
6923 valueof(t_EITC(3, ts_RslLinkID_SACCH(3), l3, true))
Harald Welte0472ab42018-03-12 15:02:26 +01006924 };
6925 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
6926}
6927
Harald Weltee613f962018-04-18 22:38:16 +02006928/***********************************************************************
6929 * Encryption Related
6930 ***********************************************************************/
6931
6932/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
Vadim Yanitskiy8239dd92020-07-04 20:31:35 +07006933private function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006934 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
6935 if (link_id.c == SACCH) {
6936 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
6937 } else {
6938 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
6939 }
6940}
6941
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006942/* Expect (or not expect) other kinds of messages */
6943private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
6944 [exp_any] RSL.receive { repeat; }
6945 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006946 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006947 }
6948}
6949
Harald Weltee613f962018-04-18 22:38:16 +02006950/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07006951private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07006952 RslLinkId link_id,
6953 octetstring l3,
6954 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07006955 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07006956) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006957 timer T := 3.0;
6958 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
6959 T.start;
6960 /* Expect RLL UNITDATA IND on RSL side */
6961 alt {
6962 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
6963 setverdict(pass);
6964 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07006965 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006966 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02006967 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006968 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02006969 }
Harald Weltee613f962018-04-18 22:38:16 +02006970 }
6971}
6972
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006973/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
6974private function f_data_mo(
6975 RslLinkId link_id,
6976 boolean p, uint3_t nr, uint3_t ns,
6977 octetstring l3,
6978 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07006979 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006980) runs on ConnHdlr {
6981 timer T := 3.0;
6982 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
6983 T.start;
6984 /* Expect RLL DATA IND on RSL side */
6985 alt {
6986 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
6987 setverdict(pass);
6988 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07006989 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006990 [] as_rsl_any_ind(exp_any);
6991 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006992 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006993 }
6994 }
6995}
6996
Harald Weltee613f962018-04-18 22:38:16 +02006997/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006998private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006999 f_l1_tune(L1CTL);
7000 f_est_dchan(true);
7001
7002 /* now we actually need to transmit some data both ways to check if the encryption works */
7003 var L1ctlDlMessage dl;
7004
Stefan Sperling603d98e2018-07-25 16:47:28 +02007005 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02007006 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7007
7008 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
7009 f_unitdata_mt(link_id, l3);
7010
7011 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
7012 f_unitdata_mo(link_id, l3);
7013
7014 /* release the channel */
7015 f_rsl_chan_deact();
7016 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7017 f_rslem_unregister(0, g_chan_nr);
7018}
7019testcase TC_chan_act_a51() runs on test_CT {
7020 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7021 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7022 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7023}
7024testcase TC_chan_act_a52() runs on test_CT {
7025 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7026 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
7027 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7028}
7029testcase TC_chan_act_a53() runs on test_CT {
7030 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7031 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
7032 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7033}
Eric Wildb9260392021-05-15 19:48:22 +02007034testcase TC_chan_act_a54() runs on test_CT {
7035 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7036 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16)));
7037 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
7038}
Harald Weltee613f962018-04-18 22:38:16 +02007039
Eric Wildf1827a72019-05-28 17:37:35 +02007040/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
7041 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 +07007042private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
Eric Wildf1827a72019-05-28 17:37:35 +02007043 f_l1_tune(L1CTL);
7044 f_est_dchan(true);
7045
7046 /* now we actually need to transmit some data both ways to check if the encryption works */
7047 var L1ctlDlMessage dl;
7048
7049 var octetstring l3 := f_rnd_octstring(20);
7050 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7051
7052 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
7053 f_unitdata_mt(link_id, l3);
7054
7055 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
7056 f_unitdata_mo(link_id, l3);
7057
7058 var RSL_Message rsl;
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007059 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, ts_RSL_ChanMode_SIGN));
Eric Wildf1827a72019-05-28 17:37:35 +02007060
7061 /* modify key to break proper encryption */
7062 g_pars.encr.key := f_rnd_octstring(8);
7063 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
7064 rsl.ies := rsl.ies & { ei };
7065 RSL.send(rsl);
7066
7067 timer T0 := 1.0;
7068 T0.start;
7069 /* Expect RSL MODIFY ACK */
7070 alt {
7071 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
7072 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
7073 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
7074 }
7075 [] T0.timeout {
7076 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
7077 }
7078 }
7079
7080 var octetstring l3msg := f_rnd_octstring(15);
7081 timer T1 := 3.0;
7082 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
7083 due to broken encryption */
7084 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
7085 T1.start;
7086 alt {
7087 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
7088 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
7089 }
7090 [] T1.timeout {
7091 setverdict(pass);
7092 }
7093 }
7094
7095 /* release the channel */
7096 f_rsl_chan_deact();
7097 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7098 f_rslem_unregister(0, g_chan_nr);
7099}
7100testcase TC_rsl_modify_encr() runs on test_CT {
7101 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7102 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7103 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
7104}
Harald Weltee613f962018-04-18 22:38:16 +02007105
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +02007106/* Verify RF RESource INDication messages (periodically sent over the RSL) */
7107private function f_TC_rsl_rf_resource_ind(template RSL_ResourceInfo info)
7108runs on test_CT {
7109 const IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
7110 var ASP_RSL_Unitdata ud;
7111 timer T;
7112
7113 /* Intave is 6 SACCH periods by default */
7114 var float Tval := int2float(6 * 480) / 1000.0 + 0.5;
7115
7116 T.start(Tval);
7117 alt {
7118 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(info), sid)) {
7119 setverdict(pass);
7120 }
7121 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND(?), sid)) -> value ud {
7122 setverdict(fail, "RF RESource INDication mismatch: ", ud.rsl);
7123 }
7124 [] RSL_CCHAN.receive { repeat; }
7125 [] T.timeout {
7126 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
7127 "Timeout waiting for RF RESource INDication");
7128 }
7129 }
7130}
7131testcase TC_rsl_rf_resource_ind() runs on test_CT {
7132 var RSL_ResourceInfo info := { };
7133
7134 f_init(trx_nr := 0);
7135
7136 f_init_l1ctl();
7137 f_l1_tune(L1CTL);
7138
7139 /* g_AllChannels contains all logical channels */
7140 for (var integer i := 0; i < lengthof(g_AllChannels); i := i + 1) {
7141 var RslChannelNr chan_nr := g_AllChannels[i];
7142
7143 /* FIXME: osmo-bts does not report for Osmocom style dynamic timeslots */
7144 if (mp_trx_pars[0].ts[chan_nr.tn].config == GSM_PCHAN_TCHH_TCHF_PDCH)
7145 { continue; }
7146
7147 info := info & { valueof(ts_RSL_ResourceInfoItem(chan_nr, mp_interf_band)) };
7148 }
7149
7150 /* Align to the first interference report */
7151 f_TC_rsl_rf_resource_ind(?);
7152
7153 /* Test 4 consecutive messages */
7154 for (var integer i := 0; i < 4; i := i + 1) {
7155 f_TC_rsl_rf_resource_ind(info);
7156 }
7157
7158 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7159}
7160
Harald Weltee613f962018-04-18 22:38:16 +02007161/* Test unencrypted channel activation followed by explicit ENCR CMD later */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007162private function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02007163 /* L3 payload doesn't matter, as it is passed transparently */
7164 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
7165 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
7166 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
7167
7168 f_l1_tune(L1CTL);
7169
7170 /* first establish a dedicated channel in the clear */
7171 f_est_dchan(false);
7172
7173 /* Establish ABM */
7174 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
7175
7176 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
7177 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
7178 /* expect the L3 to arrive still unencrypted on the MS side */
7179 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
7180
7181 /* configure L1 to apply ciphering */
7182 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
7183 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
7184
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07007185 /* send first ciphered I-frame in response and expect it on RSL */
7186 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02007187
7188 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
7189 * and hence enable encryption also on the downlink */
7190
7191 /* expect bi-directional communication work in encrypted mode */
7192 f_unitdata_mo(link_id, f_rnd_octstring(15));
7193 f_unitdata_mt(link_id, f_rnd_octstring(15));
7194
7195 /* release the channel */
7196 f_rsl_chan_deact();
7197 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7198 f_rslem_unregister(0, g_chan_nr);
7199}
7200testcase TC_encr_cmd_a51() runs on test_CT {
7201 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7202 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
7203 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7204}
7205testcase TC_encr_cmd_a52() runs on test_CT {
7206 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7207 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
7208 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7209}
7210testcase TC_encr_cmd_a53() runs on test_CT {
7211 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7212 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
7213 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7214}
Eric Wildb9260392021-05-15 19:48:22 +02007215testcase TC_encr_cmd_a54() runs on test_CT {
7216 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7217 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_4, f_rnd_octstring(16)));
7218 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
7219}
Harald Weltee613f962018-04-18 22:38:16 +02007220
7221private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
7222 var LapdmFrame lf;
7223 var octetstring reenc;
7224
7225 /* decode the LAPDm frame */
7226 if (ischosen(exp_match.ab)) {
7227 lf.ab := dec_LapdmFrameAB(enc);
7228 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007229 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02007230 }
7231
7232 /* check if decoder result matches expectation */
7233 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02007235 } else {
7236 log(name, ": matched");
7237 setverdict(pass);
7238 }
7239
7240 /* test if re-encoded frame equals original input */
7241 reenc := enc_LapdmFrame(lf);
7242 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007243 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02007244 } else {
7245 setverdict(pass);
7246 }
7247}
7248
7249testcase TC_lapdm_selftest() runs on test_CT {
7250 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
7251 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
7252 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
7253 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
7254 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
7255 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
7256 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
7257}
7258
Stefan Sperling4880be42018-08-07 18:12:59 +02007259/***********************************************************************
7260 * DTX Related (see GSM 05.08, section 8.3)
7261 ***********************************************************************/
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007262private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
Stefan Sperling4880be42018-08-07 18:12:59 +02007263 var L1ctlDlMessage dl;
Stefan Sperling4880be42018-08-07 18:12:59 +02007264 var GsmFrameNumber first_fn;
7265 var boolean is_first_frame := true;
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007266 var integer nfill_frames := 0;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007267 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02007268 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
7269 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007270 const integer frame_dtx_tchf_mod := 104;
7271 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
7272 * which operates in terms of blocks rather than frames. */
7273 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
7274 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02007275 timer T := 5.0;
7276
7277 f_l1_tune(L1CTL);
7278 RSL.clear;
7279 L1CTL.clear;
7280
7281 /* activate TCHF signalling channel */
7282 f_est_dchan(false);
7283
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007284 /* A template for matching dummy LAPDm func=UA frames */
7285 var template L1ctlDlMessage tr_fill_frame := tr_L1CTL_DATA_IND(
7286 chan_nr := g_chan_nr, link_id := tr_RslLinkID_DCCH(?),
7287 l2_data := f_pad_oct('030301'O, 23, '2B'O));
7288
Stefan Sperling4880be42018-08-07 18:12:59 +02007289 T.start;
7290 alt {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007291 [] L1CTL.receive(tr_fill_frame) -> value dl {
Stefan Sperling4880be42018-08-07 18:12:59 +02007292 var GsmFrameNumber fn := dl.dl_info.frame_nr;
Stefan Sperling4880be42018-08-07 18:12:59 +02007293
7294 if (is_first_frame) {
7295 is_first_frame := false;
7296 first_fn := dl.dl_info.frame_nr;
7297 }
7298
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007299 if (g_pars.chan_mode.dtx_d) {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007300 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007301 T.stop;
7302 f_rsl_chan_deact();
7303 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007304
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007305 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. */
7306 expected_fill_frames := 2;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007307
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007308 if (nfill_frames < expected_fill_frames) {
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007309 setverdict(fail, "Not enough fill frames received: ",
7310 nfill_frames, " out of ", expected_fill_frames);
7311 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Stefan Sperling4880be42018-08-07 18:12:59 +02007312 } else {
7313 setverdict(pass);
7314 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007315 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007316 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
7317 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
7318 * we should only see the subset of frames numbers which correspond to a block boundary.
7319 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
7320 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
7321 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007322 nfill_frames := nfill_frames + 1;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007323 repeat;
7324 }
7325 }
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007326 setverdict(fail, "Received DTX TCH fill frame with bad frame number: ", fn,
7327 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
7328 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007329 f_rsl_chan_deact();
7330 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling4880be42018-08-07 18:12:59 +02007331 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007332 } else {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007333 nfill_frames := nfill_frames + 1;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007334 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007335 T.stop;
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007336
7337 select (g_chan_nr) {
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007338 /* TCH/F: we expect 24 fill frames for every 104 frames. */
7339 case (t_RslChanNr_Bm(?)) { expected_fill_frames := 24; }
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007340 /* TCH/H: we expect 2 fill frames for every 104 frames. */
7341 case (t_RslChanNr_Lm(?, ?)) { expected_fill_frames := 2; }
7342 /* SDCCH: we expect 5 fill frames for every 104 frames. */
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007343 case (t_RslChanNr_SDCCH4(?, ?)) { expected_fill_frames := 4; }
7344 case (t_RslChanNr_SDCCH8(?, ?)) { expected_fill_frames := 4; }
Vadim Yanitskiy34ed2282020-10-24 23:18:42 +07007345 case else {
7346 /* This shall not happen, just to be sure */
7347 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7348 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007349 }
7350
7351 f_rsl_chan_deact();
7352 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02007353
Vadim Yanitskiy080a17d2020-10-25 01:06:48 +07007354 if (nfill_frames >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02007355 setverdict(pass);
7356 } else {
Vadim Yanitskiy76dc4d02020-10-24 22:56:46 +07007357 setverdict(fail, "Not enough fill frames received: ",
7358 nfill_frames, " out of ", expected_fill_frames);
7359 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Stefan Sperling4880be42018-08-07 18:12:59 +02007360 }
7361 } else {
7362 repeat;
7363 }
7364 }
7365 }
7366 [] L1CTL.receive { repeat; }
7367 [] T.timeout {
7368 f_rsl_chan_deact();
7369 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02007370 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02007371 }
7372 }
7373}
7374
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07007375private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007376 var template RSL_IE_ChannelMode ch_mode;
Stefan Sperling4880be42018-08-07 18:12:59 +02007377 var ConnHdlr vc_conn;
7378 var ConnHdlrPars pars;
7379 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02007380 f_init();
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007381 ch_mode := ts_RSL_ChanMode_SIGN(dtx_downlink := dtxd);
Stefan Sperling4880be42018-08-07 18:12:59 +02007382 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
Vadim Yanitskiy8fc43df2020-10-20 02:11:05 +07007383 pars := valueof(t_Pars(g_AllChannels[i], ch_mode));
Stefan Sperling4880be42018-08-07 18:12:59 +02007384 if (dtxd) {
7385 if (i >= 4) { /* DTX is only allowed on TCH/F */
7386 break;
7387 }
Stefan Sperling4880be42018-08-07 18:12:59 +02007388 }
Vadim Yanitskiy28a03ef2020-10-25 01:50:40 +07007389 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
Stefan Sperling4880be42018-08-07 18:12:59 +02007390 vc_conn.done;
7391 }
7392}
7393
7394/* Verify that L2 fill frames are sent on TCH in signaling mode if
7395 * there is nothing to transmit while DTX is disabled on downlink. */
7396testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
7397 f_tch_sign_l2_fill_frame(false);
7398}
7399
7400/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
7401 * there is nothing to transmit while DTX is enabled on downlink. */
7402testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
7403 f_tch_sign_l2_fill_frame(true);
7404}
Harald Welte0472ab42018-03-12 15:02:26 +01007405
Stefan Sperling0ec1c262018-10-15 15:12:52 +02007406testcase TC_chopped_ipa_ping() runs on test_CT {
7407 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
7408}
7409
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007410testcase TC_chopped_ipa_payload() runs on test_CT {
7411 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
7412}
7413
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007414
7415/* Callback function to be called by as_TC_ms_pwr_ctrl_constant().
7416 * Return value: Measurement Report to be sent (encoded octetstring). */
7417type function f_TC_ms_pwr_ctrl_cb(inout SacchL1Header l1h, integer num_blocks)
7418 runs on ConnHdlr return octetstring;
7419
7420private altstep as_TC_ms_pwr_ctrl(f_TC_ms_pwr_ctrl_cb cb, inout integer num_blocks)
7421runs on ConnHdlr {
7422 var L1ctlDlMessage l1_dl;
7423 var SacchL1Header l1h;
7424 var octetstring l2;
7425
7426 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
7427 /* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
7428 l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2));
7429 log("as_TC_ms_pwr_ctrl(): Rx SACCH L1 header: ", l1h);
7430
7431 /* Pass it to the user specified call-back function */
7432 l2 := cb.apply(l1h, num_blocks);
7433 /* Send a Measurement Report generated by the call-back */
7434 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(l1_dl.dl_info.chan_nr,
7435 l1_dl.dl_info.link_id,
7436 l1h, l2));
7437
7438 /* Shall we keep going? */
7439 num_blocks := num_blocks - 1;
7440 log("as_TC_ms_pwr_ctrl(): ", num_blocks, " SACCH blocks remaining");
7441 if (num_blocks > 0) { repeat; }
7442 }
7443 [] L1CTL.receive { repeat; }
7444}
7445
7446private function f_TC_ms_pwr_ctrl_cb_def(inout SacchL1Header l1h, integer num_blocks)
7447runs on ConnHdlr return octetstring {
7448 /* Command the L1 to apply received parameters */
7449 f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl);
7450
7451 /* Dummy measurement report (the results are invalid) */
7452 return f_pad_oct('010349'O & '0615004001C0'O, 21, '00'O);
7453}
7454
7455private function f_TC_ms_pwr_ctrl_cb_const(inout SacchL1Header l1h, integer num_blocks)
7456runs on ConnHdlr return octetstring {
7457 if (l1h.ms_power_lvl != g_pars.l1_pars.ms_power_level) {
7458 setverdict(fail, "Unexpected MS Power level change: ",
7459 g_pars.l1_pars.ms_power_level, " -> ",
7460 l1h.ms_power_lvl);
7461 }
7462
7463 return f_TC_ms_pwr_ctrl_cb_def(l1h, num_blocks);
7464}
7465
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07007466private function f_TC_ms_pwr_ctrl_cb_rssi_pwm(inout SacchL1Header l1h, integer num_blocks)
7467runs on ConnHdlr return octetstring {
7468 /* UL RSSI oscillation driven by SACCH block number */
7469 if (num_blocks rem 2 == 0) {
7470 f_trxc_fake_rssi(-100);
7471 } else {
7472 f_trxc_fake_rssi(-50);
7473 }
7474
7475 /* Make sure that MS power level remains constant */
7476 return f_TC_ms_pwr_ctrl_cb_const(l1h, num_blocks);
7477}
7478
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007479/* Make sure that MS power level remains constant when 'rx-current' equals 'rx-target' */
7480private function f_TC_ms_pwr_ctrl_constant(charstring id)
7481runs on ConnHdlr {
7482 var integer num_blocks := 8;
7483 timer T := int2float(num_blocks);
7484
7485 f_l1_tune(L1CTL);
7486 RSL.clear;
7487
7488 /* These IEs are needed for autonomous MS power control */
7489 var template (value) RSL_IE_List ies := {
7490 t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{
7491 ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level)
7492 }),
7493 t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{
7494 ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O)
7495 })
7496 };
7497
7498 /* Ensure that 'rx-current' equals 'rx-target' */
7499 f_trxc_fake_rssi(mp_uplink_power_target);
7500
7501 /* Establish a dedicated channel */
7502 f_est_dchan(more_ies := valueof(ies));
7503
7504 L1CTL.clear;
7505 T.start;
7506 alt {
7507 [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_const), num_blocks);
7508 [] T.timeout {
7509 setverdict(fail, "Not all SACCH blocks were processed in time, ",
7510 num_blocks, " were not handled");
7511 }
7512 }
Vadim Yanitskiy6b4404a2021-06-17 17:22:56 +02007513
7514 /* Release the channel */
7515 f_rsl_chan_deact();
7516 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07007517}
7518testcase TC_ms_pwr_ctrl_constant() runs on test_CT {
7519 var ConnHdlr vc_conn;
7520 var ConnHdlrPars pars;
7521
7522 f_init();
7523
7524 /* Explicitly configure the Uplink power target (in dBm) */
7525 f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target));
7526
7527 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) {
7528 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
7529 log(testcasename(), ": starting on ", pars.chan_nr);
7530
7531 vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_constant),
7532 pars, trxc_comp := true);
7533 vc_conn.done;
7534 }
7535
7536 /* No need to reset Uplink power parameters - the IUT restarts anyway */
7537 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7538}
7539
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07007540/* Test Exponentially Weighted Moving Average (EWMA) power filtering */
7541private function f_TC_ms_pwr_ctrl_pf_ewma(charstring id)
7542runs on ConnHdlr {
7543 var integer num_blocks := 16;
7544 timer T := int2float(num_blocks);
7545
7546 f_l1_tune(L1CTL);
7547 RSL.clear;
7548
7549 /* These IEs are needed for autonomous MS power control */
7550 var template (value) RSL_IE_List ies := {
7551 t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{
7552 ms_power := ts_RSL_IE_MS_Power(g_pars.l1_pars.ms_power_level)
7553 }),
7554 t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{
7555 ms_power_params := ts_RSL_IE_MS_Power_Parameters(''O)
7556 })
7557 };
7558
7559 /* Ensure that 'rx-current' equals 'rx-target' */
7560 f_trxc_fake_rssi(mp_uplink_power_target);
7561
7562 /* Establish a dedicated channel */
7563 f_est_dchan(more_ies := valueof(ies));
7564
7565 L1CTL.clear;
7566 T.start;
7567 alt {
7568 [] as_TC_ms_pwr_ctrl(refers(f_TC_ms_pwr_ctrl_cb_rssi_pwm), num_blocks);
7569 [] T.timeout {
7570 setverdict(fail, "Not all SACCH blocks were processed in time, ",
7571 num_blocks, " were not handled");
7572 }
7573 }
Vadim Yanitskiy6b4404a2021-06-17 17:22:56 +02007574
7575 /* Release the channel */
7576 f_rsl_chan_deact();
7577 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07007578}
7579testcase TC_ms_pwr_ctrl_pf_ewma() runs on test_CT {
7580 var ConnHdlr vc_conn;
7581 var ConnHdlrPars pars;
7582
7583 f_init();
7584
7585 /* Explicitly configure EWMA filtering with 80% smoothing (alpha = 0.2) */
7586 f_vty_config(BTSVTY, "bts 0", "uplink-power-filtering algo ewma beta 80");
7587 /* Explicitly configure the Uplink power range (target and delte) */
7588 f_vty_config(BTSVTY, "bts 0", "uplink-power-target " & int2str(mp_uplink_power_target)
7589 & " hysteresis " & int2str(mp_uplink_power_hysteresis));
7590
7591 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i + 1) {
7592 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
7593 log(testcasename(), ": starting on ", pars.chan_nr);
7594
7595 vc_conn := f_start_handler(refers(f_TC_ms_pwr_ctrl_pf_ewma),
7596 pars, trxc_comp := true);
7597 vc_conn.done;
7598 }
7599
7600 /* No need to reset Uplink power parameters - the IUT restarts anyway */
7601 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7602}
7603
Vadim Yanitskiy5fa85612020-10-21 03:46:18 +07007604private function f_TC_speech_no_rtp(charstring id) runs on ConnHdlr {
7605 var template L1ctlDlMessage tr_bad_frame;
7606 var L1ctlDlMessage l1_dl;
7607 timer T := 8.0;
7608
7609 f_l1_tune(L1CTL);
7610 RSL.clear;
7611
7612 f_est_dchan();
7613
7614 /* There may be a few errors right after the channel activation */
7615 f_sleep(2.0); /* ... so let's give the L1 some time to stabilize */
7616 L1CTL.clear;
7617
7618 /* A universal template for bad Downlink frame: {DATA,TRAFFIC}.ind */
7619 tr_bad_frame := tr_L1CTL_TRAFFIC_IND(g_chan_nr, tr_RslLinkID_DCCH(0));
7620 tr_bad_frame.header.msg_type := (L1CTL_DATA_IND, L1CTL_TRAFFIC_IND);
7621 tr_bad_frame.dl_info.fire_crc := (1..255); /* != 0 */
7622 tr_bad_frame.payload := ?;
7623
7624 T.start;
7625 alt {
7626 /* OS#4823: DATA.ind or TRAFFIC.ind with bad CRC most likely means that
7627 * the IUT is sending *dummy bursts*, so the L1 fails to decode them. */
7628 [] L1CTL.receive(tr_bad_frame) -> value l1_dl {
7629 setverdict(fail, "Received {DATA,TRAFFIC}.ind with bad CRC: ", l1_dl);
7630 }
7631 [] as_l1_sacch();
7632 [] L1CTL.receive { repeat; }
7633 [] T.timeout {
7634 /* We're done, break the loop */
7635 setverdict(pass);
7636 }
7637 }
7638
7639 f_rsl_chan_deact();
7640 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7641}
7642testcase TC_speech_no_rtp_tchf() runs on test_CT {
7643 var ConnHdlr vc_conn;
7644 var ConnHdlrPars pars;
7645
7646 f_init();
7647
7648 /* TS1, TCH/F, V1 (FR codec) */
7649 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)));
7650 vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars);
7651 vc_conn.done;
7652}
7653testcase TC_speech_no_rtp_tchh() runs on test_CT {
7654 var ConnHdlr vc_conn;
7655 var ConnHdlrPars pars;
7656
7657 f_init();
7658
7659 /* TS5, TCH/H, V1 (HR codec) */
7660 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)));
7661 vc_conn := f_start_handler(refers(f_TC_speech_no_rtp), pars);
7662 vc_conn.done;
7663}
7664
Vadim Yanitskiy18684882021-07-04 04:15:58 +02007665/* Verify handling of Downlink and Uplink speech frames */
7666private function f_TC_speech_rtp(charstring id) runs on ConnHdlr {
7667 var L1ctlDlMessage l1_dl;
7668 var PDU_RTP rtp_pdu;
7669 var octetstring pl;
7670 timer Td, Tu;
7671
7672 f_l1_tune(L1CTL);
7673 f_est_dchan();
7674
7675 /* Activate the RTP emulation */
7676 pl := f_rnd_octstring(6);
7677 f_rtpem_activate(pl);
7678
7679 /* Give the scheduler some time to fill up the buffers */
7680 f_sleep(2.0);
7681 L1CTL.clear;
7682 RSL.clear;
7683
7684 /* Make sure that Downlink frames are received at the UE */
7685 Td.start(2.0);
7686 alt {
7687 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := pl)) -> value l1_dl {
7688 log("TCH received: ", l1_dl.payload.traffic_ind.data);
7689 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id,
7690 l1_dl.payload.traffic_ind.data));
7691 setverdict(pass);
7692 }
7693 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr, frame := ?)) -> value l1_dl {
7694 setverdict(fail, "Rx unexpected Downlink speech frame ",
7695 "(", l1_dl.payload.traffic_ind.data, ") ",
7696 "expected (", pl, ")");
7697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7698 }
7699 [] as_l1_sacch();
7700 [] L1CTL.receive { repeat; }
7701 [] Td.timeout {
7702 setverdict(fail, "Timeout waiting for Downlink speech frames");
7703 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7704 }
7705 }
7706
7707 /* Make sure that Uplink frames are received at the BTS */
7708 RTPEM_DATA.clear;
7709 Tu.start(2.0);
7710 alt {
7711 [] RTPEM_DATA.receive(PDU_RTP:?) -> value rtp_pdu {
7712 if (rtp_pdu.data != pl)
7713 { repeat; }
7714 }
7715 [] RTPEM_DATA.receive { repeat; }
7716 [] Tu.timeout {
7717 setverdict(fail, "Timeout waiting for Uplink speech frames");
7718 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7719 }
7720 }
7721
7722 f_rtpem_mode(RTPEM_CTRL, RTPEM_MODE_NONE);
7723 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7724 f_rsl_chan_deact();
7725 f_rslem_unregister(0, g_chan_nr);
7726}
7727testcase TC_speech_rtp_tchf() runs on test_CT {
7728 var ConnHdlr vc_conn;
7729 var ConnHdlrPars pars;
7730
7731 f_init();
7732
7733 /* TS1, TCH/F, V1 (FR codec) */
7734 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1)));
7735 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
7736 vc_conn.done;
7737
7738 /* TS1, TCH/F, V2 (EFR codec) */
7739 pars := valueof(t_Pars(ts_RslChanNr_Bm(1), ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2)));
7740 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
7741 vc_conn.done;
7742
7743 /* TODO: also test V3 (AMR codec) */
7744
7745 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7746}
7747testcase TC_speech_rtp_tchh() runs on test_CT {
7748 var ConnHdlr vc_conn;
7749 var ConnHdlrPars pars;
7750
7751 f_init();
7752
7753 /* TS5, TCH/H0, V1 (HR codec) */
7754 pars := valueof(t_Pars(ts_RslChanNr_Lm(5, 0), ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1)));
7755 vc_conn := f_start_handler(refers(f_TC_speech_rtp), pars);
7756 vc_conn.done;
7757
7758 /* TODO: also test V3 (AMR codec) */
7759
7760 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7761}
7762
Neels Hofmeyraf9d6ae2021-08-15 23:18:47 +02007763private function f_TC_early_immediate_assignment(charstring id) runs on ConnHdlr {
7764 var GsmFrameNumber fn;
7765 var ChannelDescription ch_desc;
7766 var integer ra := 23;
7767
7768 f_l1_tune(L1CTL);
7769 RSL.clear;
7770
7771 /* Send RACH request and wait for ChanReq */
7772 fn := f_rach_req_wait_chan_rqd(ra);
7773
7774 /* The BSC already sends the Immediate Assignment, before the channel is active.
7775 * (Also before the Channel Activation, even. I tried to write this test so that we first send the Chan Act and then the IMM
7776 * ASS, but osmo-bts-trx responds so fast that the Chan Activ ACK comes back even before titan dispatches the
7777 * IMM ASS. So move the IMM ASS even before the Chan Activ.) */
7778 if (g_pars.fhp.enabled) {
7779 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
7780 } else {
7781 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc));
7782 }
7783 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map));
7784 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
7785
7786 /* Do not expect the Immediate Assignment to show up on MS side yet. Even give it one second before the BSC
7787 * requests Chan Activ, to make sure the RR IMM ASS is held back. */
7788 var L1ctlDlMessage dl;
7789 var GsmRrMessage rr;
7790
7791 var template GsmRrMessage rr_imm_ass := tr_IMM_ASS(ra, fn);
7792 rr_imm_ass.payload.imm_ass.ded_or_tbf := ?;
7793 rr_imm_ass.payload.imm_ass.pkt_chan_desc := *;
7794 rr_imm_ass.payload.imm_ass.chan_desc := *;
7795
7796 timer T := 1.0;
7797 T.start;
7798 alt {
7799 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
7800 rr := dec_GsmRrMessage(dl.payload.data_ind.payload);
7801 if (match(rr, rr_imm_ass)) {
7802 setverdict(fail, "Expected IMM ASS to be delayed until Chan Act ACK, but it was passed to the MS immediately");
7803 mtc.stop;
7804 } else {
7805 repeat;
7806 }
7807 }
7808 [] L1CTL.receive { repeat; }
7809 [] T.timeout;
7810 }
7811 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode, t_RSL_IE_ActType_IA));
7812 RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr));
7813
7814 /* Now expect the IMM ASS on Um */
7815 f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
7816 setverdict(pass);
7817
7818 /* Release the channel */
7819 f_rsl_chan_deact();
7820 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
7821}
7822
7823testcase TC_early_immediate_assignment() runs on test_CT {
7824 var ConnHdlr vc_conn;
7825 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
7826 f_init();
7827 vc_conn := f_start_handler(refers(f_TC_early_immediate_assignment), pars);
7828 vc_conn.done;
7829 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
7830}
7831
Harald Welte0472ab42018-03-12 15:02:26 +01007832/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
7833/* protocol error as per 44.006 */
7834/* link layer failure (repetition of I-frame N200 times without ACK */
7835/* repetition of SABM or DISC N200 times without ACK */
7836/* receptiom of SABM in multi-frame established state */
7837
7838
Harald Welte68e495b2018-02-25 00:05:57 +01007839/* TODO Areas:
7840
7841* channel activation
7842** with BS_Power / MS_Power, bypassing power control loop
7843** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01007844** with timing advance from initial activation on
7845* mode modify
7846** encryption
7847** multirate
7848* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01007849** unsupported algorithm
7850* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01007851* BS Power Control
7852* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01007853* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01007854* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01007855** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01007856* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01007857** DATA_IND from BTS->PCU
7858** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01007859
7860*/
Harald Welte70767382018-02-21 12:16:40 +01007861
7862control {
7863 execute( TC_chan_act_stress() );
7864 execute( TC_chan_act_react() );
7865 execute( TC_chan_deact_not_active() );
7866 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01007867 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01007868 execute( TC_sacch_filling() );
7869 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01007870 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01007871 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02007872 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02007873 execute( TC_sacch_chan_act_ho_async() );
7874 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01007875 execute( TC_rach_content() );
Philipp Maier16ade782020-07-08 21:36:00 +02007876 execute( TC_rach_content_emerg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01007877 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01007878 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07007879 execute( TC_ho_rach() );
Harald Welte3453ab42019-05-24 21:19:58 +02007880 execute( TC_rach_load_idle_thresh0() );
7881 execute( TC_rach_load_idle_below_thresh() );
7882 execute( TC_rach_load_count() );
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07007883 execute( TC_meas_res_speech_tchf() );
Philipp Maier149c3922020-10-22 17:29:36 +02007884 execute( TC_meas_res_speech_tchf_facch() );
Vadim Yanitskiy204b98c2020-10-19 14:52:48 +07007885 execute( TC_meas_res_speech_tchh() );
Philipp Maier149c3922020-10-22 17:29:36 +02007886 execute( TC_meas_res_speech_tchh_facch() );
Vadim Yanitskiy780bc072020-10-20 02:16:01 +07007887 execute( TC_meas_res_speech_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01007888 execute( TC_meas_res_sign_tchf() );
7889 execute( TC_meas_res_sign_tchh() );
7890 execute( TC_meas_res_sign_sdcch4() );
7891 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01007892 execute( TC_meas_res_sign_tchh_toa256() );
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02007893 execute( TC_tx_power_start_ramp_up_bcch() );
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02007894 execute( TC_tx_power_start_ramp_down_bcch() );
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02007895 execute( TC_tx_power_ramp_adm_state_change() );
Eric Wildae8f2622019-06-18 17:05:11 +02007896 execute( TC_rsl_bs_pwr_static_ass() );
7897 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01007898 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02007899 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02007900 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02007901 execute( TC_rsl_ms_pwr_dyn_up() );
7902 execute( TC_rsl_ms_pwr_dyn_down() );
7903 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
7904 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02007905 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02007906 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02007907 execute( TC_rsl_modify_encr() );
Vadim Yanitskiy98c4a1a2021-06-04 18:46:06 +02007908 execute( TC_rsl_rf_resource_ind() );
Harald Welte70767382018-02-21 12:16:40 +01007909 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01007910 execute( TC_paging_imsi_80percent() );
7911 execute( TC_paging_tmsi_80percent() );
7912 execute( TC_paging_imsi_200percent() );
7913 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01007914 execute( TC_rsl_protocol_error() );
7915 execute( TC_rsl_mand_ie_error() );
7916 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01007917 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01007918 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01007919 execute( TC_si_sched_2bis() );
7920 execute( TC_si_sched_2ter() );
7921 execute( TC_si_sched_2ter_2bis() );
7922 execute( TC_si_sched_2quater() );
7923 execute( TC_si_sched_13() );
7924 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01007925 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01007926 execute( TC_ipa_crcx_twice_not_active() );
7927 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01007928 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01007929 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01007930
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007931 if (mp_pcu_socket != "") {
Philipp Maierca058272021-06-23 10:35:23 +02007932 execute( TC_paging_imsi_200percent_with_ps() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007933 execute( TC_pcu_act_req() );
7934 execute( TC_pcu_act_req_wrong_ts() );
7935 execute( TC_pcu_act_req_wrong_bts() );
7936 execute( TC_pcu_act_req_wrong_trx() );
7937 execute( TC_pcu_deact_req() );
7938 execute( TC_pcu_deact_req_wrong_ts() );
Philipp Maier94c08482021-02-01 17:36:05 +01007939 execute( TC_pcu_ver_si1() );
7940 execute( TC_pcu_ver_si3() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007941 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02007942 if (mp_l1_supports_gprs) {
7943 execute( TC_pcu_data_req_pdtch() );
7944 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02007945 execute( TC_pcu_data_req_wrong_bts() );
7946 execute( TC_pcu_data_req_wrong_trx() );
7947 execute( TC_pcu_data_req_wrong_ts() );
7948 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02007949 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07007950 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007951 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02007952 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007953 execute( TC_pcu_data_req_imm_ass_pch() );
7954 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07007955 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07007956 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007957 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02007958 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02007959 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02007960 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02007961 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02007962 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02007963 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02007964 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07007965 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02007966 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07007967 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02007968 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07007969 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02007970 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01007971 execute( TC_dyn_osmo_pdch_act_deact() );
7972 execute( TC_dyn_osmo_pdch_double_act() );
7973 execute( TC_dyn_ipa_pdch_act_deact() );
7974 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01007975 execute( TC_pcu_info_ind_fh_params() );
7976 execute( TC_pcu_socket_nsvc_ipv4() );
7977 execute( TC_pcu_socket_nsvc_ipv6() );
Vadim Yanitskiye2a50a82021-03-23 05:58:02 +01007978 execute( TC_pcu_socket_two_nsvc() );
Vadim Yanitskiy83852c12021-06-18 16:18:29 +02007979 execute( TC_pcu_interf_ind() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01007980 } else {
7981 log("PCU socket path not available, skipping PCU tests");
7982 }
Harald Welte3d04ae62018-04-04 20:29:05 +02007983
Harald Welte3d04ae62018-04-04 20:29:05 +02007984 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02007985 execute( TC_dyn_osmo_pdch_tchf_act() );
7986 execute( TC_dyn_osmo_pdch_tchh_act() );
Pau Espin Pedrol8e57ac12021-06-29 17:04:24 +02007987 execute( TC_dyn_osmo_pdch_sdcch8_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02007988 execute( TC_dyn_ipa_pdch_tchf_act() );
7989 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01007990
7991 execute( TC_rll_est_ind() );
7992 execute( TC_rll_est_req_DCCH_3() );
7993 execute( TC_rll_est_req_ACCH_3() );
7994 execute( TC_rll_rel_ind_DCCH_0() );
7995 execute( TC_rll_rel_ind_DCCH_3() );
7996 execute( TC_rll_rel_ind_ACCH_0() );
7997 execute( TC_rll_rel_ind_ACCH_3() );
7998 execute( TC_rll_rel_req() );
7999 execute( TC_rll_unit_data_req_DCCH() );
8000 execute( TC_rll_unit_data_req_ACCH() );
8001 execute( TC_rll_unit_data_ind_DCCH() );
8002 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02008003
8004 execute( TC_chan_act_a51() );
8005 execute( TC_chan_act_a52() );
8006 execute( TC_chan_act_a53() );
8007 execute( TC_encr_cmd_a51() );
8008 execute( TC_encr_cmd_a52() );
8009 execute( TC_encr_cmd_a53() );
8010
Harald Welteee25aae2019-05-19 14:32:37 +02008011 execute( TC_err_rep_wrong_mdisc() );
8012 execute( TC_err_rep_wrong_msg_type() );
8013 execute( TC_err_rep_wrong_sequence() );
8014
Harald Weltee613f962018-04-18 22:38:16 +02008015 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02008016
8017 execute( TC_tch_sign_l2_fill_frame() );
8018 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02008019
8020 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008021 execute( TC_chopped_ipa_payload() );
Vadim Yanitskiyc7ef0302020-10-18 19:24:18 +07008022
8023 execute( TC_ms_pwr_ctrl_constant() );
Vadim Yanitskiy652e60e2020-10-18 19:43:27 +07008024 execute( TC_ms_pwr_ctrl_pf_ewma() );
Vadim Yanitskiy5fa85612020-10-21 03:46:18 +07008025
8026 execute( TC_speech_no_rtp_tchf() );
8027 execute( TC_speech_no_rtp_tchh() );
Vadim Yanitskiy18684882021-07-04 04:15:58 +02008028 execute( TC_speech_rtp_tchf() );
8029 execute( TC_speech_rtp_tchh() );
Neels Hofmeyraf9d6ae2021-08-15 23:18:47 +02008030
8031 execute( TC_early_immediate_assignment() );
Vadim Yanitskiy46f19922021-10-06 02:36:22 +06008032
8033 /* BEWARE: these test cases can potentially break the IUT or cause
8034 * weird/unexpected behavior. Ensure that they are executed last. */
8035 execute( TC_dyn_osmo_pdch_tchh_race_act() );
8036 execute( TC_dyn_osmo_pdch_sdcch8_race_act() );
Harald Welte70767382018-02-21 12:16:40 +01008037}
8038
8039
8040}