blob: f60da24163114cbe90f372b39e02cdccf8f9448a [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;
Harald Welte82ccef72018-02-25 16:17:33 +010032import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010033import from L1CTL_PortType all;
34import from L1CTL_Types all;
35import from LAPDm_Types all;
Harald Weltead033dc2019-05-25 17:28:16 +020036import from LAPDm_RAW_PT all;
Harald Welte70767382018-02-21 12:16:40 +010037import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020038import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010039
40import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010041import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010042import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020043import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010044import from RSL_Emulation all;
45
46import from IPL4asp_Types all;
47import from TRXC_Types all;
48import from TRXC_CodecPort all;
49import from TRXC_CodecPort_CtrlFunct all;
50
Harald Welte883340c2018-02-28 18:59:29 +010051import from PCUIF_Types all;
52import from PCUIF_CodecPort all;
Harald Weltea2e0e942019-05-27 18:12:53 +020053import from UD_Types all;
Harald Welte883340c2018-02-28 18:59:29 +010054
Harald Welte7484fc42018-02-24 14:09:45 +010055import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010056import from MobileL3_RRM_Types all;
57import from MobileL3_Types all;
58import from L3_Templates all;
Harald Welteeaa9a862019-05-26 23:01:08 +020059import from L3_Common all;
60import from MobileL3_GMM_SM_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010061
Harald Welte8da48242018-02-27 20:41:32 +010062import from Osmocom_VTY_Functions all;
63import from TELNETasp_PortType all;
64
Harald Welte505cf9b2018-09-15 17:47:23 +030065friend module BTS_Tests_SMSCB;
Harald Weltead033dc2019-05-25 17:28:16 +020066friend module BTS_Tests_virtphy;
Harald Welte505cf9b2018-09-15 17:47:23 +030067
Harald Welte70767382018-02-21 12:16:40 +010068/* The tests assume a BTS with the following timeslot configuration:
69 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020070 * TS1 : TCH/F
71 * TS2 : TCH/F
72 * TS3 : TCH/F_PDCH (IPA Style)
73 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010074 * TS5 : TCH/H
75 * TS6 : SDCCH/8
76 * TS7 : PDCH
77 */
78
79modulepar {
80 charstring mp_rsl_ip := "127.0.0.2";
81 integer mp_rsl_port := 3003;
82 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070083 charstring mp_bts_trxc_ip := "127.0.0.1";
84 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010085 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020086 charstring mp_ctrl_ip := "127.0.0.1";
87 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020088 charstring mp_bsc_ctrl_ip := "127.0.0.1";
89 integer mp_bsc_ctrl_port := 4249;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020090 integer mp_tolerance_rxqual := 1;
91 integer mp_tolerance_rxlev := 3;
92 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020093 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020094 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020095 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020096 integer mp_ms_actual_ta_exp := 0;
97 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +010098 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +020099 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200100 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200101 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
102 boolean mp_l1_supports_gprs := false;
Harald Welte70767382018-02-21 12:16:40 +0100103}
104
Harald Welte629cc6b2018-03-11 17:19:05 +0100105type record of RslChannelNr ChannelNrs;
106
Harald Welte70767382018-02-21 12:16:40 +0100107type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100108 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100109 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100110 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100111 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100112 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100113 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100114
115 /* L1CTL port (for classic tests) */
116 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100117
Harald Welte54a2a2d2018-02-26 09:14:05 +0100118 /* TRXC port (for classic tests) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700119 port TRXC_CODEC_PT BTS_TRXC;
120 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100121
Harald Weltef50e3ae2018-09-10 10:27:56 +0200122 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100123 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200124 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100125
Harald Welte883340c2018-02-28 18:59:29 +0100126 /* PCU Interface of BTS */
127 port PCUIF_CODEC_PT PCU;
128 var integer g_pcu_conn_id;
129 /* Last PCU INFO IND we received */
130 var PCUIF_Message g_pcu_last_info;
131
Harald Welte48494ca2018-02-25 16:59:50 +0100132 /* SI configuration */
133 var SystemInformationConfig si_cfg := {
134 bcch_extended := false,
135 si1_present := false,
136 si2bis_present := false,
137 si2ter_present := false,
138 si2quater_present := false,
139 si7_present := false,
140 si8_present := false,
141 si9_present := false,
142 si13_present := false,
143 si13alt_present := false,
144 si15_present := false,
145 si16_present := false,
146 si17_present := false,
147 si2n_present := false,
148 si21_present := false,
149 si22_present := false
150 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100151
152 /* all logical channels available on the BTS */
153 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100154 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100155}
156
157/* an individual call / channel */
158type component ConnHdlr extends RSL_DchanHdlr {
159 port L1CTL_PT L1CTL;
160
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700161 port TRXC_CODEC_PT BTS_TRXC;
162 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100163
164 timer g_Tguard;
165 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
166
167 var ConnHdlrPars g_pars;
168 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100169 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200170
171 /* PCU Interface of BTS */
172 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100173}
174
175function f_init_rsl(charstring id) runs on test_CT {
176 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
177 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
178
179 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
180 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
181 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
182
183 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
184 vc_RSL.start(RSL_Emulation.main(false));
185}
186
187type record ConnHdlrPars {
188 RslChannelNr chan_nr,
189 RSL_IE_ChannelMode chan_mode,
190 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100191 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200192 TestSpecUnion spec optional,
193 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100194}
195
196/* Test-specific parameters */
197type union TestSpecUnion {
198 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100199}
200
Harald Welte82ccef72018-02-25 16:17:33 +0100201template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100202 max_retrans := RACH_MAX_RETRANS_7,
203 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100204 cell_barr_access := false,
205 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100206 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100207};
208
Harald Weltef10153f2018-02-25 16:34:05 +0100209template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100210 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200211 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100212 acs := '0'B,
213 neci := true,
214 rxlev_access_min := 0
215}
216
217template (value) LocationAreaIdentification ts_LAI_default := {
218 mcc_mnc := '262F42'H,
219 lac := 42
220}
221
Harald Welte7484fc42018-02-24 14:09:45 +0100222/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100223template (value) SystemInformation ts_SI3_default := {
224 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100225 payload := {
226 si3 := {
227 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100228 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100229 ctrl_chan_desc := {
230 msc_r99 := true,
231 att := true,
232 bs_ag_blks_res := 1,
233 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100234 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100235 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
236 spare := '00'B,
237 bs_pa_mfrms := 0, /* 2 multiframes */
238 t3212 := 1 /* 6 minutes */
239 },
Harald Welte82ccef72018-02-25 16:17:33 +0100240 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100241 dn_ind := false,
242 pwrc := false,
243 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100244 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100245 },
Harald Weltef10153f2018-02-25 16:34:05 +0100246 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100247 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100248 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100249 }
250 }
251}
Harald Welte70767382018-02-21 12:16:40 +0100252
Harald Weltef8df4cb2018-03-10 15:15:08 +0100253template (value) SystemInformation ts_SI2_default := {
254 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100255 payload := {
256 si2 := {
257 bcch_freq_list := '00000000000000000000000000000000'O,
258 ncc_permitted := '11111111'B,
259 rach_control := ts_RachCtrl_default
260 }
261 }
262}
263
Harald Weltef8df4cb2018-03-10 15:15:08 +0100264template (value) SystemInformation ts_SI4_default := {
265 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100266 payload := {
267 si4 := {
268 lai := ts_LAI_default,
269 cell_sel_par := ts_CellSelPar_default,
270 rach_control := ts_RachCtrl_default,
271 cbch_chan_desc := omit,
272 cbch_mobile_alloc := omit,
273 rest_octets := ''O
274 }
275 }
276}
277
278function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
279runs on test_CT {
280 log("Setting ", rsl_si_type, ": ", si_enc);
281 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
282}
283
284function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
285runs on test_CT {
286 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
287 log("Setting ", rsl_si_type, ": ", si_dec);
288 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
289}
290
Harald Welte505cf9b2018-09-15 17:47:23 +0300291friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100292 map(self:BTSVTY, system:BTSVTY);
293 f_vty_set_prompts(BTSVTY);
294 f_vty_transceive(BTSVTY, "enable");
295}
296
Harald Welte505cf9b2018-09-15 17:47:23 +0300297friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200298 map(self:BSCVTY, system:BSCVTY);
299 f_vty_set_prompts(BSCVTY, "OsmoBSC");
300 f_vty_transceive(BSCVTY, "enable");
301}
302
Harald Welte883340c2018-02-28 18:59:29 +0100303/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200304private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
305 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100306 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200307 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
308 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100309 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200310 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200311 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100312 }
313}
314
Harald Weltef26de0b2018-04-04 20:28:05 +0200315private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
316 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100317 timer T := 2.0;
318 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100319 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200320 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100321 return;
322 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200323 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100324
325 T.start;
326 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200327 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100328 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200329 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100330 }
331 }
332}
333
Harald Welte70767382018-02-21 12:16:40 +0100334/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100335function f_init(charstring id := "BTS-Test") runs on test_CT {
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100336 timer T := mp_ipa_up_timeout;
Harald Welte629cc6b2018-03-11 17:19:05 +0100337 g_AllChannels := {
338 /* TS 1..4: TCH/F */
339 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
340 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
341 /* TS 5: TCH/H */
342 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
343 /* TS 0: SDCCH/4 */
344 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
345 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
346 /* TS 6: SDCCH/8 */
347 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
348 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
349 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
350 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
351 };
352
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200353 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700354 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200355 g_AllChanTypes := {
356 /* TS 1..4: TCH/F */
357 valueof(ts_RslChanNr_Bm(1)),
358 /* TS 5: TCH/H */
359 valueof(ts_RslChanNr_Lm(5,1)),
360 /* TS 0: SDCCH/4 */
361 valueof(ts_RslChanNr_SDCCH4(0,2)),
362 /* TS 6: SDCCH/8 */
363 valueof(ts_RslChanNr_SDCCH8(6,4))
364 };
365 } else {
366 g_AllChanTypes := {
367 /* TS 1..4: TCH/F */
368 valueof(ts_RslChanNr_Bm(1)),
369 /* TS 0: SDCCH/4 */
370 valueof(ts_RslChanNr_SDCCH4(0,2)),
371 /* TS 6: SDCCH/8 */
372 valueof(ts_RslChanNr_SDCCH8(6,4))
373 };
374 }
Harald Welte70767382018-02-21 12:16:40 +0100375 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200376 T.start;
377 alt {
378 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
379 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200380 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Harald Welte83f6dbf2018-06-03 18:26:50 +0200381 }
382 }
Harald Welte2d142592018-02-25 13:19:44 +0100383 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100384 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200385 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100386
387 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100388 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
389 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
390 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
391 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100392
Harald Weltef26de0b2018-04-04 20:28:05 +0200393 map(self:PCU, system:PCU);
394 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100395
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700396 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100397 var TrxcMessage ret;
398 /* start with a default moderate timing offset equalling TA=2 */
399 f_main_trxc_connect();
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700400 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
Harald Welte84271622018-03-10 17:21:03 +0100401 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200402
403 /* Wait some extra time to make sure the BTS emits a stable carrier.
404 * (this is only relevant when running the tests with a physical BTS.) */
405 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100406}
407
Harald Welte68e495b2018-02-25 00:05:57 +0100408/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
409function f_init_l1ctl() runs on test_CT {
410 map(self:L1CTL, system:L1CTL);
411 f_connect_reset(L1CTL);
412}
413
Harald Welte70767382018-02-21 12:16:40 +0100414type function void_fn(charstring id) runs on ConnHdlr;
415
416/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200417function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100418runs on test_CT return ConnHdlr {
419 var charstring id := testcasename();
420 var ConnHdlr vc_conn;
421
422 vc_conn := ConnHdlr.create(id);
423 /* connect to RSL Emulation main component */
424 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
425 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200426 if (pcu_comp) {
427 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
428 * it from the test_CT and connect it to the component. This obviously only
429 * works for one component, i.e. no concurrency */
430 unmap(self:PCU, system:PCU);
431 map(vc_conn:PCU, system:PCU);
432 }
Harald Welte70767382018-02-21 12:16:40 +0100433
434 vc_conn.start(f_handler_init(fn, id, pars));
435 return vc_conn;
436}
437
Harald Welte7484fc42018-02-24 14:09:45 +0100438template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
439 streamId := sid,
440 rsl := rsl
441}
442
443template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
444 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
445 streamId := sid,
446 rsl := rsl
447}
448
Harald Welte70767382018-02-21 12:16:40 +0100449private altstep as_Tguard() runs on ConnHdlr {
450 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200451 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100452 }
453}
454
Harald Welte990a3612019-05-27 14:02:13 +0200455friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
456 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100457}
458
459private function f_trxc_connect() runs on ConnHdlr {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700460 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte70767382018-02-21 12:16:40 +0100461 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700462 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Weltea4d8f352018-03-01 15:47:20 +0100463 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200464 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200465 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +0200466 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700467 g_bts_trxc_conn_id := res.connId;
Harald Welte70767382018-02-21 12:16:40 +0100468}
469
470private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100471 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700472 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100473}
474
475private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100476 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700477 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100478}
479
480/* first function started in ConnHdlr component */
481private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
482runs on ConnHdlr {
483 g_pars := pars;
484 g_chan_nr := pars.chan_nr;
485
486 map(self:L1CTL, system:L1CTL);
487 f_connect_reset(L1CTL);
488
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700489 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100490 f_trxc_connect();
491 }
Harald Welte70767382018-02-21 12:16:40 +0100492
493 g_Tguard.start(pars.t_guard);
494 activate(as_Tguard());
495
496 f_rslem_register(0, pars.chan_nr);
497
498 /* call the user-supplied test case function */
499 fn.apply(id);
500}
501
Harald Welteb1726c92018-03-30 11:56:38 +0200502function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
503 boolean ignore_other := false)
504runs on ConnHdlr return RSL_Message {
505 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100506 timer T := 3.0;
507 RSL.send(tx);
508 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100509 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200510 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100511 T.stop;
512 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100513 }
Harald Welte1eba3742018-02-25 12:48:14 +0100514 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200515 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100516 }
Harald Welte21240e62018-03-11 21:43:35 +0100517 [not ignore_other] as_l1_sacch();
518 [not ignore_other] as_meas_res();
519 [not ignore_other] as_l1_dcch();
520 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200521 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100522 }
Harald Welte21240e62018-03-11 21:43:35 +0100523 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100524 }
Harald Welteb1726c92018-03-30 11:56:38 +0200525 return rx;
526}
527
528function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
529 boolean ignore_other := false)
530runs on ConnHdlr {
531 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100532}
533
Harald Welte8b01c792019-05-19 22:51:25 +0200534function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
535 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
536 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200537 if (encr_enable) {
538 /* append encryption related IEs, if requested */
539 var RSL_IE_EncryptionInfo encr_info;
540 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
541 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
542encr_info})) };
543 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200544 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200545 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100546}
547
Harald Welte70767382018-02-21 12:16:40 +0100548function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100549 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 +0100550 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100551}
552
Harald Welte70767382018-02-21 12:16:40 +0100553private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
554 template RSL_IE_ChannelMode chan_mode,
555 float t_guard := 20.0) := {
556 chan_nr := valueof(chan_nr),
557 chan_mode := valueof(chan_mode),
558 t_guard := t_guard,
559 l1_pars := {
560 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100561 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100562 meas_ul := {
563 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200564 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100565 rxqual := 0
566 },
567 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200568 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100569 rxqual := 0
570 }
571 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200572 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100573 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200574 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200575 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100576 },
Harald Weltee613f962018-04-18 22:38:16 +0200577 spec := omit,
578 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100579}
580
Harald Welte93640c62018-02-25 16:59:33 +0100581/***********************************************************************
582 * Channel Activation / Deactivation
583 ***********************************************************************/
584
Harald Welte70767382018-02-21 12:16:40 +0100585/* Stress test: Do 500 channel activations/deactivations in rapid succession */
586function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
587 for (var integer i := 0; i < 500; i := i+1) {
588 f_rsl_chan_act(g_pars.chan_mode);
589 f_rsl_chan_deact();
590 }
591 setverdict(pass);
592}
593testcase TC_chan_act_stress() runs on test_CT {
594 var ConnHdlr vc_conn;
595 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
596 f_init(testcasename());
597 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
598 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200599 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100600}
601
602/* Test if re-activation of an already active channel fails as expected */
603function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
604 f_rsl_chan_act(g_pars.chan_mode);
605 /* attempt to activate the same lchan again -> expect reject */
606 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
607 alt {
608 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200609 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100610 }
611 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
612 setverdict(pass);
613 }
614 }
615 f_rsl_chan_deact();
616}
617testcase TC_chan_act_react() runs on test_CT {
618 var ConnHdlr vc_conn;
619 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100620 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100621 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
622 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200623 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100624}
625
626/* Attempt to de-activate a channel that's not active */
627function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
628 timer T := 3.0;
629 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
630 T.start;
631 alt {
632 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
633 setverdict(pass);
634 }
635 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200636 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100637 }
638 }
639}
640testcase TC_chan_deact_not_active() runs on test_CT {
641 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100642 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100643 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
644 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200645 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100646}
647
648/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
649function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
650 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
651 alt {
652 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200653 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100654 }
655 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
656 setverdict(pass);
657 }
658 }
659}
660private type record WrongChanNrCase {
661 RslChannelNr chan_nr,
662 charstring description
663}
664private type record of WrongChanNrCase WrongChanNrCases;
665private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
666 chan_nr := chan_nr,
667 description := desc
668}
669
670testcase TC_chan_act_wrong_nr() runs on test_CT {
671 var ConnHdlr vc_conn;
672 var ConnHdlrPars pars;
673
Harald Welte294b0a22018-03-10 23:26:48 +0100674 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100675
676 var WrongChanNrCases wrong := {
677 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
678 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
679 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
680 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
681 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
682 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
683 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
684 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
685 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
686 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
687 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
688 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
689 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
690 };
691
692 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
693 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
694 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
695 vc_conn.done;
696 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100698}
699
Harald Weltee613f962018-04-18 22:38:16 +0200700/* execute the same callback function on a variety of logical channels */
701private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
702 var ConnHdlr vc_conn;
703 f_init(testcasename());
704
705 /* test on each of the channels we have */
706 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
707 pars.chan_nr := valueof(g_AllChanTypes[i]);
708
709 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
710 vc_conn := f_start_handler(fn, pars);
711 vc_conn.done;
712 }
713
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200714 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200715}
716
Harald Welte93640c62018-02-25 16:59:33 +0100717/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100718 * SACCH handling
719 ***********************************************************************/
720
721private function f_exp_sacch(boolean exp) runs on ConnHdlr {
722 timer T_sacch := 3.0;
723 T_sacch.start;
724 alt {
725 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200726 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100727 }
728 [not exp] T_sacch.timeout {
729 setverdict(pass);
730 }
731 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
732 setverdict(pass);
733 }
734 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200735 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100736 }
737 [] L1CTL.receive { repeat; }
738 [] RSL.receive { repeat; }
739 }
740}
741
742/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
743private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
744 f_l1_tune(L1CTL);
745 RSL.clear;
746
747 /* activate the logical channel */
748 f_est_dchan();
749 L1CTL.clear;
750
751 /* check that SACCH actually are received as expected */
752 f_exp_sacch(true);
753
754 /* deactivate SACCH on the logical channel */
755 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
756 f_sleep(1.0);
757 L1CTL.clear;
758
759 /* check that no SACCH are received anymore */
760 f_exp_sacch(false);
761
762 /* release the channel */
763 f_rsl_chan_deact();
764 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
765}
766testcase TC_deact_sacch() runs on test_CT {
767 var ConnHdlr vc_conn;
768 var ConnHdlrPars pars;
769 f_init();
770 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
771 //for (var integer i := 0; i < 1; i := i+1) {
772 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
773 log(testcasename(), ": Starting for ", g_AllChannels[i]);
774 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
775 vc_conn.done;
776 }
777 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200778 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100779}
780
Harald Welte55700662018-03-12 13:15:43 +0100781/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100782private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
783 var L1ctlDlMessage dl;
784 /* check that the specified SI5 value is actually sent */
785 timer T_sacch := 3.0;
786 L1CTL.clear;
787 T_sacch.start;
788 alt {
789 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
790 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
791 if (match(l3, l3_exp)) {
792 setverdict(pass);
793 } else {
794 repeat;
795 }
796 }
797 [] L1CTL.receive { repeat; }
798 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200799 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100800 }
801 }
802}
803
Harald Welte55700662018-03-12 13:15:43 +0100804/* verify that given SACCH payload is not present */
805private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
806 var L1ctlDlMessage dl;
807 /* check that the specified SI5 value is actually sent */
808 timer T_sacch := 3.0;
809 L1CTL.clear;
810 T_sacch.start;
811 alt {
812 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
813 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
814 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200815 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100816 } else {
817 repeat;
818 }
819 }
820 [] L1CTL.receive { repeat; }
821 [] T_sacch.timeout {
822 setverdict(pass);
823 }
824 }
825}
826
Harald Welte629cc6b2018-03-11 17:19:05 +0100827/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100828private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
829 /* Set a known default SACCH filling for SI5 */
830 var octetstring si5 := f_rnd_octstring(19);
831 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
832
833 f_l1_tune(L1CTL);
834 RSL.clear;
835
836 /* activate the logical channel */
837 f_est_dchan();
838
839 /* check that the specified SI5 value is actually sent */
840 f_sacch_present(si5);
841
842 /* release the channel */
843 RSL.clear;
844 f_rsl_chan_deact();
845 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
846}
847testcase TC_sacch_filling() runs on test_CT {
848 var ConnHdlr vc_conn;
849 var ConnHdlrPars pars;
850 f_init();
851 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
852 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
853 log(testcasename(), ": Starting for ", g_AllChannels[i]);
854 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
855 vc_conn.done;
856 }
857 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200858 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100859}
860
Harald Welte629cc6b2018-03-11 17:19:05 +0100861/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100862private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
863 /* Set a known default SACCH filling for SI5 */
864 var octetstring si5 := f_rnd_octstring(19);
865 var octetstring si5_diff := f_rnd_octstring(19);
866 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
867
868 f_l1_tune(L1CTL);
869 RSL.clear;
870
871 log("Activating channel, expecting standard SI5");
872 /* activate the logical channel */
873 f_est_dchan();
874 /* check that the specified SI5 value is actually sent */
875 f_sacch_present(si5);
876
877 /* set channel-specific different SI5 */
878 log("Setting channel specific SACCH INFO, expecting it");
879 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
880 /* check that the specified lchan-specific value is now used */
881 f_sacch_present(si5_diff);
882
883 /* deactivate the channel and re-activate it, this should result in default SI5 */
884 log("De-activating and re-activating channel, expecting standard SI5");
885 f_rsl_chan_deact();
886 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
887 /* Verify that the TRX-wide default SACCH filling is present again */
888 f_sacch_present(si5);
889
890 /* release the channel */
891 RSL.clear;
892 f_rsl_chan_deact();
893 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
894}
895testcase TC_sacch_info_mod() runs on test_CT {
896 var ConnHdlr vc_conn;
897 var ConnHdlrPars pars;
898 f_init();
899 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
900 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
901 log(testcasename(), ": Starting for ", g_AllChannels[i]);
902 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
903 vc_conn.done;
904 }
905 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100907}
908
Harald Welte075d84c2018-03-12 13:07:24 +0100909/* Test SACCH scheduling of multiple different SI message types */
910private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
911 var octetstring si5 := f_rnd_octstring(19);
912 var octetstring si5bis := f_rnd_octstring(19);
913 var octetstring si5ter := f_rnd_octstring(19);
914 var octetstring si6 := f_rnd_octstring(19);
915
916 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
917 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
918 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
919 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
920
921 f_l1_tune(L1CTL);
922 RSL.clear;
923
924 /* activate the logical channel */
925 f_est_dchan();
926 L1CTL.clear;
927
928 /* check that SACCH actually are received as expected */
929 f_sacch_present(si5);
930 f_sacch_present(si5bis);
931 f_sacch_present(si5ter);
932 f_sacch_present(si6);
933
934 /* release the channel */
935 f_rsl_chan_deact();
936 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
937}
938testcase TC_sacch_multi() runs on test_CT {
939 var ConnHdlr vc_conn;
940 var ConnHdlrPars pars;
941 f_init();
942 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
943 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
944 log(testcasename(), ": Starting for ", g_AllChannels[i]);
945 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
946 vc_conn.done;
947 }
948 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200949 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100950}
951
Harald Welte55700662018-03-12 13:15:43 +0100952/* Test if SACH information is modified as expected */
953private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
954 var octetstring si5 := f_rnd_octstring(19);
955 var octetstring si6 := f_rnd_octstring(19);
956
957 /* First, configure both SI5 and SI6 to be transmitted */
958 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
959 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
960
961 f_l1_tune(L1CTL);
962 RSL.clear;
963
964 /* activate the logical channel */
965 f_est_dchan();
966 L1CTL.clear;
967
968 /* check that SACCH actually are received as expected */
969 f_sacch_present(si5);
970 f_sacch_present(si6);
971
972 /* disable SI6 */
973 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
974
975 /* check that SI5 is still transmitted */
976 f_sacch_present(si5);
977 /* check if SI6 is now gone */
978 f_sacch_missing(si6);
979
980 /* release the channel */
981 f_rsl_chan_deact();
982 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
983}
984testcase TC_sacch_multi_chg() runs on test_CT {
985 var ConnHdlr vc_conn;
986 var ConnHdlrPars pars;
987 f_init();
988 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
989 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
990 log(testcasename(), ": Starting for ", g_AllChannels[i]);
991 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
992 vc_conn.done;
993 }
994 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200995 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +0100996}
997
Harald Weltec8d363c2019-05-19 20:36:48 +0200998/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
999private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1000 var octetstring si5 := f_rnd_octstring(19);
1001 var octetstring si6 := f_rnd_octstring(19);
1002 var octetstring si5_specific := f_rnd_octstring(19);
1003 var octetstring si6_specific := f_rnd_octstring(19);
1004
1005 /* First, configure both SI5 and SI6 to be transmitted */
1006 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1007 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1008
1009 f_l1_tune(L1CTL);
1010 RSL.clear;
1011
1012 /* activate channel with different SACCH filling */
1013 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1014 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1015 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1016 }));
1017 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1018 RSL_IE_Body:{sacch_info := sacch_info})) };
1019 f_est_dchan(more_ies := addl_ies);
1020
1021 /* check that SACCH actually are received as expected */
1022 f_sacch_present(si5_specific);
1023 f_sacch_present(si6_specific);
1024
1025 /* release the channel */
1026 f_rsl_chan_deact();
1027 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1028}
1029testcase TC_sacch_chan_act() runs on test_CT {
1030 var ConnHdlr vc_conn;
1031 var ConnHdlrPars pars;
1032 f_init();
1033
1034 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1035 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1036 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1037 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1038 vc_conn.done;
1039 }
1040 /* TODO: do the above in parallel, rather than sequentially? */
1041 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1042}
1043
Harald Welte8b01c792019-05-19 22:51:25 +02001044/* verify that SACCH DL transmission is started only if MS power IE present
1045 * see section 4.1.3 of 3GPP TS 48.058 */
1046private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1047 var octetstring si5 := f_rnd_octstring(19);
1048
1049 f_l1_tune(L1CTL);
1050 RSL.clear;
1051
1052 /* Step 1: Activate ASYNC HO channel without MS power IE */
1053
1054 /* Activate channel on BTS side */
1055 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1056 /* don't perform immediate assignment here, as we're testing non-IA case */
1057 /* enable dedicated mode */
1058 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1059
1060 /* Verify that no DL SACCH is being received */
1061 f_sacch_missing(?);
1062
1063 f_rsl_chan_deact();
1064 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1065
1066
1067 /* Step 2: Activate ASYNC HO channel with MS power IE */
1068
1069 /* Activate channel on BTS side */
1070 var RSL_IE_List addl_ies := {
1071 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1072 };
1073 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1074 /* don't perform immediate assignment here, as we're testing non-IA case */
1075 /* enable dedicated mode */
1076 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1077
1078 /* Verify that DL SACCH is being received */
1079 f_sacch_present(si5);
1080
1081 f_rsl_chan_deact();
1082 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1083}
1084testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1085 var ConnHdlr vc_conn;
1086 var ConnHdlrPars pars;
1087 f_init();
1088
1089 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1090 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1091 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1092 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1093 vc_conn.done;
1094 }
1095 /* TODO: do the above in parallel, rather than sequentially? */
1096 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1097}
1098
1099/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1100 * see section 4.1.4 of 3GPP TS 48.058 */
1101private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1102 var octetstring si5 := f_rnd_octstring(19);
1103 var RSL_IE_List addl_ies;
1104
1105 f_l1_tune(L1CTL);
1106 RSL.clear;
1107
1108 /* Step 1: Activate SYNC HO channel without MS power IE */
1109
1110 /* Activate channel on BTS side */
1111 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1112 /* don't perform immediate assignment here, as we're testing non-IA case */
1113 /* enable dedicated mode */
1114 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1115
1116 /* Verify that no DL SACCH is being received */
1117 f_sacch_missing(?);
1118
1119 f_rsl_chan_deact();
1120 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1121
1122
1123 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1124
1125 /* Activate channel on BTS side */
1126 addl_ies := {
1127 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1128 };
1129 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1130 /* don't perform immediate assignment here, as we're testing non-IA case */
1131 /* enable dedicated mode */
1132 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1133
1134 /* Verify that no DL SACCH is being received */
1135 f_sacch_missing(?);
1136
1137 f_rsl_chan_deact();
1138 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1139
1140
1141 /* Step 2b: Activate SYNC HO channel with TA IE */
1142
1143 /* Activate channel on BTS side */
1144 addl_ies := {
1145 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1146 };
1147 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1148 /* don't perform immediate assignment here, as we're testing non-IA case */
1149 /* enable dedicated mode */
1150 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1151
1152 /* Verify that no DL SACCH is being received */
1153 f_sacch_missing(?);
1154
1155 f_rsl_chan_deact();
1156 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1157
1158
1159 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1160
1161 /* Activate channel on BTS side */
1162 addl_ies := {
1163 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1164 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1165 };
1166 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1167 /* don't perform immediate assignment here, as we're testing non-IA case */
1168 /* enable dedicated mode */
1169 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1170
1171 /* Verify that DL SACCH is being received */
1172 f_sacch_present(si5);
1173
1174 f_rsl_chan_deact();
1175 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1176}
1177testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1178 var ConnHdlr vc_conn;
1179 var ConnHdlrPars pars;
1180 f_init();
1181
1182 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1183 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1184 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1185 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1186 vc_conn.done;
1187 }
1188 /* TODO: do the above in parallel, rather than sequentially? */
1189 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1190}
Harald Welte629cc6b2018-03-11 17:19:05 +01001191
1192
1193/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001194 * RACH Handling
1195 ***********************************************************************/
1196
Harald Welte8c24c2b2018-02-26 08:31:31 +01001197/* like L1SAP_IS_PACKET_RACH */
1198private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001199 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001200 return true;
1201 }
1202 return false;
1203}
1204
1205/* generate a random RACH for circuit-switched */
1206private function f_rnd_ra_cs() return OCT1 {
1207 var OCT1 ra;
1208 do {
1209 ra := f_rnd_octstring(1);
1210 } while (ra_is_ps(ra));
1211 return ra;
1212}
1213
Harald Welte883340c2018-02-28 18:59:29 +01001214/* generate a random RACH for packet-switched */
1215private function f_rnd_ra_ps() return OCT1 {
1216 var OCT1 ra;
1217 do {
1218 ra := f_rnd_octstring(1);
1219 } while (not ra_is_ps(ra));
1220 return ra;
1221}
1222
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001223/* generate a random 11-bit RA (packet-switched only) */
1224private function f_rnd_ra11_ps() return BIT11 {
1225 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1226 return int2bit(ra11, 11);
1227}
1228
Harald Welte8c24c2b2018-02-26 08:31:31 +01001229/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1230testcase TC_rach_content() runs on test_CT {
1231 f_init(testcasename());
1232 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001233 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001234
Harald Welte8c24c2b2018-02-26 08:31:31 +01001235 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001236 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001237 for (var integer i := 0; i < 1000; i := i+1) {
1238 var OCT1 ra := f_rnd_ra_cs();
1239 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1240 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001241 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001242 }
1243 fn_last := fn;
1244
1245 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001246 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001247 alt {
1248 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1249 T.stop;
1250 }
1251 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001252 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001253 }
1254 [] RSL_CCHAN.receive { repeat; }
1255 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001256 test_failed := true;
1257 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001258 }
1259 }
1260 }
Maxba06feb2019-03-05 10:52:46 +01001261 if (test_failed) {
1262 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001263 }
Maxba06feb2019-03-05 10:52:46 +01001264 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001265 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001266}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001267
1268/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1269testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001270 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001271 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001272 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001273 f_l1_tune(L1CTL);
1274
1275 var GsmFrameNumber fn_last := 0;
1276 for (var integer i := 0; i < 1000; i := i+1) {
1277 var OCT1 ra := f_rnd_ra_cs();
1278 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1279 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001280 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001281 }
1282 fn_last := fn;
1283 }
1284 var integer rsl_chrqd := 0;
1285 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001286 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001287 alt {
1288 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1289 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001290 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001291 repeat;
1292 }
1293 [] RSL_CCHAN.receive { repeat; }
1294 [] T.timeout { }
1295 }
1296 if (rsl_chrqd == 1000) {
1297 setverdict(pass);
1298 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001300 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001301 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001302}
1303
Harald Welte3453ab42019-05-24 21:19:58 +02001304private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1305 var charstring bts_str := "bts " & int2str(bts_nr);
1306 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1307}
1308
1309/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1310private template integer tr_rach_slots_per_interval := (90 .. 130);
1311
1312/* Expect 0 RACH load on an idle BTS that has just started up */
1313testcase TC_rach_load_idle_thresh0() runs on test_CT {
1314 var ASP_RSL_Unitdata rx_ud;
1315
1316 f_init_vty_bsc();
1317 /* send load indications even at 0% load */
1318 f_vty_load_ind_thresh(0);
1319 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1320 f_sleep(2.0);
1321
1322 f_init();
1323
1324 timer T := 5.0;
1325 T.start;
1326 alt {
1327 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
1328 setverdict(pass);
1329 repeat;
1330 }
1331 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1332 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1333 repeat;
1334 }
1335 [] RSL_CCHAN.receive {
1336 repeat;
1337 }
1338 [] T.timeout { }
1339 }
1340
1341 f_vty_load_ind_thresh(10);
1342 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1343}
1344
1345/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1346testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1347 var ASP_RSL_Unitdata rx_ud;
1348
1349 f_init_vty_bsc();
1350 f_init();
1351
1352 timer T := 5.0;
1353 T.start;
1354 alt {
1355 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1356 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1357 repeat;
1358 }
1359 [] RSL_CCHAN.receive {
1360 repeat;
1361 }
1362 [] T.timeout {
1363 setverdict(pass);
1364 }
1365 }
1366
1367 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1368}
1369
1370/* Expect 0 RACH load on an idle BTS that has just started up */
1371testcase TC_rach_load_count() runs on test_CT {
1372 var ASP_RSL_Unitdata rx_ud;
1373 var integer load_access_count := 0;
1374
1375 f_init_vty_bsc();
1376 /* send load indications even at 0% load */
1377 f_vty_load_ind_thresh(0);
1378 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1379 f_sleep(2.0);
1380 f_init();
1381
1382 f_init_l1ctl();
1383 f_sleep(1.0);
1384 f_l1_tune(L1CTL);
1385
1386 var GsmFrameNumber fn_last := 0;
1387 for (var integer i := 0; i < 1000; i := i+1) {
1388 var OCT1 ra := f_rnd_ra_cs();
1389 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1390 if (fn == fn_last) {
1391 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1392 }
1393 fn_last := fn;
1394 }
1395
1396 timer T := 5.0;
1397 T.start;
1398 alt {
1399 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
1400 -> value rx_ud {
1401 var RSL_IE_Body ie;
1402 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1403 load_access_count := load_access_count + ie.rach_load.access_count;
1404 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1405 setverdict(fail, "Access count cannot be < Busy count");
1406 }
1407 repeat;
1408 }
1409 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1410 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1411 repeat;
1412 }
1413 [] RSL_CCHAN.receive {
1414 repeat;
1415 }
1416 [] T.timeout { }
1417 }
1418 if (load_access_count == 1000) {
1419 setverdict(pass);
1420 } else {
1421 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1422 }
1423
1424 f_vty_load_ind_thresh(10);
1425 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1426}
1427
1428
1429
Harald Welte54a2a2d2018-02-26 09:14:05 +01001430private function f_main_trxc_connect() runs on test_CT {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001431 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001432 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001433 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Welted3a88a62018-03-01 16:04:52 +01001434 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001435 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001436 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +02001437 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001438 g_bts_trxc_conn_id := res.connId;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001439}
1440
1441private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001442 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001443 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001444 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001445 f_sleep(0.5);
1446
1447 /* Transmit RACH request + wait for confirmation */
1448 var OCT1 ra := f_rnd_ra_cs();
1449 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1450
1451 /* Check for expected result */
1452 timer T := 1.5;
1453 T.start;
1454 alt {
1455 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1456 setverdict(pass);
1457 }
1458 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001459 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001460 }
1461 [] RSL_CCHAN.receive { repeat; }
1462 [not expect_pass] T.timeout {
1463 setverdict(pass);
1464 }
1465 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001466 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001467 }
1468 }
1469}
1470
1471/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1472testcase TC_rach_max_ta() runs on test_CT {
1473 f_init(testcasename());
1474 f_init_l1ctl();
1475 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001476 f_sleep(1.0);
1477
1478 /* default max-ta is 63 (full range of GSM timing advance */
1479
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001480 /* We allow early arrival up to 2 symbols */
1481 f_rach_toffs(-1*256, true);
1482 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001483 f_rach_toffs(-10*256, false);
1484
1485 /* 0 / 32 / 63 bits is legal / permitted */
1486 f_rach_toffs(0, true);
1487 f_rach_toffs(32*256, true);
1488 f_rach_toffs(63*256, true);
1489
1490 /* more than 63 bits is not legal / permitted */
1491 f_rach_toffs(64*256, false);
1492 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001493 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001494}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001495
Harald Welte93640c62018-02-25 16:59:33 +01001496/***********************************************************************
1497 * Measurement Processing / Reporting
1498 ***********************************************************************/
1499
Harald Welte70767382018-02-21 12:16:40 +01001500template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1501 spare := '0'B,
1502 lpd := 0,
1503 sapi := sapi,
1504 c_r := c_r,
1505 ea := true
1506}
1507
Harald Welted879bd92018-03-12 15:01:23 +01001508template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001509 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001510 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001511 len := 0, /* overwritten */
1512 m := false,
1513 el := 1,
1514 payload := pl
1515}
1516
1517/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1518altstep as_l1_sacch() runs on ConnHdlr {
1519 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001520 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001521 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001522 var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp, 0, 0, omit));
Harald Welted879bd92018-03-12 15:01:23 +01001523 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001524 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001525
1526 var L1ctlDataReq data_req := {
1527 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1528 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1529 }
1530 log("Sending Measurement Report: ", data_req);
1531 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001532 repeat;
1533 }
1534}
1535
1536altstep as_l1_dcch() runs on ConnHdlr {
1537 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001538 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001539 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1540 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001541 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1542 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001543 repeat;
1544 }
1545}
1546
1547type record MeasElem {
1548 uint6_t rxlev,
1549 uint3_t rxqual
1550}
1551
1552type record MeasElemFS {
1553 MeasElem full,
1554 MeasElem sub
1555}
1556
1557type record ConnL1Pars {
1558 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001559 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001560 MeasElemFS meas_ul,
1561 int16_t timing_offset_256syms,
1562 uint5_t bs_power_level,
1563 uint5_t ms_power_level,
1564 uint8_t ms_actual_ta
1565}
1566
1567/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1568private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1569 return 63 + (toffs256s/256);
1570}
1571
Harald Welted5684392018-03-10 18:22:04 +01001572private function f_max(integer a, integer b) return integer {
1573 if (a > b) {
1574 return a;
1575 } else {
1576 return b;
1577 }
1578}
1579
1580private function f_min(integer a, integer b) return integer {
1581 if (a < b) {
1582 return a;
1583 } else {
1584 return b;
1585 }
1586}
1587
1588/* compute negative tolerance val-tolerance, ensure >= min */
1589private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1590 val := val - tolerance;
1591 return f_max(val, min);
1592}
1593
1594/* compute positive tolerance val+tolerance, ensure <= max */
1595private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1596 val := val + tolerance;
1597 return f_min(val, max);
1598}
1599
1600/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1601private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1602return template integer {
1603 var template integer ret;
1604 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1605 return ret;
1606}
1607
1608
Harald Welte70767382018-02-21 12:16:40 +01001609/* build a template for matching measurement results against */
1610private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1611 var ConnL1Pars l1p := g_pars.l1_pars;
1612 var template RSL_IE_UplinkMeas ul_meas := {
1613 len := 3,
1614 rfu := '0'B,
1615 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001616 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001617 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001618 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001619 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001620 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1621 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001622 supp_meas_info := omit
1623 };
Harald Welte685d5982018-02-27 20:42:05 +01001624 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001625 ul_meas.len := (3+8);
1626 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001627 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001628 toa256_min := ?,
1629 toa256_max := ?,
1630 toa256_std_dev := ?
1631 }
Harald Welte685d5982018-02-27 20:42:05 +01001632 }
Harald Welte70767382018-02-21 12:16:40 +01001633 var template RSL_IE_BS_Power bs_power := {
1634 reserved := 0,
1635 epc := false,
1636 fpc := false,
1637 power_level := l1p.bs_power_level
1638 };
1639 var template RSL_IE_L1Info l1_info := {
1640 ms_power_lvl := l1p.ms_power_level,
1641 fpc := false,
1642 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001643 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001644 };
1645 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001646 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001647 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1648 ?, t_toffs);
1649}
1650
1651/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001652altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001653 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001654 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001655 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1656 /* increment counter of next to-be-expected meas rep */
1657 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1658 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001659 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001660 repeat;
1661 }
1662 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001663 /* increment counter of next to-be-expected meas rep */
1664 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1665 if (g_first_meas_res) {
1666 g_first_meas_res := false;
1667 repeat;
1668 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001669 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001670 }
Harald Welte70767382018-02-21 12:16:40 +01001671 }
1672 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001673 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001674 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001675 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001676 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001677 }
1678}
1679
Harald Weltee613f962018-04-18 22:38:16 +02001680private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1681 select (rsl_alg_id) {
1682 case (RSL_ALG_ID_A5_0) { return 0; }
1683 case (RSL_ALG_ID_A5_1) { return 1; }
1684 case (RSL_ALG_ID_A5_2) { return 2; }
1685 case (RSL_ALG_ID_A5_3) { return 3; }
1686 case (RSL_ALG_ID_A5_4) { return 4; }
1687 case (RSL_ALG_ID_A5_5) { return 5; }
1688 case (RSL_ALG_ID_A5_6) { return 6; }
1689 case (RSL_ALG_ID_A5_7) { return 7; }
1690 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001691 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1692 /* Make compiler happy by calling mtc.stop here. It is already
1693 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001694 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001695 }
1696 }
1697}
1698
1699private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1700 select (rsl_alg_id) {
1701 case (RSL_ALG_ID_A5_1) { return '000'B; }
1702 case (RSL_ALG_ID_A5_2) { return '001'B; }
1703 case (RSL_ALG_ID_A5_3) { return '010'B; }
1704 case (RSL_ALG_ID_A5_4) { return '011'B; }
1705 case (RSL_ALG_ID_A5_5) { return '100'B; }
1706 case (RSL_ALG_ID_A5_6) { return '101'B; }
1707 case (RSL_ALG_ID_A5_7) { return '110'B; }
1708 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001709 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1710 /* Make compiler happy by calling mtc.stop here. It is already
1711 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001712 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001713 }
1714 }
1715}
1716
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001717/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1718private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1719 var GsmFrameNumber fn;
1720 timer T := 8.0;
1721
1722 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1723 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1724
1725 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1726 /* Send the actual RACH */
1727 fn := f_L1CTL_RACH(L1CTL, ra);
1728
1729 T.start;
1730 alt {
1731 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1732 [] T.timeout {
1733 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1734 }
1735 }
1736 T.stop
1737 return fn;
1738}
Harald Weltee613f962018-04-18 22:38:16 +02001739
Harald Welte70767382018-02-21 12:16:40 +01001740/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001741private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001742 var GsmFrameNumber fn;
1743 var ImmediateAssignment imm_ass;
1744 var integer ra := 23;
1745
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001746 /* Send RACH request and wait for ChanReq */
1747 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001748
1749 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001750 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001751
1752 /* Send IMM.ASS via CCHAN */
1753 var ChannelDescription ch_desc := {
1754 chan_nr := g_pars.chan_nr,
1755 tsc := 7,
1756 h := false,
1757 arfcn := mp_trx0_arfcn,
1758 maio_hsn := omit
1759 };
1760 var MobileAllocation ma := {
1761 len := 0,
1762 ma := ''B
1763 };
1764 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1765 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1766
1767 /* receive IMM.ASS on MS side */
1768 var ImmediateAssignment ia_um;
1769 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1770 /* enable dedicated mode */
1771 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001772 /* enable encryption, if requested */
1773 if (encr_enable) {
1774 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1775 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1776 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001777
1778 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001779}
1780
1781/* establish DChan, verify existance + contents of measurement reports */
1782function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001783 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001784 RSL.clear;
1785
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001786 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001787 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001788 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1789 }
Harald Welte70767382018-02-21 12:16:40 +01001790
1791 f_est_dchan();
1792
1793 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1794 * RSL measurement reports on Abis side */
1795 timer T := 8.0;
1796 T.start;
1797 alt {
1798 [] as_l1_sacch();
1799 [] as_meas_res();
1800 [] as_l1_dcch();
1801 [] L1CTL.receive { repeat; }
1802 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001803 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001804 * of any earlier errors, so if we reach this timeout, we're good */
1805 setverdict(pass);
1806 }
1807 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001808 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001809 }
1810 }
1811 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001812 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001813}
Harald Welte0472ab42018-03-12 15:02:26 +01001814
Harald Welte70767382018-02-21 12:16:40 +01001815testcase TC_meas_res_sign_tchf() runs on test_CT {
1816 var ConnHdlr vc_conn;
1817 var ConnHdlrPars pars;
1818 f_init(testcasename());
1819 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1820 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1821 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1822 vc_conn.done;
1823 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001824 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001825}
1826testcase TC_meas_res_sign_tchh() runs on test_CT {
1827 var ConnHdlr vc_conn;
1828 var ConnHdlrPars pars;
1829 f_init(testcasename());
1830 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1831 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1832 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1833 vc_conn.done;
1834 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001835 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001836}
1837testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1838 var ConnHdlr vc_conn;
1839 var ConnHdlrPars pars;
1840 f_init(testcasename());
1841 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1842 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1843 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1844 vc_conn.done;
1845 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001846 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001847}
1848testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1849 var ConnHdlr vc_conn;
1850 var ConnHdlrPars pars;
1851 f_init(testcasename());
1852 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1853 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1854 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1855 vc_conn.done;
1856 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001857 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001858}
Harald Welte685d5982018-02-27 20:42:05 +01001859testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1860 var ConnHdlr vc_conn;
1861 var ConnHdlrPars pars;
1862 f_init(testcasename());
1863 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1864 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1865 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1866 pars.l1_pars.toa256_enabled := true;
1867 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1868 vc_conn.done;
1869 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001870 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01001871}
1872
Philipp Maier4d1e9c92018-12-20 11:11:56 +01001873/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
1874 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
1875function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
1876 var L1ctlDlMessage l1_dl;
1877 var RSL_IE_MS_Power ms_power;
1878 var RSL_Message rsl;
1879 var uint5_t power_level := 0;
1880
1881 f_l1_tune(L1CTL);
1882 RSL.clear;
1883
1884 f_est_dchan();
1885
1886 ms_power.reserved := 0;
1887 ms_power.fpc_epc := false;
1888
1889 /* Send the first power control command. This will disable any BTS/TRX
1890 * internal power control and switch the MS (which is not in scope of
1891 * this test) to a constant power level. We start with a power level
1892 * of 0 */
1893 ms_power.power_level := power_level;
1894 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1895 RSL.send(rsl);
1896
1897 alt {
1898
1899 /* Pick all SACCH blocks for checking */
1900 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1901
1902 /* The first byte of the L1 header contains the power level.
1903 * The reserved bits and the fpc bit is set to 0, so we may
1904 * compare directly. */
1905 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
1906 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
1907 }
1908
1909 /* Signal a new power level via RSL for the next turn. */
1910 if (power_level < 31) {
1911 power_level := power_level + 1;
1912 ms_power.power_level := power_level;
1913 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1914 RSL.send(rsl);
1915 repeat;
1916 }
1917
1918 }
1919
1920 /* Ignore all other blocks */
1921 [] L1CTL.receive { repeat; }
1922
1923 }
1924
1925 f_rsl_chan_deact();
1926 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1927
1928 setverdict(pass);
1929}
1930
1931testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
1932 var ConnHdlr vc_conn;
1933 var ConnHdlrPars pars;
1934 f_init(testcasename());
1935
1936 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1937 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1938 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
1939 vc_conn.done;
1940 }
1941 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1942}
Harald Welte70767382018-02-21 12:16:40 +01001943
Eric Wild6833cc92019-05-23 19:34:44 +02001944/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
1945TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
1946function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
1947 var L1ctlDlMessage l1_dl;
1948 var uint5_t ta_to_test := 16;
1949
1950
1951 f_l1_tune(L1CTL);
1952 RSL.clear;
1953
1954 /* tell fake_trx to use a given timing offset for all bursts */
1955 f_trx_fake_toffs256(ta_to_test*256);
1956
1957 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
1958
1959
1960 alt {
1961
1962 /* Pick all SACCH blocks for checking */
1963 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1964
1965 /* The second byte of the L1 header contains the TA. */
1966 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
1967 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
1968 }
1969
1970 }
1971
1972 /* Ignore all other blocks */
1973 [] L1CTL.receive { repeat; }
1974
1975 }
1976
1977 f_rsl_chan_deact();
1978 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1979
1980 setverdict(pass);
1981}
1982
1983testcase TC_rsl_chan_initial_ta() runs on test_CT {
1984 var ConnHdlr vc_conn;
1985 var ConnHdlrPars pars;
1986 f_init(testcasename());
1987 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1988 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars);
1989 vc_conn.done;
1990 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1991}
1992
Eric Wilde57e1a62019-05-28 13:30:55 +02001993/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
1994function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
1995 var L1ctlDlMessage l1_dl;
1996 var uint5_t ms_power_level := 7;
1997
1998 var RSL_IE_MS_Power ms_power;
1999 ms_power.reserved := 0;
2000 ms_power.fpc_epc := false;
2001 ms_power.power_level := ms_power_level;
2002
2003 f_l1_tune(L1CTL);
2004 RSL.clear;
2005
2006 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
2007
2008 timer T := 1.0;
2009 T.start;
2010 alt {
2011 /* Pick all SACCH blocks for checking */
2012 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2013 /* The first byte of the L1 header contains the power level.. */
2014 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) {
2015 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2016 }
2017 }
2018 /* Ignore all other blocks */
2019 [] L1CTL.receive { repeat; }
2020 [] T.timeout {
2021 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2022 }
2023 }
2024
2025 f_rsl_chan_deact();
2026 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2027 setverdict(pass);
2028}
2029
2030testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
2031 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2032 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
2033}
2034
Harald Welte0472ab42018-03-12 15:02:26 +01002035/* 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 +01002036private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002037 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002038 RSL.clear;
2039
2040 f_est_dchan();
2041 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01002042 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01002043
2044 timer T := 40.0;
2045 T.start;
2046 alt {
2047 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
2048 setverdict(pass)
2049 }
2050 [] RSL.receive { repeat };
2051 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002052 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01002053 }
2054 }
2055 f_rsl_chan_deact();
2056}
2057testcase TC_conn_fail_crit() runs on test_CT {
2058 var ConnHdlr vc_conn;
2059 var ConnHdlrPars pars;
2060 f_init(testcasename());
2061 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
2062 pars.t_guard := 60.0;
2063 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
2064 vc_conn.done;
2065}
2066
Harald Welte93640c62018-02-25 16:59:33 +01002067/***********************************************************************
2068 * Paging
2069 ***********************************************************************/
2070
Harald Welte68e495b2018-02-25 00:05:57 +01002071function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
2072 if (tmsi == 'FFFFFFFF'O) {
2073 return true;
2074 } else {
2075 return false;
2076 }
2077}
Harald Welte70767382018-02-21 12:16:40 +01002078
Philipp Maier82cb0b12018-08-31 14:41:39 +02002079type record allowedFn { integer frame_nr }
2080template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2081template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2082template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2083template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2084template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2085template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2086template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2087template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2088function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2089{
2090 var integer frame_nr_51;
2091 frame_nr_51 := frame_nr mod 51
2092
2093 var allowedFn fn_check;
2094 fn_check.frame_nr := frame_nr_51;
2095
2096 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002097 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002098 return;
2099 }
2100
2101 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2102 return;
2103 }
2104 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2105 return;
2106 }
2107 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2108 return;
2109 }
2110 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2111 return;
2112 }
2113 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2114 return;
2115 }
2116 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2117 return;
2118 }
2119 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2120 return;
2121 }
2122 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2123 return;
2124 }
2125
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002126 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002127 return;
2128}
2129
2130altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids, PagingTestCfg cfg)
Harald Welte68e495b2018-02-25 00:05:57 +01002131runs on test_CT {
2132 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002133 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002134 repeat;
2135 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002136 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002137 var octetstring without_plen :=
2138 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2139 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002140
2141 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2142
Harald Welte68e495b2018-02-25 00:05:57 +01002143 if (match(rr, tr_PAGING_REQ1)) {
2144 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2145 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2146 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
2147 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2148 }
2149 } else if (match(rr, tr_PAGING_REQ2)) {
2150 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2151 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2152 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2153 }
2154 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2155 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2156 }
2157 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
2158 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2159 }
2160 } else if (match(rr, tr_PAGING_REQ3)) {
2161 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2162 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2163 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2164 }
2165 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2166 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2167 }
2168 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2169 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2170 }
2171 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2172 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2173 }
2174 }
2175 repeat;
2176 }
2177}
2178
2179type record PagingTestCfg {
2180 boolean combined_ccch,
2181 integer bs_ag_blks_res,
2182 float load_factor,
2183 boolean exp_load_ind,
2184 boolean exp_overload,
2185 boolean use_tmsi
2186}
2187
2188type record PagingTestState {
2189 integer num_paging_sent,
2190 integer num_paging_rcv_msgs,
2191 integer num_paging_rcv_ids,
2192 integer num_overload
2193}
2194
2195/* receive + ignore RSL RF RES IND */
2196altstep as_rsl_res_ind() runs on test_CT {
2197 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
2198 repeat;
2199 }
2200}
2201
2202/* Helper function for paging related testing */
2203private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
2204 f_init(testcasename());
2205 f_init_l1ctl();
2206 f_l1_tune(L1CTL);
2207
2208 var PagingTestState st := {
2209 num_paging_sent := 0,
2210 num_paging_rcv_msgs := 0,
2211 num_paging_rcv_ids := 0,
2212 num_overload := 0
2213 };
2214
2215 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2216 var float max_pch_imsi_per_sec;
2217 if (cfg.use_tmsi) {
2218 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2219 } else {
2220 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2221 }
2222 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2223 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002224 var float time_total := 20.0;
2225 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2226 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002227
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002228 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2229 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002230
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002231 timer T_itv := 0.0;
2232 T_itv.start;
2233 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002234 alt {
2235 /* check for presence of CCCH LOAD IND (paging load) */
2236 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
2237 st.num_overload := st.num_overload + 1;
2238 repeat;
2239 }
2240 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002241 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01002242 }
2243 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
2244 log("Rx LOAD_IND");
2245 /* FIXME: analyze/verify interval + contents */
2246 repeat;
2247 }
2248 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02002249 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002250 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002251 [] T_itv.timeout {
2252 /* Send paging cmds based on elapsed time */
2253 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
2254 while (st.num_paging_sent < new_sent) {
2255 /* build mobile Identity */
2256 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2257 if (cfg.use_tmsi) {
2258 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2259 } else {
2260 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
2261 }
2262 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2263 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2264
2265 /* Send RSL PAGING COMMAND */
2266 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
2267
2268 st.num_paging_sent := st.num_paging_sent + 1;
2269 }
2270 if (st.num_paging_sent < pkt_total) {
2271 /* Wait for interval to next PAGING COMMAND */
2272 var float time_now := T_total.read;
2273 var float next_sched := int2float(st.num_paging_sent)*interval;
2274 if (next_sched > time_now) {
2275 T_itv.start(next_sched - time_now);
2276 } else {
2277 T_itv.start(0.0);
2278 }
2279 } else {
2280 /* We are done, no need to keep counting */
2281 T_total.stop;
2282 }
2283 }
2284 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01002285 [] as_rsl_res_ind();
2286 }
2287 }
2288
2289 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
2290 timer T_wait := 18.0;
2291 T_wait.start;
2292 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02002293 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002294 [] L1CTL.receive { repeat; }
2295 /* 65535 == empty paging queue, we can terminate*/
2296 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
2297 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
2298 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01002300 }
2301 [] as_rsl_res_ind();
2302 }
2303
2304 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
2305 " rcvd_ids=", st.num_paging_rcv_ids);
2306 return st;
2307}
2308
2309/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
2310 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2311 * - that CCCH LOAD IND (PCH) are being generated
2312 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2313testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002314 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002315 var PagingTestCfg cfg := {
2316 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002317 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002318 load_factor := 0.8,
2319 exp_load_ind := true,
2320 exp_overload := false,
2321 use_tmsi := false
2322 };
2323 var PagingTestState st := f_TC_paging(cfg);
2324 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002325 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2326 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002327 } else {
2328 setverdict(pass);
2329 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002330 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002331}
2332
2333/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
2334 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2335 * - that CCCH LOAD IND (PCH) are being generated
2336 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2337testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002338 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002339 var PagingTestCfg cfg := {
2340 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002341 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002342 load_factor := 0.8,
2343 exp_load_ind := true,
2344 exp_overload := false,
2345 use_tmsi := true
2346 };
2347 var PagingTestState st := f_TC_paging(cfg);
2348 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002349 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2350 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002351 } else {
2352 setverdict(pass);
2353 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002354 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002355}
2356
2357/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
2358 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2359 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2360 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2361testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002362 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002363 var PagingTestCfg cfg := {
2364 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002365 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002366 load_factor := 2.0,
2367 exp_load_ind := true,
2368 exp_overload := true,
2369 use_tmsi := false
2370 };
2371 var PagingTestState st := f_TC_paging(cfg);
2372 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
2373 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002374 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002375 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002376 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 +01002377 } else {
2378 setverdict(pass);
2379 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002380 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002381}
2382
2383/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
2384 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2385 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2386 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2387testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002388 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002389 var PagingTestCfg cfg := {
2390 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002391 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002392 load_factor := 2.0,
2393 exp_load_ind := true,
2394 exp_overload := true,
2395 use_tmsi := true
2396 };
2397 var PagingTestState st := f_TC_paging(cfg);
2398 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
2399 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002400 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002401 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002402 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 +01002403 } else {
2404 setverdict(pass);
2405 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002406 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002407}
2408
2409
Harald Welte93640c62018-02-25 16:59:33 +01002410/***********************************************************************
2411 * Immediate Assignment / AGCH
2412 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02002413const MobileAllocation c_MA_null := {
2414 len := 0,
2415 ma := ''B
2416}
Harald Welte93640c62018-02-25 16:59:33 +01002417
Harald Weltee8d750e2018-06-10 21:41:35 +02002418template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
2419 uint12_t arfcn := 871) := {
2420 chan_nr := chan_nr,
2421 tsc := tsc,
2422 h := false,
2423 arfcn := arfcn,
2424 maio_hsn := omit
2425}
2426
2427private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
2428 return int2str(num_tx) & " sent, "
2429 & int2str(num_rx) & " received, "
2430 & int2str(num_del) & " deleted";
2431}
2432
2433private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
2434 var L1ctlDlMessage l1_dl;
2435 timer T := 10.0;
2436 var integer num_tx := 0;
2437 var integer num_rx := 0;
2438 var integer num_del := 0;
2439 var charstring res_str;
2440 var float rx_ratio;
2441
Harald Welte68e495b2018-02-25 00:05:57 +01002442 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02002443 f_init_l1ctl();
2444 f_l1_tune(L1CTL);
2445
2446 for (var integer i := 0; i < num_total; i := i+1) {
2447 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
2448 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
2449 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01002450 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02002451 num_tx := num_tx+1;
2452 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01002453 }
2454 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02002455 T.start;
2456 alt {
2457 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
2458 num_del := num_del+1;
2459 repeat;
2460 }
2461 [] RSL_CCHAN.receive {
2462 repeat;
2463 }
2464 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
2465 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2466 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
2467 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
2468 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002469 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02002470 } else {
2471 num_rx := num_rx+1;
2472 }
2473 repeat;
2474 }
2475 [] L1CTL.receive { repeat; }
2476 [] T.timeout { }
2477 }
2478 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
2479 log("AGCH test: " & res_str);
2480 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002481 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002482 }
2483 rx_ratio := int2float(num_rx) / int2float(num_tx);
2484 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002485 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 +02002486 } else {
2487 setverdict(pass);
2488 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002490}
2491
Harald Weltee8d750e2018-06-10 21:41:35 +02002492/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
2493testcase TC_imm_ass_1000_20ms() runs on test_CT {
2494 f_TC_imm_ass(1000, 0.02, 0.25);
2495}
2496
2497/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
2498testcase TC_imm_ass_200_0ms() runs on test_CT {
2499 f_TC_imm_ass(200, 0.0, 0.05);
2500}
2501
2502/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
2503testcase TC_imm_ass_200_76ms() runs on test_CT {
2504 f_TC_imm_ass(150, 0.076, 1.00);
2505}
2506
2507
2508
Harald Welte48494ca2018-02-25 16:59:50 +01002509/***********************************************************************
2510 * BCCH
2511 ***********************************************************************/
2512
2513/* tuple of Frame Number + decoded SI */
2514type record SystemInformationFn {
2515 GsmFrameNumber frame_number,
2516 SystemInformation si
2517}
2518
2519/* an arbitrary-length vector of decoded SI + gsmtap header */
2520type record of SystemInformationFn SystemInformationVector;
2521
2522/* an array of SI-vectors indexed by TC value */
2523type SystemInformationVector SystemInformationVectorPerTc[8];
2524
2525/* determine if a given SI vector contains given SI type at least once */
2526function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2527 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2528 var integer fn_mod51 := arr[i].frame_number mod 51;
2529 if (not bcch_ext and fn_mod51 == 2 or
2530 bcch_ext and fn_mod51 == 6) {
2531 if (arr[i].si.header.message_type == key) {
2532 return true;
2533 }
2534 }
2535 }
2536 return false;
2537}
2538
2539/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2540function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2541 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002542 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002543 }
2544}
2545
2546/* check if a given SI vector contains given SI type at least once on any TC */
2547function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2548 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2549 if (f_si_vecslot_contains(arr[tc], key) or
2550 f_si_vecslot_contains(arr[tc], key, true)) {
2551 return true;
2552 }
2553 }
2554 return false;
2555}
2556
2557/* determine if a given SI vector contains given SI type at least N of M times */
2558function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2559 var integer count := 0;
2560 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002561 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01002562 }
2563 for (var integer i:= 0; i < m; i := i + 1) {
2564 var integer fn_mod51 := arr[i].frame_number mod 51;
2565 if (not bcch_ext and fn_mod51 == 2 or
2566 bcch_ext and fn_mod51 == 6) {
2567 if (arr[i].si.header.message_type == key) {
2568 count := count + 1;
2569 }
2570 }
2571 }
2572 if (count >= n) {
2573 return true;
2574 } else {
2575 return false;
2576 }
2577}
2578
2579/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2580function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2581 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002582 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002583 }
2584}
2585
2586/* determine if a given SI vector contains given SI type at least once */
2587function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2588 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2589 var integer fn_mod51 := arr[i].frame_number mod 51;
2590 if (not bcch_ext and fn_mod51 == 2 or
2591 bcch_ext and fn_mod51 == 6) {
2592 if (arr[i].si.header.message_type != key) {
2593 return false;
2594 }
2595 }
2596 }
2597 return true;
2598}
2599
2600/* ensure a given TC slot of the SI vector contains only given SI type */
2601function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2602 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002603 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002604 }
2605}
2606
2607/* SI configuration of cell, against which we validate actual SI messages */
2608type set SystemInformationConfig {
2609 boolean bcch_extended,
2610 boolean si1_present,
2611 boolean si2bis_present,
2612 boolean si2ter_present,
2613 boolean si2quater_present,
2614 boolean si7_present,
2615 boolean si8_present,
2616 boolean si9_present,
2617 boolean si13_present,
2618 boolean si13alt_present,
2619 boolean si15_present,
2620 boolean si16_present,
2621 boolean si17_present,
2622 boolean si2n_present,
2623 boolean si21_present,
2624 boolean si22_present
2625}
2626
2627/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2628function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2629 var integer i;
2630 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2631 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002632 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01002633 }
2634 }
2635 if (cfg.si1_present) {
2636 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2637 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2638 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2639 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2640 /* make sure *ALL* contain SI1 */
2641 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2642 }
2643 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2644 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2645 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2646 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2647 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2648 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2649
2650 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2651 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2652 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2653 * consecutive occurrences of TC = 4. */
2654 if (cfg.si2bis_present and not cfg.si2ter_present) {
2655 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2656 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2657 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2658 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2659 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2660 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2661 }
2662
2663 if (cfg.si7_present or cfg.si8_present) {
2664 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2665 * if System Information type 4 does not contain all information needed for cell
2666 * selection and reselection. */
2667 if (not cfg.bcch_extended) {
2668 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2669 }
2670 if (cfg.si7_present) {
2671 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2672 }
2673 if (cfg.si8_present) {
2674 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2675 }
2676 }
2677
2678 if (cfg.si2quater_present) {
2679 /* iii) System information type 2 quater is sent if needed, as determined by the system
2680 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2681 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2682 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2683 * within any of 4 consecutive occurrences of TC = 5. */
2684 if (not (cfg.bcch_extended)) {
2685 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2686 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2687 } else {
2688 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2689 }
2690 } else {
2691 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2692 }
2693 }
2694 if (cfg.si9_present) {
2695 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2696 * in system information type 3 as defined in 3GPP TS 44.018. */
2697 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2698 }
2699 if (cfg.si13_present) {
2700 /* vii) System Information type 13 is only related to the GPRS service. System Information
2701 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2702 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2703 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2704 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2705 * within any of 4 consecutive occurrences of TC=4. */
2706 if (not cfg.bcch_extended) {
2707 log("not-bccch-extended");
2708 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2709 } else {
2710 log("bccch-extended");
2711 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2712 }
2713 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002714 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002715 }
2716 }
2717 if (cfg.si16_present or cfg.si17_present) {
2718 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2719 * should not be sent in a cell where network sharing is used (see rule xv). */
2720 if (cfg.si22_present) {
2721 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2722 }
2723 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002724 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002725 }
2726 if (not cfg.bcch_extended) {
2727 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2728 }
2729 if (cfg.si16_present) {
2730 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2731 }
2732 if (cfg.si17_present) {
2733 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2734 }
2735 }
2736
2737 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2738 * broadcast information. The frequency with which they are sent is determined by the
2739 * system operator. System Information type 9 identifies the scheduling of System
2740 * Information type 18 and 20 messages. */
2741
2742 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2743 * Information Type 19 is present, then its scheduling shall be indicated in System
2744 * Information Type 9. */
2745
2746 if (cfg.si15_present) {
2747 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2748 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2749 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2750 * 4 consecutive occurrences of TC = 1. */
2751 if (not cfg.bcch_extended) {
2752 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2753 } else {
2754 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2755 }
2756 }
2757 if (cfg.si13alt_present) {
2758 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2759 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2760 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2761 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2762 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2763 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2764 * of TC = 4. */
2765 if (cfg.si13_present) {
2766 testcase.stop("Error: Cannot have SI13alt and SI13");
2767 }
2768 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002769 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002770 }
2771 if (not cfg.bcch_extended) {
2772 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2773 } else {
2774 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2775 }
2776 }
2777 if (cfg.si2n_present) {
2778 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2779 * as determined by the system operator. In the case that the message is sent on the
2780 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2781 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2782 * consecutive occurrences of TC = 4. */
2783 if (not cfg.bcch_extended) {
2784 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2785 } else {
2786 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2787 }
2788 }
2789 if (cfg.si21_present) {
2790 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2791 * determined by the system operator. If Extended Access Barring is in use in the cell
2792 * then this message is sent at least once within any of 4 consecutive occurrences of
2793 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2794 * cell then this message shall only be sent on BCCH Ext. */
2795 if (not cfg.bcch_extended) {
2796 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2797 } else {
2798 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2799 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002800 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01002801 }
2802 }
2803 }
2804 if (cfg.si22_present) {
2805 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2806 * should not be sent in a cell where SoLSA is used (see rule viii). System
2807 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2808 * =2 and TC=6. */
2809 if (cfg.si16_present or cfg.si17_present) {
2810 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2811 }
2812 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2813 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002814 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002815 }
2816 if (not cfg.bcch_extended) {
2817 testcase.stop("Error: SI22 requires BCCH Extd!");
2818 } else {
2819 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2820 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2821 }
2822 }
2823}
2824
2825/* sample Systme Information for specified duration via L1CTL */
2826function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2827 timer T := duration;
2828 var SystemInformationVectorPerTc si_per_tc;
2829 var L1ctlDlMessage l1_dl;
2830
2831 /* initialize all per-TC vectors empty */
2832 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2833 si_per_tc[i] := {};
2834 }
2835
2836 /* flush all previous L1 queued msgs */
2837 pt.clear;
2838
2839 T.start;
2840 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002841 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002842 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2843 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2844 log("Ignoring non-RR SI ", l1_dl);
2845 repeat;
2846 }
2847 var SystemInformationFn sig := {
2848 frame_number := l1_dl.dl_info.frame_nr,
2849 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2850 }
2851 var integer tc := f_gsm_compute_tc(sig.frame_number);
2852 log("SI received at TC=", tc, ": ", sig.si);
2853 /* append to the per-TC bucket */
2854 si_per_tc[tc] := si_per_tc[tc] & { sig };
2855 repeat;
2856 }
2857 [] pt.receive { repeat; }
2858 [] T.timeout { }
2859 }
2860
2861 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2862 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2863 }
2864 log("si_per_tc=", si_per_tc);
2865 return si_per_tc;
2866}
2867
2868/* helper function: Set given SI via RSL + validate scheduling.
2869 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2870function f_TC_si_sched() runs on test_CT {
2871 var SystemInformationVectorPerTc si_per_tc;
2872 f_init_l1ctl();
2873 f_l1_tune(L1CTL);
2874
2875 /* Sample + Validate Scheduling */
2876 si_per_tc := f_l1_sample_si(L1CTL);
2877 f_validate_si_scheduling(si_cfg, si_per_tc);
2878
2879 setverdict(pass);
2880}
2881
2882testcase TC_si_sched_default() runs on test_CT {
2883 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002884 /* 2+3+4 are mandatory and set in f_init() */
2885 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002886 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01002887}
2888
2889testcase TC_si_sched_1() runs on test_CT {
2890 f_init();
2891 si_cfg.si1_present := true;
2892 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002893 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002894 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002895}
2896
2897testcase TC_si_sched_2bis() runs on test_CT {
2898 f_init();
2899 si_cfg.si2bis_present := true;
2900 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2901 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002902 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002903}
2904
2905testcase TC_si_sched_2ter() runs on test_CT {
2906 f_init();
2907 si_cfg.si2ter_present := true;
2908 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2909 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002910 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002911}
2912
2913testcase TC_si_sched_2ter_2bis() runs on test_CT {
2914 f_init();
2915 si_cfg.si2bis_present := true;
2916 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2917 si_cfg.si2ter_present := true;
2918 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2919 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002920 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002921}
2922
2923testcase TC_si_sched_2quater() runs on test_CT {
2924 f_init();
2925 si_cfg.si2quater_present := true;
2926 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2927 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002928 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002929}
2930
2931testcase TC_si_sched_13() runs on test_CT {
2932 f_init();
2933 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002934 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002935 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002936 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002937}
2938
2939testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2940 f_init();
2941 si_cfg.si2bis_present := true;
2942 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2943 si_cfg.si2ter_present := true;
2944 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2945 si_cfg.si2quater_present := true;
2946 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2947 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002948 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002949 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002950 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002951}
2952
2953
Harald Welte68e495b2018-02-25 00:05:57 +01002954testcase TC_bcch_info() runs on test_CT {
2955 f_init(testcasename());
2956 /* FIXME: enable / disable individual BCCH info */
2957 //ts_RSL_BCCH_INFO(si_type, info);
2958 /* expect no ERROR REPORT after either of them *
2959 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002960 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002961}
2962
Harald Welte93640c62018-02-25 16:59:33 +01002963/***********************************************************************
2964 * Low-Level Protocol Errors / ERROR REPORT
2965 ***********************************************************************/
2966
Harald Welte01d982c2018-02-25 01:31:40 +01002967private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2968 timer T := 5.0;
2969 T.start;
2970 alt {
2971 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2972 setverdict(pass);
2973 }
2974 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002975 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002976 }
2977 [] RSL_CCHAN.receive {
2978 repeat;
2979 }
2980 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002981 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002982 }
2983 }
2984}
2985
2986/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2987testcase TC_rsl_protocol_error() runs on test_CT {
2988 f_init(testcasename());
2989 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2990 rsl.ies := omit;
2991 RSL_CCHAN.send(ts_RSL_UD(rsl));
2992
2993 f_exp_err_rep(RSL_ERR_PROTO);
2994}
2995
2996/* Provoke a mandatory IE error and match on ERROR REPORT */
2997testcase TC_rsl_mand_ie_error() runs on test_CT {
2998 f_init(testcasename());
2999
3000 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3001 rsl.ies := { rsl.ies[0] };
3002 RSL_CCHAN.send(ts_RSL_UD(rsl));
3003
3004 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
3005}
3006
3007/* Provoke an IE content error and match on ERROR REPORT */
3008testcase TC_rsl_ie_content_error() runs on test_CT {
3009 f_init(testcasename());
3010 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3011 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
3012 RSL_CCHAN.send(ts_RSL_UD(rsl));
3013
3014 f_exp_err_rep(RSL_ERR_IE_CONTENT);
3015}
3016
Harald Welteee25aae2019-05-19 14:32:37 +02003017/* attempt to activate channel with wrong RSL Message Discriminator IE */
3018function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
3019 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3020 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
3021 RSL.send(rsl);
3022 f_rslem_unregister(0, g_chan_nr);
3023}
3024testcase TC_err_rep_wrong_mdisc() runs on test_CT {
3025 var ConnHdlr vc_conn;
3026 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3027
3028 f_init(testcasename());
3029
3030 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
3031 vc_conn.done;
3032 f_exp_err_rep(RSL_ERR_MSG_DISCR);
3033
3034 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3035}
3036
3037/* Send messages with wrong message type */
3038function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
3039 var template (value) RSL_Message rsl_tx;
3040 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3041 rsl_tx.msg_type := RSL_MT_NOT_CMD;
3042 RSL.send(rsl_tx);
3043 f_rslem_unregister(0, g_chan_nr);
3044}
3045function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
3046 var template (value) RSL_Message rsl_tx;
3047 /* we first have to activate the dedicated channel */
3048 f_rsl_chan_act(g_pars.chan_mode);
3049 /* ... to then send an invalid RLL message */
3050 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
3051 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
3052 RSL.send(rsl_tx);
3053 f_rslem_unregister(0, g_chan_nr);
3054}
3055testcase TC_err_rep_wrong_msg_type() runs on test_CT {
3056 var ConnHdlr vc_conn;
3057 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3058 var template (value) RSL_Message rsl_tx;
3059
3060 f_init(testcasename());
3061
3062 /* Common Channel with wrong message type */
3063 RSL_CCHAN.clear;
3064 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3065 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
3066 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3067 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3068
3069 /* TRX Management */
3070 RSL_CCHAN.clear;
3071 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
3072 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
3073 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3074 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3075
3076 /* Dedicated Channel */
3077 RSL_CCHAN.clear;
3078 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3079 vc_conn.done;
3080 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3081
3082 /* RLL */
3083 RSL_CCHAN.clear;
3084 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3085 vc_conn.done;
3086 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3087}
3088
3089/* Send messages in wrong sequence (RLL to an inactive lchan) */
3090function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3091 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3092 f_rslem_unregister(0, g_chan_nr);
3093}
3094testcase TC_err_rep_wrong_sequence() runs on test_CT {
3095 var ConnHdlr vc_conn;
3096 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3097
3098 f_init(testcasename());
3099
3100 RSL_CCHAN.clear;
3101 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3102 vc_conn.done;
3103 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3104}
3105
Harald Welte93640c62018-02-25 16:59:33 +01003106/***********************************************************************
3107 * IPA CRCX/MDCX/DLCS media stream handling
3108 ***********************************************************************/
3109
Harald Weltea871a382018-02-25 02:03:14 +01003110/* Send IPA DLCX to inactive lchan */
3111function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003112 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3113 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003114}
3115testcase TC_ipa_dlcx_not_active() runs on test_CT {
3116 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3117 f_init(testcasename());
3118 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3119 vc_conn.done;
3120}
Harald Welte68e495b2018-02-25 00:05:57 +01003121
Harald Weltea3f1df92018-02-25 12:49:55 +01003122/* Send IPA CRCX twice to inactive lchan */
3123function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3124 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3125 "IPA CRCX ACK");
3126 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3127 "IPA CRCX NACK");
3128}
3129testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3130 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3131 f_init(testcasename());
3132 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3133 vc_conn.done;
3134}
3135
3136/* Regular sequence of CRCX/MDCX/DLCX */
3137function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3138 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3139 "IPA CRCX ACK");
3140 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3141 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3142 var uint7_t rtp_pt2 := f_rnd_int(127);
3143 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3144 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3145 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3146 "IPA MDCX ACK");
3147 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3148 "IPA DLCX ACK");
3149}
3150testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3151 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3152 f_init(testcasename());
3153 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3154 vc_conn.done;
3155}
3156
Harald Welte3ae11da2018-02-25 13:36:06 +01003157/* Sequence of CRCX, 2x MDCX, DLCX */
3158function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3159 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3160 "IPA CRCX ACK");
3161 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3162 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3163 var uint7_t rtp_pt2 := f_rnd_int(127);
3164 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3165 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3166 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3167 "IPA MDCX ACK");
3168 /* Second MDCX */
3169 remote_ip := f_rnd_int(c_UINT32_MAX);
3170 remote_port := f_rnd_int(c_UINT16_MAX);
3171 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3172 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3173 "IPA MDCX ACK");
3174 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3175 "IPA DLCX ACK");
3176}
3177testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3178 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3179 f_init(testcasename());
3180 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3181 vc_conn.done;
3182}
3183
Harald Welte9912eb52018-02-25 13:30:15 +01003184/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3185function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3186 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3187 "IPA CRCX NACK");
3188}
3189testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3190 var ConnHdlrPars pars;
3191 var ConnHdlr vc_conn;
3192 f_init(testcasename());
3193
3194 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3195 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3196 vc_conn.done;
3197
3198 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3199 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3200 vc_conn.done;
3201}
3202
Harald Weltea3f1df92018-02-25 12:49:55 +01003203
Harald Welte883340c2018-02-28 18:59:29 +01003204/***********************************************************************
3205 * PCU Socket related tests
3206 ***********************************************************************/
3207
Harald Welte07bd2d22019-05-25 11:03:30 +02003208/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003209friend 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 +01003210runs on test_CT {
3211 timer T := 3.0;
3212
3213 /* we don't expect any RTS.req before PDCH are active */
3214 T.start;
3215 alt {
3216 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003217 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003218 }
3219 [] PCU.receive { repeat; }
3220 [] T.timeout { }
3221 }
3222
3223 /* Send PDCH activate request for known PDCH timeslot */
3224 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3225
3226 /* we now expect RTS.req for this timeslot (only) */
3227 T.start;
3228 alt {
3229 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
3230 setverdict(pass);
3231 }
3232 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3233 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01003235 }
3236 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003237 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01003238 }
3239 [] PCU.receive { repeat; }
3240 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003241 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003242 }
3243 [not exp_success] T.timeout {
3244 setverdict(pass);
3245 }
3246 }
3247}
3248
Harald Welte07bd2d22019-05-25 11:03:30 +02003249/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003250friend 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 +01003251runs on test_CT {
3252 timer T := 3.0;
3253
3254 /* Send PDCH activate request for known PDCH timeslot */
3255 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
3256
3257 PCU.clear;
3258 /* we now expect no RTS.req for this timeslot */
3259 T.start;
3260 alt {
3261 [] 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 +02003262 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003263 }
3264 [] PCU.receive { repeat; }
3265 [] T.timeout {
3266 setverdict(pass);
3267 }
3268 }
3269}
3270
Harald Weltead033dc2019-05-25 17:28:16 +02003271friend function f_init_pcu_test() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003272 f_init();
3273 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
3274}
3275
Harald Welte883340c2018-02-28 18:59:29 +01003276/* PDCH activation via PCU socket; check for presence of RTS.req */
3277testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003278 f_init_pcu_test();
3279
Harald Welte883340c2018-02-28 18:59:29 +01003280 f_TC_pcu_act_req(0, 0, 7, true);
3281}
3282
3283/* PDCH activation via PCU socket on non-PDCU timeslot */
3284testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003285 f_init_pcu_test();
3286
Harald Welte883340c2018-02-28 18:59:29 +01003287 f_TC_pcu_act_req(0, 0, 1, false);
3288}
3289
3290/* PDCH activation via PCU socket on wrong BTS */
3291testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003292 f_init_pcu_test();
3293
Harald Welte883340c2018-02-28 18:59:29 +01003294 f_TC_pcu_act_req(23, 0, 7, false);
3295}
3296
3297/* PDCH activation via PCU socket on wrong TRX */
3298testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003299 f_init_pcu_test();
3300
Harald Welte883340c2018-02-28 18:59:29 +01003301 f_TC_pcu_act_req(0, 23, 7, false);
3302}
3303
3304/* PDCH deactivation via PCU socket; check for absence of RTS.req */
3305testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003306 f_init_pcu_test();
3307
Harald Welte883340c2018-02-28 18:59:29 +01003308 /* Activate PDCH */
3309 f_TC_pcu_act_req(0, 0, 7, true);
3310 f_sleep(1.0);
3311 /* and De-Activate again */
3312 f_TC_pcu_deact_req(0, 0, 7);
3313}
3314
3315/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
3316testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003317 f_init_pcu_test();
3318
Harald Welte883340c2018-02-28 18:59:29 +01003319 f_TC_pcu_deact_req(0, 0, 1);
3320}
3321
3322/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
3323testcase TC_pcu_ver_si13() runs on test_CT {
3324 const octetstring si13 := '00010203040506070909'O;
3325 var PCUIF_send_data sd;
3326 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01003327 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003328
3329 /* Set SI13 via RSL */
3330 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01003331
Harald Welte883340c2018-02-28 18:59:29 +01003332 T.start;
3333 alt {
3334 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
3335 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
3336 setverdict(pass);
3337 } else {
3338 repeat;
3339 }
3340 }
3341 [] PCU.receive { repeat; }
3342 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003343 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01003344 }
3345 }
3346}
3347
3348private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
3349
3350/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02003351friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01003352 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
3353runs on test_CT
3354{
3355 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
3356 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
3357}
3358
3359/* 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 +02003360friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
3361 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01003362runs on test_CT
3363{
3364 var PCUIF_send_data sd;
3365
3366 timer T := 3.0;
3367 T.start;
3368 alt {
3369 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3370 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
3371 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
3372 sd.data.u.rts_req.fn, sapi, data);
3373 }
3374 [] PCU.receive { repeat; }
3375 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003376 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01003377 }
3378 }
3379}
3380
3381/* Send DATA.req on invalid BTS */
3382testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02003383 var TfiUsfArr tua := f_TfiUsfArrInit();
3384 var octetstring data := '0000'O & f_rnd_octstring(21);
3385
3386 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01003387
Harald Welte883340c2018-02-28 18:59:29 +01003388 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02003389 f_TfiUsfArrSet(tua, 7, 0);
3390 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3391 f_sleep(1.0);
3392
3393 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01003394}
3395
3396/* Send DATA.req on invalid TRX */
3397testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02003398 var TfiUsfArr tua := f_TfiUsfArrInit();
3399 var octetstring data := '0000'O & f_rnd_octstring(21);
3400
3401 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01003402
Harald Welte883340c2018-02-28 18:59:29 +01003403 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02003404 f_TfiUsfArrSet(tua, 7, 0);
3405 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3406 f_sleep(1.0);
3407
3408 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01003409}
3410
3411/* Send DATA.req on invalid timeslot */
3412testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02003413 var TfiUsfArr tua := f_TfiUsfArrInit();
3414 var octetstring data := '0000'O & f_rnd_octstring(21);
3415
3416 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01003417
Harald Welte883340c2018-02-28 18:59:29 +01003418 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02003419 f_TfiUsfArrSet(tua, 7, 0);
3420 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3421 f_sleep(1.0);
3422
3423 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01003424}
3425
3426/* Send DATA.req on timeslot that hasn't been activated */
3427testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02003428 var TfiUsfArr tua := f_TfiUsfArrInit();
3429 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01003430
Harald Welte7162a612019-05-26 12:56:09 +02003431 f_virtphy_common();
3432
3433 f_TfiUsfArrSet(tua, 7, 0);
3434 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3435 f_sleep(1.0);
3436
3437 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01003438}
3439
Harald Weltead033dc2019-05-25 17:28:16 +02003440private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02003441 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
3442 boolean wait_rts := true)
3443runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02003444 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02003445 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02003446
3447 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02003448 if (wait_rts) {
3449 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
3450 } else {
3451 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
3452 }
Harald Weltead033dc2019-05-25 17:28:16 +02003453
3454 T.start;
3455 alt {
Harald Welte7162a612019-05-26 12:56:09 +02003456 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02003457 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
3458 setverdict(pass);
3459 }
Harald Welte7162a612019-05-26 12:56:09 +02003460 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
3461 setverdict(fail, "Received unexpected ", rx_dl);
3462 }
Harald Weltead033dc2019-05-25 17:28:16 +02003463 [] L1CTL.receive {
3464 repeat;
3465 }
Harald Welte7162a612019-05-26 12:56:09 +02003466 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02003467 setverdict(fail, "Timeout waiting for ", data);
3468 }
Harald Welte7162a612019-05-26 12:56:09 +02003469 [not expect_data] T.timeout {
3470 setverdict(pass);
3471 }
Harald Weltead033dc2019-05-25 17:28:16 +02003472 }
3473}
3474
3475private function f_disable_dynamic_ts() runs on test_CT
3476{
3477 f_init_vty_bsc();
3478 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
3479 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
3480 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
3481 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Max2c6f5632019-03-18 17:25:17 +01003482 f_init_pcu_test();
Harald Weltead033dc2019-05-25 17:28:16 +02003483}
3484
3485private function f_virtphy_common() runs on test_CT {
3486 f_disable_dynamic_ts();
3487 f_init_l1ctl();
3488 f_l1_tune(L1CTL);
3489}
3490
3491testcase TC_pcu_data_req_pdtch() runs on test_CT {
3492 var TfiUsfArr tua := f_TfiUsfArrInit();
3493 var octetstring data := '0000'O & f_rnd_octstring(21);
3494
3495 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01003496
Harald Welte883340c2018-02-28 18:59:29 +01003497 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02003498 f_TfiUsfArrSet(tua, 7, 0);
3499 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3500 f_sleep(1.0);
3501
3502 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01003503}
3504
3505testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02003506 var TfiUsfArr tua := f_TfiUsfArrInit();
3507 var octetstring data := '0000'O & f_rnd_octstring(21);
3508
3509 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01003510
Harald Welte883340c2018-02-28 18:59:29 +01003511 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02003512 f_TfiUsfArrSet(tua, 7, 0);
3513 f_L1CTL_TBF_CFG(L1CTL, false, tua);
3514 f_sleep(1.0);
3515
3516 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01003517}
3518
3519/* Send AGCH from PCU; check it appears on Um side */
3520testcase TC_pcu_data_req_agch() runs on test_CT {
3521 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01003522 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003523 f_init_l1ctl();
3524 f_l1_tune(L1CTL);
3525
3526 f_TC_pcu_act_req(0, 0, 7, true);
3527 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
3528
3529 T.start;
3530 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003531 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01003532 setverdict(pass);
3533 }
3534 [] L1CTL.receive { repeat; }
3535 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003536 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003537 }
3538 }
3539}
3540
Harald Welte928622b2019-05-26 13:22:59 +02003541/* Send AGCH from PCU; check it appears on Um side */
3542testcase TC_pcu_data_req_pch() runs on test_CT {
3543 timer T := 3.0;
3544 f_init_pcu_test();
3545 f_init_l1ctl();
3546 f_l1_tune(L1CTL);
3547
3548 f_TC_pcu_act_req(0, 0, 7, true);
3549 /* three characters prefix: last 3 digits of IMSI as ASCII */
3550 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
3551
3552 T.start;
3553 alt {
3554 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
3555 setverdict(pass);
3556 }
3557 [] L1CTL.receive { repeat; }
3558 [] T.timeout {
3559 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
3560 }
3561 }
3562}
3563
Harald Welte883340c2018-02-28 18:59:29 +01003564/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
3565testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
3566 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01003567 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003568 f_init_l1ctl();
3569 f_l1_tune(L1CTL);
3570
3571 /* append 3 last imsi digits so BTS can compute pagng group */
3572 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
3573
3574 timer T := 0.5;
3575 T.start;
3576 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003577 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01003578 /* TODO: verify paging group */
3579 setverdict(pass);
3580 }
3581 [] L1CTL.receive { repeat; }
3582 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003583 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003584 }
3585 }
3586}
3587
3588/* Send RACH from Um side, expect it to show up on PCU socket */
3589testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003590 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003591 f_init_l1ctl();
3592 f_l1_tune(L1CTL);
3593
3594 var GsmFrameNumber fn_last := 0;
3595 for (var integer i := 0; i < 1000; i := i+1) {
3596 var OCT1 ra := f_rnd_ra_ps();
3597 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
3598 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003599 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01003600 }
3601 fn_last := fn;
3602
3603 timer T := 2.0;
3604 T.start;
3605 alt {
3606 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
3607 T.stop;
3608 }
3609 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003610 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003611 }
3612 [] PCU.receive { repeat; }
3613 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003614 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003615 }
3616 }
3617 }
3618 setverdict(pass);
3619}
3620
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07003621/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
3622 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
3623testcase TC_pcu_ext_rach_content() runs on test_CT {
3624 var template PCUIF_Message pcu_rach_ind;
3625 var GsmFrameNumber fn_last := 0;
3626 var L1ctlRachSynchSeq synch_seq;
3627 var PCUIF_BurstType pcu_bt;
3628 var GsmFrameNumber fn;
3629 var BIT11 ra11;
3630
3631 f_init_pcu_test();
3632 f_init_l1ctl();
3633 f_l1_tune(L1CTL);
3634
3635 for (var integer i := 0; i < 1000; i := i+1) {
3636 /* We need to test both TS1 & TS2 */
3637 if (i rem 2 == 0) {
3638 synch_seq := RACH_SYNCH_SEQ_TS1;
3639 pcu_bt := BURST_TYPE_1;
3640 } else {
3641 synch_seq := RACH_SYNCH_SEQ_TS2;
3642 pcu_bt := BURST_TYPE_2;
3643 }
3644
3645 ra11 := f_rnd_ra11_ps();
3646 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
3647 if (fn == fn_last) {
3648 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3649 "Two RACH in same FN?!?");
3650 }
3651 fn_last := fn;
3652
3653 /* Compose the expected message */
3654 pcu_rach_ind := tr_PCUIF_RACH_IND(
3655 bts_nr := 0,
3656 ra := bit2int(ra11),
3657 is_11bit := 1,
3658 burst_type := pcu_bt,
3659 fn := fn);
3660
3661 timer T := 2.0;
3662 T.start;
3663 alt {
3664 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
3665 T.stop;
3666 }
3667 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
3668 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
3669 }
3670 [] PCU.receive { repeat; }
3671 [] T.timeout {
3672 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
3673 }
3674 }
3675 }
3676 setverdict(pass);
3677}
3678
Harald Welte883340c2018-02-28 18:59:29 +01003679private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
3680 var integer strlen := lengthof(str);
3681 for (var integer i := 0; i < len-strlen; i := i+1) {
3682 str := str & pad;
3683 }
3684 return str;
3685}
3686
3687/* Send PAGING via RSL, expect it to shw up on PCU socket */
3688testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003689 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003690
3691 for (var integer i := 0; i < 100; i := i+1) {
3692 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
3693 timer T := 3.0;
3694 if (i < 50) {
3695 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
3696 } else {
3697 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
3698 }
3699 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
3700 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
3701 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
3702
3703 /* Send RSL PAGING COMMAND */
3704 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
3705 T.start;
3706 alt {
3707 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
3708 }
3709 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003710 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003711 }
3712 [] PCU.receive { repeat; }
3713 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003714 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003715 }
3716 }
3717 }
3718 setverdict(pass);
3719}
3720
Harald Welted66c9b82019-05-25 09:03:15 +02003721/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
3722testcase TC_pcu_time_ind() runs on test_CT {
3723 var PCUIF_send_data pcu_sd;
3724 var integer num_time_ind := 0;
3725 var integer first_fn, last_fn;
3726 var float test_duration := 5.0;
3727 timer T;
3728
3729 f_init_pcu_test();
3730 f_TC_pcu_act_req(0, 0, 7, true);
3731
3732 PCU.clear;
3733 T.start(test_duration);
3734 alt {
3735 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
3736 num_time_ind := num_time_ind + 1;
3737 if (not isbound(first_fn)) {
3738 first_fn := pcu_sd.data.u.time_ind.fn;
3739 }
3740 last_fn := pcu_sd.data.u.time_ind.fn;
3741 repeat;
3742 }
3743 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
3744 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
3745 repeat;
3746 }
3747 [] PCU.receive {
3748 repeat;
3749 }
3750 [] T.timeout {}
3751 }
3752 var integer fn_expired := last_fn - first_fn;
3753 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
3754
3755 /* verify the number of frames expired matches our expectation */
3756 const float c_GSM_FN_DURATION_MS := 4.61538;
3757 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02003758 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02003759 if (not match(fn_expired, t_fn_expected)) {
3760 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
3761 }
3762
3763 /* There are three TIME.ind in every fn MOD 13 */
3764 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
3765 /* Add some tolerance */
3766 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
3767 if (not match(num_time_ind, t_time_ind_exp)) {
3768 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
3769 }
3770
3771 setverdict(pass);
3772}
3773
Harald Welte4832c862019-05-25 14:57:18 +02003774/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
3775testcase TC_pcu_rts_req() runs on test_CT {
3776 var PCUIF_send_data pcu_sd;
3777 var integer first_fn, last_fn;
3778 var integer num_rts_pdtch := 0;
3779 var integer num_rts_ptcch := 0;
3780 var float test_duration := 5.0;
3781 timer T;
3782
3783 f_init_pcu_test();
3784 f_TC_pcu_act_req(0, 0, 7, true);
3785
3786 PCU.clear;
3787 T.start(test_duration);
3788 alt {
3789 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
3790 -> value pcu_sd {
3791 num_rts_pdtch := num_rts_pdtch + 1;
3792 if (not isbound(first_fn)) {
3793 first_fn := pcu_sd.data.u.rts_req.fn;
3794 }
3795 last_fn := pcu_sd.data.u.rts_req.fn;
3796 repeat;
3797 }
3798 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
3799 -> value pcu_sd {
3800 num_rts_ptcch := num_rts_ptcch + 1;
3801 if (not isbound(first_fn)) {
3802 first_fn := pcu_sd.data.u.rts_req.fn;
3803 }
3804 last_fn := pcu_sd.data.u.rts_req.fn;
3805 repeat;
3806 }
3807 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
3808 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
3809 repeat;
3810 }
3811 [] PCU.receive {
3812 repeat;
3813 }
3814 [] T.timeout {}
3815 }
3816 var integer fn_expired := last_fn - first_fn;
3817 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
3818 ", num_rts_ptcch=", num_rts_ptcch);
3819
3820 /* verify the number of frames expired matches our expectation */
3821 const float c_GSM_FN_DURATION_MS := 4.61538;
3822 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02003823 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02003824 if (not match(fn_expired, t_fn_expected)) {
3825 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
3826 }
3827
3828 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
3829 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
3830 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
3831 if (not match(num_rts_ptcch, t_ptcch_exp)) {
3832 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
3833 t_ptcch_exp);
3834 }
3835
3836 /* We have 12 PDTCH blocks every 52-multiframe */
3837 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
3838 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
3839 if (not match(num_rts_pdtch, t_pdtch_exp)) {
3840 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
3841 t_pdtch_exp);
3842 }
3843
3844 setverdict(pass);
3845}
3846
Harald Welte07bd2d22019-05-25 11:03:30 +02003847/* test for generating Abis side OML ALERT from the PCU */
3848testcase TC_pcu_oml_alert() runs on test_CT {
3849 var PCUIF_send_data pcu_sd;
3850 var integer num_time_ind := 0;
3851 var integer first_fn, last_fn;
3852 var float test_duration := 5.0;
3853 timer T;
3854
3855 f_init_pcu_test();
3856 f_TC_pcu_act_req(0, 0, 7, true);
3857
3858 /* re-connect CTRL port from BTS to BSC */
3859 f_ipa_ctrl_stop();
3860 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
3861
3862 /* Send that OML Alert */
3863 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
3864
3865 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
3866 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
3867 setverdict(pass);
3868}
3869
Harald Welteeaa9a862019-05-26 23:01:08 +02003870template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
3871 template (value) RoutingAreaIdentificationV rai,
3872 template (value) OCT1 cause) := {
3873 discriminator := '0000'B, /* overwritten */
3874 tiOrSkip := {
3875 skipIndicator := '0000'B
3876 },
3877 msgs := {
3878 rrm := {
3879 gPRS_suspensionRequest := {
3880 messageType := '00110100'B,
3881 tLLI := tlli,
3882 routingAreaIdentification := rai,
3883 suspensionCause := cause,
3884 service_Support := omit
3885 }
3886 }
3887 }
3888}
3889
3890/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
3891private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
3892 var PCUIF_Message first_info;
3893 var integer pcu_conn_id := -1;
3894 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3895 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
3896 var OCT4 tlli := '01020304'O;
3897 var OCT1 cause := '23'O;
3898 timer T := 5.0;
3899
3900 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3901
3902 f_l1_tune(L1CTL);
3903 RSL.clear;
3904
3905 f_est_dchan();
3906 L1CTL.clear;
3907
3908 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3909
3910 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
3911 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
3912 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
3913
3914 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
3915 T.start;
3916 alt {
3917 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
3918 setverdict(pass);
3919 }
3920 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
3921 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
3922 }
3923 [] PCU.receive {
3924 repeat;
3925 }
3926 [] T.timeout {
3927 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
3928 }
3929 }
3930}
3931testcase TC_pcu_rr_suspend() runs on test_CT {
3932 var ConnHdlrPars pars;
3933 var ConnHdlr vc_conn;
3934
3935 f_init();
3936
3937 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
3938 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
3939 vc_conn.done;
3940}
Harald Welte07bd2d22019-05-25 11:03:30 +02003941
Harald Weltea2e0e942019-05-27 18:12:53 +02003942/* Ensure that PCUIF socket can accept only a single connection */
3943testcase TC_pcu_socket_connect_multi() runs on test_CT {
3944 timer T := 5.0;
3945
3946 /* this (among other things) establishes the first connection to the PCUIF socket */
3947 f_init();
3948
3949 /* try to establish a second connection, expect it to fail */
3950 PCU.send(UD_connect:{mp_pcu_socket, -1});
3951 T.start;
3952 alt {
3953 [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) {
3954 setverdict(pass);
3955 }
3956 [] PCU.receive(UD_connect_result:?) {
3957 setverdict(fail, "Unexpected unix domain connect result");
3958 }
3959 [] T.timeout {
3960 setverdict(pass);
3961 }
3962 }
3963 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3964}
3965
Harald Weltec8effb72019-05-27 18:23:04 +02003966/* Ensure that PCUIF socket can disconnect + reconnect */
3967testcase TC_pcu_socket_reconnect() runs on test_CT {
3968 /* this (among other things) establishes the first connection to the PCUIF socket */
3969 f_init();
3970
3971 f_sleep(1.0);
3972
3973 f_pcuif_close(PCU, g_pcu_conn_id);
3974 g_pcu_conn_id := -1;
3975
3976 f_sleep(1.0);
3977
3978 /* re-connect */
3979 PCU.clear;
3980 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
3981 setverdict(pass);
3982
3983 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3984}
3985
Harald Welted66c9b82019-05-25 09:03:15 +02003986
Harald Welte3d04ae62018-04-04 20:29:05 +02003987/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02003988 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02003989 ***********************************************************************/
3990
3991private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3992runs on ConnHdlr {
3993 var PCUIF_send_data sd;
3994 /* Expect BTS to immediately acknowledge activation as PDCH */
3995 PCU.clear;
3996 f_rsl_chan_act(g_pars.chan_mode);
3997 /* expect INFO_IND on PCU interface listing TS as PDCH */
3998 alt {
3999 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
4000 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004001 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02004002 }
4003 }
4004 [] PCU.receive { repeat; }
4005 }
4006 /* try to activate this PDCH from the PCU point of view */
4007 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
4008 /* FIXME: is there a response? */
4009}
4010
4011private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
4012runs on ConnHdlr {
4013 var PCUIF_send_data sd;
4014 /* Send RSL CHAN REL (deactivate) */
4015 PCU.clear;
4016 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
4017 /* expect BTS to ask PCU to deactivate the channel */
4018 alt {
4019 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
4020 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004021 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02004022 }
4023 }
4024 [] PCU.receive { repeat; }
4025 }
4026 /* Emulate PCU asking BTS to deactivate PDCH */
4027 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
4028 alt {
4029 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
4030 setverdict(pass);
4031 }
4032 [] RSL.receive { repeat; }
4033 }
4034}
4035
4036/* Activate Osmocom-style dynamic PDCH from BSC side */
4037function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
4038 var PCUIF_Message first_info;
4039 var integer ts_nr := g_chan_nr.tn;
4040 var integer trx_nr := 0;
4041 var integer bts_nr := 0;
4042 var integer pcu_conn_id := -1;
4043
4044 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4045
4046 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
4047 f_sleep(3.0);
4048 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
4049 setverdict(pass);
4050}
4051testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
4052 var ConnHdlrPars pars;
4053 var ConnHdlr vc_conn;
4054 f_init(testcasename());
4055
4056 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
4057 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
4058 vc_conn.done;
4059}
4060
4061/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
4062function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
4063 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02004064 var integer pcu_conn_id := -1;
4065
4066 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4067
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02004068 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
4069 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
4070 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02004071 setverdict(pass);
4072}
4073testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
4074 var ConnHdlrPars pars;
4075 var ConnHdlr vc_conn;
4076 f_init(testcasename());
4077
4078 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
4079 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
4080 vc_conn.done;
4081}
4082
4083/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
4084function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
4085 var PCUIF_Message first_info;
4086 var integer ts_nr := g_chan_nr.tn;
4087 var integer trx_nr := 0;
4088 var integer bts_nr := 0;
4089 var integer pcu_conn_id := -1;
4090
4091 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4092
4093 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02004094 /* Send a second Chan Activ and expect it to be NACKed */
4095 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
4096 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02004097 setverdict(pass);
4098}
4099testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
4100 var ConnHdlrPars pars;
4101 var ConnHdlr vc_conn;
4102 f_init(testcasename());
4103
4104 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
4105 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
4106 vc_conn.done;
4107}
4108
4109/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
4110function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
4111 var PCUIF_Message first_info;
4112 var integer ts_nr := g_chan_nr.tn;
4113 var integer trx_nr := 0;
4114 var integer bts_nr := 0;
4115 var integer pcu_conn_id := -1;
4116 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
4117
4118 /* register for the TCH/F channel number */
4119 f_rslem_register(0, chan_nr);
4120
4121 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4122
4123 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
4124 "RSL CHAN ACT");
4125 setverdict(pass);
4126}
4127testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
4128 var ConnHdlrPars pars;
4129 var ConnHdlr vc_conn;
4130 f_init(testcasename());
4131
4132 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
4133 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
4134 vc_conn.done;
4135}
4136
4137/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
4138function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
4139 var PCUIF_Message first_info;
4140 var integer ts_nr := g_chan_nr.tn;
4141 var integer trx_nr := 0;
4142 var integer bts_nr := 0;
4143 var integer pcu_conn_id := -1;
4144 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
4145 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
4146
4147 /* register for the TCH/H channel numbers */
4148 f_rslem_register(0, chan_nr[0]);
4149 f_rslem_register(0, chan_nr[1]);
4150
4151 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4152
4153 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
4154 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
4155 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
4156 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
4157 setverdict(pass);
4158}
4159testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
4160 var ConnHdlrPars pars;
4161 var ConnHdlr vc_conn;
4162 f_init(testcasename());
4163
4164 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
4165 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
4166 vc_conn.done;
4167}
4168
Harald Welte9bbbfb52018-04-05 09:33:19 +02004169/***********************************************************************
4170 * IPA Style Dynamic Timeslot Support
4171 ***********************************************************************/
4172
4173private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
4174runs on ConnHdlr {
4175 var PCUIF_send_data sd;
4176 /* Expect BTS to immediately acknowledge activation as PDCH */
4177 PCU.clear;
4178 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
4179 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004180 timer T_wait := 2.0;
4181 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02004182 alt {
4183 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
4184 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004185 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
4186 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
4187 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02004188 }
4189 }
4190 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004191 [] T_wait.timeout {
4192 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4193 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
4194 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02004195 }
4196 /* try to activate this PDCH from the PCU point of view */
4197 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
4198 /* FIXME: is there a response? */
4199
4200 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
4201}
4202
4203private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
4204runs on ConnHdlr {
4205 var PCUIF_send_data sd;
4206 /* Send RSL CHAN REL (deactivate) */
4207 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
4208 PCU.clear;
4209 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004210 timer T_wait := 2.0;
4211 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02004212 alt {
4213 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
4214 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004215 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
4216 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
4217 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02004218 }
4219 }
4220 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01004221 [] T_wait.timeout {
4222 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4223 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
4224 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02004225 }
4226 /* Emulate PCU asking BTS to deactivate PDCH */
4227 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
4228 alt {
4229 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
4230 setverdict(pass);
4231 }
4232 [] RSL.receive { repeat; }
4233 }
4234}
4235
4236/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
4237function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
4238 var PCUIF_Message first_info;
4239 var integer ts_nr := g_chan_nr.tn;
4240 var integer trx_nr := 0;
4241 var integer bts_nr := 0;
4242 var integer pcu_conn_id := -1;
4243
4244 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4245
4246 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
4247 f_sleep(3.0);
4248 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
4249
4250 setverdict(pass);
4251
4252}
4253testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
4254 var ConnHdlrPars pars;
4255 var ConnHdlr vc_conn;
4256 f_init();
4257
4258 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4259 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
4260 vc_conn.done;
4261}
4262
4263/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
4264function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
4265 var PCUIF_Message first_info;
4266 var integer ts_nr := g_chan_nr.tn;
4267 var integer trx_nr := 0;
4268 var integer bts_nr := 0;
4269 var integer pcu_conn_id := -1;
4270
4271 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4272
4273 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
4274 "RSL CHAN ACT");
4275 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
4276 "RF CHAN REL", true);
4277 setverdict(pass);
4278}
4279testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
4280 var ConnHdlrPars pars;
4281 var ConnHdlr vc_conn;
4282 f_init(testcasename());
4283
4284 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4285 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
4286 vc_conn.done;
4287}
4288
4289/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
4290function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
4291 var PCUIF_Message first_info;
4292 var integer ts_nr := g_chan_nr.tn;
4293 var integer trx_nr := 0;
4294 var integer bts_nr := 0;
4295 var integer pcu_conn_id := -1;
4296
4297 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4298
4299 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
4300 "RSL CHAN ACT");
4301
4302 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
4303 alt {
4304 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
4305 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004306 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02004307 }
4308 [] RSL.receive { repeat; }
4309 }
4310
4311 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
4312 "RF CHAN REL", true);
4313 setverdict(pass);
4314}
4315testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
4316 var ConnHdlrPars pars;
4317 var ConnHdlr vc_conn;
4318 f_init(testcasename());
4319
4320 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4321 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
4322 vc_conn.done;
4323}
4324
4325/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
4326function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
4327 var PCUIF_Message first_info;
4328 var integer ts_nr := g_chan_nr.tn;
4329 var integer trx_nr := 0;
4330 var integer bts_nr := 0;
4331 var integer pcu_conn_id := -1;
4332
4333 /* register for the TCH/F channel number */
4334 f_rslem_register(0, g_chan_nr);
4335
4336 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4337
4338 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
4339
4340 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
4341 "RSL CHAN ACT");
4342
4343 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
4344
4345 setverdict(pass);
4346}
4347testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
4348 var ConnHdlrPars pars;
4349 var ConnHdlr vc_conn;
4350 f_init(testcasename());
4351
4352 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4353 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
4354 vc_conn.done;
4355}
4356
4357
Harald Welte0472ab42018-03-12 15:02:26 +01004358/***********************************************************************
4359 * LAPDm / RLL related
4360 ***********************************************************************/
4361
4362private function f_tx_lapdm(template (value) LapdmFrame l,
4363 template (value) RslLinkId link_id) runs on ConnHdlr {
4364 var octetstring l2 := enc_LapdmFrame(valueof(l));
4365 if (valueof(link_id.c) == SACCH) {
4366 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02004367 var L1ctlDataReq l1hl2 := {
4368 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
4369 l2_payload := f_pad_oct(l2, 21, '2B'O)
4370 }
4371 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
4372 } else {
4373 /* If required, pad L2 frame with constant 0x2b filling */
4374 l2 := f_pad_oct(l2, 23, '2B'O);
4375
4376 log("encoding ", l, " to ", l2);
4377 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01004378 }
Harald Welte0472ab42018-03-12 15:02:26 +01004379}
4380
4381type record RllTestCase {
4382 uint3_t sapi,
4383 RslLinkId link_id,
4384 octetstring l3,
4385 boolean exp
4386}
4387type record of RllTestCase RllTestCases;
4388template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
4389 sapi := sapi,
4390 link_id := id,
4391 l3 := l3,
4392 exp := exp
4393}
4394
4395/* execute the same callback function with a set of different parameters (tcs) on a
4396 * variety of logical channels */
4397private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
4398 var ConnHdlrPars pars;
4399 var ConnHdlr vc_conn;
4400 f_init(testcasename());
4401
4402 /* test on each of the channels we have */
4403 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
4404 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
4405
4406 /* test each of the test cases on the current channel */
4407 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
4408 pars.spec.rll := tcs[j];
4409 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
4410 vc_conn := f_start_handler(fn, pars);
4411 vc_conn.done;
4412 }
4413 }
4414
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004415 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01004416}
4417
4418/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
4419private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
4420 var RllTestCase tc := g_pars.spec.rll;
4421 timer T := 3.0;
4422
4423 f_l1_tune(L1CTL);
4424 RSL.clear;
4425
4426 /* activate the logical channel */
4427 f_est_dchan();
4428 L1CTL.clear;
4429
4430 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
4431 T.start;
4432 alt {
4433 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
4434 if (tc.exp) {
4435 setverdict(pass);
4436 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004437 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004438 }
4439 }
4440 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
4441 if (tc.exp) {
4442 setverdict(pass);
4443 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004444 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004445 }
4446 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004447 /* We also expect to receive the measurements */
4448 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004449 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004450 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004451 }
4452 [not tc.exp] T.timeout {
4453 setverdict(pass);
4454 }
4455 }
4456
4457 f_rsl_chan_deact();
4458 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4459 f_rslem_unregister(0, g_chan_nr);
4460}
4461testcase TC_rll_est_ind() runs on test_CT {
4462 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02004463 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01004464 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02004465 /* normal SAPI0 establishment */
4466 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01004467 /* SAPI 3 doesn't support contention resolution */
4468 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
4469 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
4470 /* normal SAPI3 establishment on main DCCH */
4471 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4472 /* normal SAPI3 establishment on SACCH */
4473 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4474 };
4475 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
4476}
4477
4478/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
4479private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
4480 var RllTestCase tc := g_pars.spec.rll;
4481 var L1ctlDlMessage dl;
4482 timer T := 3.0;
4483
4484 f_l1_tune(L1CTL);
4485 RSL.clear;
4486
4487 /* activate the logical channel */
4488 f_est_dchan();
4489 L1CTL.clear;
4490
4491 /* Send a RSL EST REQ for SAPI3 on main DCCH */
4492 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
4493 T.start;
4494 alt {
4495 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4496 var LapdmFrame lapdm;
4497 var octetstring l2 := dl.payload.data_ind.payload;
4498 if (dl.dl_info.link_id.c == SACCH) {
4499 /* remove L1 header */
4500 l2 := substr(l2, 2, lengthof(l2)-2);
4501 }
4502 lapdm.ab := dec_LapdmFrameAB(l2);
4503 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
4504 setverdict(pass);
4505 } else {
4506 repeat;
4507 }
4508 }
4509 [] L1CTL.receive { repeat; }
4510 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004511 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01004512 }
4513 }
4514
4515 f_rsl_chan_deact();
4516 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4517 f_rslem_unregister(0, g_chan_nr);
4518}
4519testcase TC_rll_est_req_DCCH_3() runs on test_CT {
4520 var RllTestCases tcs := {
4521 /* normal SAPI3 establishment on main DCCH */
4522 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
4523 };
4524 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4525}
4526testcase TC_rll_est_req_ACCH_3() runs on test_CT {
4527 var RllTestCases tcs := {
4528 /* normal SAPI3 establishment on SACCH */
4529 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4530 }
4531 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4532}
4533
4534/* altstep to receive a LAPDm frame matching the given template */
4535private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
4536 var L1ctlDlMessage dl;
4537 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4538 var LapdmFrame lapdm;
4539 var octetstring l2 := dl.payload.data_ind.payload;
4540 if (dl.dl_info.link_id.c == SACCH) {
4541 /* remove L1 header */
4542 l2 := substr(l2, 2, lengthof(l2)-2);
4543 }
4544 if (ischosen(exp.ab)) {
4545 lapdm.ab := dec_LapdmFrameAB(l2);
4546 } else if (ischosen(exp.b4)) {
4547 lapdm.b4 := dec_LapdmFrameB4(l2);
4548 } else if (ischosen(exp.bbis)) {
4549 lapdm.bbis := dec_LapdmFrameBbis(l2);
4550 }
4551 log("Rx LAPDm ", lapdm);
4552 if (match(lapdm, exp)) {
4553 setverdict(pass);
4554 } else {
4555 repeat;
4556 }
4557 }
4558 [] L1CTL.receive { repeat; }
4559}
4560private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
4561 timer T := t;
4562 T.start;
4563 alt {
4564 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004565 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01004566 }
4567 [] as_l1_exp_lapdm(exp);
4568 }
4569}
4570
4571/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
4572private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4573 /* send SABM from MS -> BTS */
4574 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
4575 /* expect RLL EST IND on Abis */
4576 alt {
4577 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
4578 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
4579 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004580 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004581 }
4582 [] RSL.receive { repeat; }
4583 }
4584 /* expect UA from BTS -> MS */
4585 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
4586}
4587
4588/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
4589private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
4590 var RllTestCase tc := g_pars.spec.rll;
4591
4592 f_l1_tune(L1CTL);
4593 RSL.clear;
4594
4595 /* activate the logical channel */
4596 f_est_dchan();
4597 L1CTL.clear;
4598
4599 /* first establish the link-layer */
4600 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4601
4602 /* then send the DISC */
4603 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
4604 /* ... and expect the REL IND on the RSL side */
4605 alt {
4606 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
4607 setverdict(pass);
4608 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004609 /* We also expect to receive the measurements */
4610 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004611 }
4612
4613 /* release the channel */
4614 f_rsl_chan_deact();
4615 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4616 f_rslem_unregister(0, g_chan_nr);
4617}
4618testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
4619 var RllTestCases tcs := {
4620 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
4621 };
4622 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4623}
4624
4625testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
4626 var RllTestCases tcs := {
4627 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
4628 };
4629 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4630}
4631testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
4632 var RllTestCases tcs := {
4633 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
4634 };
4635 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4636}
4637testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
4638 var RllTestCases tcs := {
4639 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4640 };
4641 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4642}
4643
4644/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
4645private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
4646 var RllTestCase tc := g_pars.spec.rll;
4647 f_l1_tune(L1CTL);
4648 RSL.clear;
4649
4650 /* activate the logical channel */
4651 f_est_dchan();
4652 L1CTL.clear;
4653
4654 /* first establish the link-layer */
4655 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4656
4657 /* then send the REL REQ via RSL */
4658 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
4659 /* ... and expect the DISC on the Um side */
4660 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02004661 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01004662 /* FIXME: send a UA in resposne to the DISC */
4663 }
4664 }
4665
4666 /* release the channel */
4667 f_rsl_chan_deact();
4668 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4669 f_rslem_unregister(0, g_chan_nr);
4670}
4671testcase TC_rll_rel_req() runs on test_CT {
4672 var RllTestCases tcs := {
4673 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
4674 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
4675 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4676 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4677 };
4678 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
4679}
4680
4681/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
4682testcase TC_rll_data_req() runs on test_CT {
4683}
4684
4685/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
4686testcase TC_rll_data_ind() runs on test_CT {
4687}
4688
4689/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
4690private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
4691 var RllTestCase tc := g_pars.spec.rll;
4692
4693 f_l1_tune(L1CTL);
4694 RSL.clear;
4695
4696 f_est_dchan();
4697 L1CTL.clear;
4698
4699 /* Send UNITDATA REQ on RSL side */
4700 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
4701 /* Expect it to arrive on the other side */
4702 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02004703 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004704 } else {
Harald Weltee613f962018-04-18 22:38:16 +02004705 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004706 }
4707
4708 /* release the channel */
4709 f_rsl_chan_deact();
4710 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4711 f_rslem_unregister(0, g_chan_nr);
4712}
4713testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
4714 var octetstring l3 := f_rnd_octstring(15);
4715 var RllTestCases tcs := {
4716 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4717 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4718 };
4719 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4720}
4721testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
4722 var octetstring l3 := f_rnd_octstring(19);
4723 var RllTestCases tcs := {
4724 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4725 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4726 };
4727 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4728}
4729
4730/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
4731private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
4732 var RllTestCase tc := g_pars.spec.rll;
4733
4734 f_l1_tune(L1CTL);
4735 RSL.clear;
4736
4737 f_est_dchan();
4738 L1CTL.clear;
4739
4740 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02004741 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01004742 /* Expdct RLL UNITDATA IND on RSL side */
4743 alt {
4744 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
4745 setverdict(pass);
4746 }
4747 [] RSL.receive { repeat; }
4748 }
4749
4750 /* release the channel */
4751 f_rsl_chan_deact();
4752 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4753 f_rslem_unregister(0, g_chan_nr);
4754}
4755testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02004756 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01004757 var RllTestCases tcs := {
4758 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4759 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4760 };
4761 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4762}
4763testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
4764 var octetstring l3 := f_rnd_octstring(18);
4765 var RllTestCases tcs := {
4766 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4767 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4768 };
4769 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4770}
4771
Harald Weltee613f962018-04-18 22:38:16 +02004772/***********************************************************************
4773 * Encryption Related
4774 ***********************************************************************/
4775
4776/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4777function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4778 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
4779 if (link_id.c == SACCH) {
4780 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
4781 } else {
4782 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
4783 }
4784}
4785
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004786/* Expect (or not expect) other kinds of messages */
4787private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
4788 [exp_any] RSL.receive { repeat; }
4789 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004790 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004791 }
4792}
4793
Harald Weltee613f962018-04-18 22:38:16 +02004794/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07004795private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004796 RslLinkId link_id,
4797 octetstring l3,
4798 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004799 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004800) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02004801 timer T := 3.0;
4802 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
4803 T.start;
4804 /* Expect RLL UNITDATA IND on RSL side */
4805 alt {
4806 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
4807 setverdict(pass);
4808 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004809 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004810 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02004811 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004812 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02004813 }
Harald Weltee613f962018-04-18 22:38:16 +02004814 }
4815}
4816
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004817/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
4818private function f_data_mo(
4819 RslLinkId link_id,
4820 boolean p, uint3_t nr, uint3_t ns,
4821 octetstring l3,
4822 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004823 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004824) runs on ConnHdlr {
4825 timer T := 3.0;
4826 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
4827 T.start;
4828 /* Expect RLL DATA IND on RSL side */
4829 alt {
4830 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
4831 setverdict(pass);
4832 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004833 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004834 [] as_rsl_any_ind(exp_any);
4835 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004836 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004837 }
4838 }
4839}
4840
Harald Weltee613f962018-04-18 22:38:16 +02004841/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
4842function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
4843 f_l1_tune(L1CTL);
4844 f_est_dchan(true);
4845
4846 /* now we actually need to transmit some data both ways to check if the encryption works */
4847 var L1ctlDlMessage dl;
4848
Stefan Sperling603d98e2018-07-25 16:47:28 +02004849 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02004850 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4851
4852 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4853 f_unitdata_mt(link_id, l3);
4854
4855 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
4856 f_unitdata_mo(link_id, l3);
4857
4858 /* release the channel */
4859 f_rsl_chan_deact();
4860 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4861 f_rslem_unregister(0, g_chan_nr);
4862}
4863testcase TC_chan_act_a51() runs on test_CT {
4864 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4865 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4866 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4867}
4868testcase TC_chan_act_a52() runs on test_CT {
4869 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4870 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4871 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4872}
4873testcase TC_chan_act_a53() runs on test_CT {
4874 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4875 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4876 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4877}
4878
Eric Wildf1827a72019-05-28 17:37:35 +02004879/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
4880 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
4881function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
4882 f_l1_tune(L1CTL);
4883 f_est_dchan(true);
4884
4885 /* now we actually need to transmit some data both ways to check if the encryption works */
4886 var L1ctlDlMessage dl;
4887
4888 var octetstring l3 := f_rnd_octstring(20);
4889 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4890
4891 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4892 f_unitdata_mt(link_id, l3);
4893
4894 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
4895 f_unitdata_mo(link_id, l3);
4896
4897 var RSL_Message rsl;
4898 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false))));
4899
4900 /* modify key to break proper encryption */
4901 g_pars.encr.key := f_rnd_octstring(8);
4902 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
4903 rsl.ies := rsl.ies & { ei };
4904 RSL.send(rsl);
4905
4906 timer T0 := 1.0;
4907 T0.start;
4908 /* Expect RSL MODIFY ACK */
4909 alt {
4910 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
4911 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
4912 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
4913 }
4914 [] T0.timeout {
4915 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
4916 }
4917 }
4918
4919 var octetstring l3msg := f_rnd_octstring(15);
4920 timer T1 := 3.0;
4921 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
4922 due to broken encryption */
4923 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
4924 T1.start;
4925 alt {
4926 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
4927 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
4928 }
4929 [] T1.timeout {
4930 setverdict(pass);
4931 }
4932 }
4933
4934 /* release the channel */
4935 f_rsl_chan_deact();
4936 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4937 f_rslem_unregister(0, g_chan_nr);
4938}
4939testcase TC_rsl_modify_encr() runs on test_CT {
4940 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4941 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4942 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
4943}
Harald Weltee613f962018-04-18 22:38:16 +02004944
4945/* Test unencrypted channel activation followed by explicit ENCR CMD later */
4946function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
4947 /* L3 payload doesn't matter, as it is passed transparently */
4948 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
4949 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
4950 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4951
4952 f_l1_tune(L1CTL);
4953
4954 /* first establish a dedicated channel in the clear */
4955 f_est_dchan(false);
4956
4957 /* Establish ABM */
4958 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4959
4960 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
4961 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
4962 /* expect the L3 to arrive still unencrypted on the MS side */
4963 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
4964
4965 /* configure L1 to apply ciphering */
4966 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
4967 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
4968
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004969 /* send first ciphered I-frame in response and expect it on RSL */
4970 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02004971
4972 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
4973 * and hence enable encryption also on the downlink */
4974
4975 /* expect bi-directional communication work in encrypted mode */
4976 f_unitdata_mo(link_id, f_rnd_octstring(15));
4977 f_unitdata_mt(link_id, f_rnd_octstring(15));
4978
4979 /* release the channel */
4980 f_rsl_chan_deact();
4981 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4982 f_rslem_unregister(0, g_chan_nr);
4983}
4984testcase TC_encr_cmd_a51() runs on test_CT {
4985 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4986 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4987 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4988}
4989testcase TC_encr_cmd_a52() runs on test_CT {
4990 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4991 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4992 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4993}
4994testcase TC_encr_cmd_a53() runs on test_CT {
4995 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4996 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4997 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4998}
4999
5000private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
5001 var LapdmFrame lf;
5002 var octetstring reenc;
5003
5004 /* decode the LAPDm frame */
5005 if (ischosen(exp_match.ab)) {
5006 lf.ab := dec_LapdmFrameAB(enc);
5007 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005008 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02005009 }
5010
5011 /* check if decoder result matches expectation */
5012 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005013 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02005014 } else {
5015 log(name, ": matched");
5016 setverdict(pass);
5017 }
5018
5019 /* test if re-encoded frame equals original input */
5020 reenc := enc_LapdmFrame(lf);
5021 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005022 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02005023 } else {
5024 setverdict(pass);
5025 }
5026}
5027
5028testcase TC_lapdm_selftest() runs on test_CT {
5029 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
5030 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
5031 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
5032 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
5033 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
5034 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
5035 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
5036}
5037
Stefan Sperling4880be42018-08-07 18:12:59 +02005038/***********************************************************************
5039 * DTX Related (see GSM 05.08, section 8.3)
5040 ***********************************************************************/
5041
5042/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
5043function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
5044 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
5045 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
5046 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
5047 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
5048}
5049function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
5050 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
5051 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
5052}
5053function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
5054 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
5055 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
5056 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
5057 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
5058}
5059function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
5060 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
5061 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
5062 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
5063 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
5064 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
5065 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
5066 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
5067 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
5068}
5069
5070function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
5071 var L1ctlDlMessage dl;
5072 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
5073 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
5074 var GsmFrameNumber first_fn;
5075 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005076 var integer nfill_frames_sacch := 0;
5077 var integer nfill_frames_nonsacch := 0;
5078 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02005079 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
5080 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005081 const integer frame_dtx_tchf_mod := 104;
5082 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
5083 * which operates in terms of blocks rather than frames. */
5084 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
5085 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02005086 timer T := 5.0;
5087
5088 f_l1_tune(L1CTL);
5089 RSL.clear;
5090 L1CTL.clear;
5091
5092 /* activate TCHF signalling channel */
5093 f_est_dchan(false);
5094
5095 T.start;
5096 alt {
5097 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5098 var GsmFrameNumber fn := dl.dl_info.frame_nr;
5099 var octetstring l2 := dl.payload.data_ind.payload;
5100
5101 if (is_first_frame) {
5102 is_first_frame := false;
5103 first_fn := dl.dl_info.frame_nr;
5104 }
5105
5106 if (dl.dl_info.link_id.c == SACCH) {
5107 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
5108 if (not match(l2_fill_frame_sacch, l2)) {
5109 repeat;
5110 }
5111 } else if (not match(l2_fill_frame, l2)) {
5112 repeat;
5113 }
5114
5115 if (dtxd) {
5116 if (not f_g_chan_is_tchf()) {
5117 T.stop;
5118 f_rsl_chan_deact();
5119 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005120 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!");
Stefan Sperling4880be42018-08-07 18:12:59 +02005121 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005122 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02005123 T.stop;
5124 f_rsl_chan_deact();
5125 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005126
5127 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
5128 * 2 SACCH, 1 TCH/F */
5129 expected_fill_frames := 3;
5130
5131 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
5132 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
5133 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005134 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02005135 } else {
5136 setverdict(pass);
5137 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005138 } else {
5139 if (dl.dl_info.link_id.c == SACCH) {
5140 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02005141 repeat;
5142 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005143 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
5144 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
5145 * we should only see the subset of frames numbers which correspond to a block boundary.
5146 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
5147 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
5148 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
5149 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
5150 repeat;
5151 }
5152 }
5153 log("Received DTX TCH fill frame with bad frame number: ", fn,
5154 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
5155 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
5156 f_rsl_chan_deact();
5157 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005158 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02005159 }
Stefan Sperling4880be42018-08-07 18:12:59 +02005160 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005161 if (dl.dl_info.link_id.c == SACCH) {
5162 nfill_frames_sacch := nfill_frames_sacch + 1;
5163 } else {
5164 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
5165 }
5166 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02005167 T.stop;
5168 if (f_g_chan_is_tchf()) {
5169 /* Without DTX we can expect 25 fill frames for every 104 frames.
5170 * (24 FACCH + 1 SACCH filling) */
5171 expected_fill_frames := 25;
5172 } else if (f_g_chan_is_tchh()) {
5173 /* We can expect 2 fill frames for every 104 frames. */
5174 expected_fill_frames := 2;
5175 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
5176 /* We can expect 5 fill frames for every 104 frames. */
5177 expected_fill_frames := 5;
5178 } else {
5179 f_rsl_chan_deact();
5180 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005181 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02005182 }
5183
5184 f_rsl_chan_deact();
5185 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005186
5187 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02005188 setverdict(pass);
5189 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02005190 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
5191 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005192 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02005193 }
5194 } else {
5195 repeat;
5196 }
5197 }
5198 }
5199 [] L1CTL.receive { repeat; }
5200 [] T.timeout {
5201 f_rsl_chan_deact();
5202 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005203 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02005204 }
5205 }
5206}
5207
5208function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
5209 f_test_l2_fill_frames(false);
5210}
5211
5212function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
5213 f_test_l2_fill_frames(true);
5214}
5215
5216function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
5217 var ConnHdlr vc_conn;
5218 var ConnHdlrPars pars;
5219 pars.t_guard := 60.0;
5220 f_init(testcasename());
5221 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
5222 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
5223 if (dtxd) {
5224 if (i >= 4) { /* DTX is only allowed on TCH/F */
5225 break;
5226 }
5227 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
5228 } else {
5229 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
5230 }
5231 vc_conn.done;
5232 }
5233}
5234
5235/* Verify that L2 fill frames are sent on TCH in signaling mode if
5236 * there is nothing to transmit while DTX is disabled on downlink. */
5237testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
5238 f_tch_sign_l2_fill_frame(false);
5239}
5240
5241/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
5242 * there is nothing to transmit while DTX is enabled on downlink. */
5243testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
5244 f_tch_sign_l2_fill_frame(true);
5245}
Harald Welte0472ab42018-03-12 15:02:26 +01005246
Stefan Sperling0ec1c262018-10-15 15:12:52 +02005247testcase TC_chopped_ipa_ping() runs on test_CT {
5248 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
5249}
5250
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005251testcase TC_chopped_ipa_payload() runs on test_CT {
5252 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
5253}
5254
Harald Welte0472ab42018-03-12 15:02:26 +01005255/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
5256/* protocol error as per 44.006 */
5257/* link layer failure (repetition of I-frame N200 times without ACK */
5258/* repetition of SABM or DISC N200 times without ACK */
5259/* receptiom of SABM in multi-frame established state */
5260
5261
Harald Welte68e495b2018-02-25 00:05:57 +01005262/* TODO Areas:
5263
5264* channel activation
5265** with BS_Power / MS_Power, bypassing power control loop
5266** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01005267** with timing advance from initial activation on
5268* mode modify
5269** encryption
5270** multirate
5271* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01005272** unsupported algorithm
5273* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01005274* BS Power Control
5275* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01005276* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01005277* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01005278** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01005279* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01005280** DATA_IND from BTS->PCU
5281** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01005282
5283*/
Harald Welte70767382018-02-21 12:16:40 +01005284
5285control {
5286 execute( TC_chan_act_stress() );
5287 execute( TC_chan_act_react() );
5288 execute( TC_chan_deact_not_active() );
5289 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01005290 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01005291 execute( TC_sacch_filling() );
5292 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01005293 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01005294 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02005295 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02005296 execute( TC_sacch_chan_act_ho_async() );
5297 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01005298 execute( TC_rach_content() );
5299 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01005300 execute( TC_rach_max_ta() );
Harald Welte3453ab42019-05-24 21:19:58 +02005301 execute( TC_rach_load_idle_thresh0() );
5302 execute( TC_rach_load_idle_below_thresh() );
5303 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01005304 execute( TC_meas_res_sign_tchf() );
5305 execute( TC_meas_res_sign_tchh() );
5306 execute( TC_meas_res_sign_sdcch4() );
5307 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01005308 execute( TC_meas_res_sign_tchh_toa256() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01005309 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wilde57e1a62019-05-28 13:30:55 +02005310 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02005311 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02005312 execute( TC_rsl_modify_encr() );
Harald Welte70767382018-02-21 12:16:40 +01005313 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01005314 execute( TC_paging_imsi_80percent() );
5315 execute( TC_paging_tmsi_80percent() );
5316 execute( TC_paging_imsi_200percent() );
5317 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01005318 execute( TC_rsl_protocol_error() );
5319 execute( TC_rsl_mand_ie_error() );
5320 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01005321 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01005322 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01005323 execute( TC_si_sched_2bis() );
5324 execute( TC_si_sched_2ter() );
5325 execute( TC_si_sched_2ter_2bis() );
5326 execute( TC_si_sched_2quater() );
5327 execute( TC_si_sched_13() );
5328 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01005329 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01005330 execute( TC_ipa_crcx_twice_not_active() );
5331 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01005332 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01005333 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01005334
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01005335 if (mp_pcu_socket != "") {
5336 execute( TC_pcu_act_req() );
5337 execute( TC_pcu_act_req_wrong_ts() );
5338 execute( TC_pcu_act_req_wrong_bts() );
5339 execute( TC_pcu_act_req_wrong_trx() );
5340 execute( TC_pcu_deact_req() );
5341 execute( TC_pcu_deact_req_wrong_ts() );
5342 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02005343 if (mp_l1_supports_gprs) {
5344 execute( TC_pcu_data_req_pdtch() );
5345 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02005346 execute( TC_pcu_data_req_wrong_bts() );
5347 execute( TC_pcu_data_req_wrong_trx() );
5348 execute( TC_pcu_data_req_wrong_ts() );
5349 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02005350 }
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01005351 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02005352 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01005353 execute( TC_pcu_data_req_imm_ass_pch() );
5354 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07005355 execute( TC_pcu_ext_rach_content() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01005356 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02005357 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02005358 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02005359 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02005360 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02005361 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02005362 execute( TC_pcu_socket_reconnect() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01005363 } else {
5364 log("PCU socket path not available, skipping PCU tests");
5365 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005366
5367 execute( TC_dyn_osmo_pdch_act_deact() );
5368 execute( TC_dyn_osmo_pdch_unsol_deact() );
5369 execute( TC_dyn_osmo_pdch_double_act() );
5370 execute( TC_dyn_osmo_pdch_tchf_act() );
5371 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02005372 execute( TC_dyn_ipa_pdch_act_deact() );
5373 execute( TC_dyn_ipa_pdch_tchf_act() );
5374 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
5375 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01005376
5377 execute( TC_rll_est_ind() );
5378 execute( TC_rll_est_req_DCCH_3() );
5379 execute( TC_rll_est_req_ACCH_3() );
5380 execute( TC_rll_rel_ind_DCCH_0() );
5381 execute( TC_rll_rel_ind_DCCH_3() );
5382 execute( TC_rll_rel_ind_ACCH_0() );
5383 execute( TC_rll_rel_ind_ACCH_3() );
5384 execute( TC_rll_rel_req() );
5385 execute( TC_rll_unit_data_req_DCCH() );
5386 execute( TC_rll_unit_data_req_ACCH() );
5387 execute( TC_rll_unit_data_ind_DCCH() );
5388 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02005389
5390 execute( TC_chan_act_a51() );
5391 execute( TC_chan_act_a52() );
5392 execute( TC_chan_act_a53() );
5393 execute( TC_encr_cmd_a51() );
5394 execute( TC_encr_cmd_a52() );
5395 execute( TC_encr_cmd_a53() );
5396
Harald Welteee25aae2019-05-19 14:32:37 +02005397 execute( TC_err_rep_wrong_mdisc() );
5398 execute( TC_err_rep_wrong_msg_type() );
5399 execute( TC_err_rep_wrong_sequence() );
5400
Harald Weltee613f962018-04-18 22:38:16 +02005401 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02005402
5403 execute( TC_tch_sign_l2_fill_frame() );
5404 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02005405
5406 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005407 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01005408}
5409
5410
5411}