blob: 80804ec6d0a6ee20feb9893830ee231513babde3 [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
Harald Welte14906952019-05-27 09:19:49 +02003/* Integration Tests for OsmoBTS
Harald Welte34b5a952019-05-27 11:54:11 +02004 * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org>
Harald Welte14906952019-05-27 09:19:49 +02005 * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH
6 * All rights reserved.
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
10 *
Harald Welte34b5a952019-05-27 11:54:11 +020011 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
Harald Welte14906952019-05-27 09:19:49 +020013 * This test suite tests OsmoBTS by attaching to the external interfaces
14 * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation
15 * using the L1CTL protocol/interface.
16 *
17 * You can run the tests with
18 * a) osmo-bts-trx + trxcon + fake_trx (without any hardware)
19 * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware)
20 * c) osmo-bts-virtual + virt_phy (without any hardware)
21 *
22 * Some of the tests will only run on a subset of those three configurations
23 * due to limitations in the respective L1.
24 */
25
Daniel Willmann0fcc4d32018-10-23 20:32:19 +020026import from Misc_Helpers all;
Harald Welte70767382018-02-21 12:16:40 +010027import from General_Types all;
28import from GSM_Types all;
29import from GSM_RR_Types all;
30import from Osmocom_Types all;
31import from GSM_Types all;
Vadim Yanitskiy5d2cf442020-05-02 16:49:17 +070032import from GSM_RestOctets all;
Harald Welte82ccef72018-02-25 16:17:33 +010033import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010034import from L1CTL_PortType all;
35import from L1CTL_Types all;
36import from LAPDm_Types all;
Harald Weltead033dc2019-05-25 17:28:16 +020037import from LAPDm_RAW_PT all;
Harald Welte70767382018-02-21 12:16:40 +010038import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020039import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010040
41import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010042import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010043import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020044import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010045import from RSL_Emulation all;
46
47import from IPL4asp_Types all;
48import from TRXC_Types all;
49import from TRXC_CodecPort all;
50import from TRXC_CodecPort_CtrlFunct all;
51
Harald Welte883340c2018-02-28 18:59:29 +010052import from PCUIF_Types all;
53import from PCUIF_CodecPort all;
Harald Weltea2e0e942019-05-27 18:12:53 +020054import from UD_Types all;
Harald Welte883340c2018-02-28 18:59:29 +010055
Harald Welte7484fc42018-02-24 14:09:45 +010056import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010057import from MobileL3_RRM_Types all;
58import from MobileL3_Types all;
59import from L3_Templates all;
Harald Welteeaa9a862019-05-26 23:01:08 +020060import from L3_Common all;
61import from MobileL3_GMM_SM_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010062
Harald Welte8da48242018-02-27 20:41:32 +010063import from Osmocom_VTY_Functions all;
64import from TELNETasp_PortType all;
Harald Welte2f2b2b72019-05-31 22:24:57 +020065import from BTS_Tests_LAPDm all;
Harald Welte8da48242018-02-27 20:41:32 +010066
Harald Welte505cf9b2018-09-15 17:47:23 +030067friend module BTS_Tests_SMSCB;
Harald Weltead033dc2019-05-25 17:28:16 +020068friend module BTS_Tests_virtphy;
Harald Welte2f2b2b72019-05-31 22:24:57 +020069friend module BTS_Tests_LAPDm;
Pau Espin Pedrol5a012ee2020-02-06 19:33:22 +010070friend module BTS_Tests_perf;
Harald Welte505cf9b2018-09-15 17:47:23 +030071
Harald Welte70767382018-02-21 12:16:40 +010072/* The tests assume a BTS with the following timeslot configuration:
73 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020074 * TS1 : TCH/F
75 * TS2 : TCH/F
76 * TS3 : TCH/F_PDCH (IPA Style)
77 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010078 * TS5 : TCH/H
79 * TS6 : SDCCH/8
80 * TS7 : PDCH
81 */
82
83modulepar {
84 charstring mp_rsl_ip := "127.0.0.2";
85 integer mp_rsl_port := 3003;
86 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +070087 integer mp_trx1_arfcn := 873;
88 integer mp_trx2_arfcn := 875;
89 integer mp_trx3_arfcn := 877;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070090 charstring mp_bts_trxc_ip := "127.0.0.1";
91 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010092 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020093 charstring mp_ctrl_ip := "127.0.0.1";
94 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020095 charstring mp_bsc_ctrl_ip := "127.0.0.1";
96 integer mp_bsc_ctrl_port := 4249;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020097 integer mp_tolerance_rxqual := 1;
98 integer mp_tolerance_rxlev := 3;
99 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200100 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200101 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200102 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200103 integer mp_ms_actual_ta_exp := 0;
104 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100105 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +0200106 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200107 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200108 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
109 boolean mp_l1_supports_gprs := false;
Harald Welte70767382018-02-21 12:16:40 +0100110}
111
Harald Welte629cc6b2018-03-11 17:19:05 +0100112type record of RslChannelNr ChannelNrs;
113
Harald Welte70767382018-02-21 12:16:40 +0100114type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100115 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100116 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100117 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100118 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100119 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100120 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100121
122 /* L1CTL port (for classic tests) */
123 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100124
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700125 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700126 port TRXC_CODEC_PT BTS_TRXC;
127 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100128
Harald Weltef50e3ae2018-09-10 10:27:56 +0200129 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100130 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200131 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100132
Harald Welte883340c2018-02-28 18:59:29 +0100133 /* PCU Interface of BTS */
134 port PCUIF_CODEC_PT PCU;
135 var integer g_pcu_conn_id;
136 /* Last PCU INFO IND we received */
137 var PCUIF_Message g_pcu_last_info;
138
Harald Welte48494ca2018-02-25 16:59:50 +0100139 /* SI configuration */
140 var SystemInformationConfig si_cfg := {
141 bcch_extended := false,
142 si1_present := false,
143 si2bis_present := false,
144 si2ter_present := false,
145 si2quater_present := false,
146 si7_present := false,
147 si8_present := false,
148 si9_present := false,
149 si13_present := false,
150 si13alt_present := false,
151 si15_present := false,
152 si16_present := false,
153 si17_present := false,
154 si2n_present := false,
155 si21_present := false,
156 si22_present := false
157 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100158
159 /* all logical channels available on the BTS */
160 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100161 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100162}
163
164/* an individual call / channel */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200165type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100166 port L1CTL_PT L1CTL;
167
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700168 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700169 port TRXC_CODEC_PT BTS_TRXC;
170 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100171
172 timer g_Tguard;
173 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
174
175 var ConnHdlrPars g_pars;
176 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100177 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200178
179 /* PCU Interface of BTS */
180 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100181}
182
183function f_init_rsl(charstring id) runs on test_CT {
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700184 timer T := mp_ipa_up_timeout;
185
Harald Welte70767382018-02-21 12:16:40 +0100186 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
187 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
188
189 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
190 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
191 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
192
193 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
194 vc_RSL.start(RSL_Emulation.main(false));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700195
196 T.start;
197 alt {
Vadim Yanitskiy6de2fcb2020-05-25 19:40:45 +0700198 /* TODO: handle connection events from multiple transceivers */
199 [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700200 [] T.timeout {
201 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
202 }
203 }
Harald Welte70767382018-02-21 12:16:40 +0100204}
205
206type record ConnHdlrPars {
207 RslChannelNr chan_nr,
208 RSL_IE_ChannelMode chan_mode,
209 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100210 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200211 TestSpecUnion spec optional,
Eric Wild61edb7e2019-06-03 12:38:31 +0200212 RSL_IE_EncryptionInfo encr optional,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700213 BtsBand bts0_band optional,
214
215 /* Frequency hopping parameters (disabled if absent) */
216 MaioHsn maio_hsn optional,
217 /* MA bitmap to be indicated in RR Immediate Assignment */
218 MobileAllocation ma_map,
219 /* The actual Mobile Allocation (ARFCN list) to be used */
220 L1ctlMA ma
Harald Welte0472ab42018-03-12 15:02:26 +0100221}
222
223/* Test-specific parameters */
224type union TestSpecUnion {
225 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100226}
227
Harald Welte82ccef72018-02-25 16:17:33 +0100228template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100231 cell_barr_access := false,
232 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100233 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100234};
235
Harald Weltef10153f2018-02-25 16:34:05 +0100236template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100237 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200238 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100239 acs := '0'B,
240 neci := true,
241 rxlev_access_min := 0
242}
243
244template (value) LocationAreaIdentification ts_LAI_default := {
245 mcc_mnc := '262F42'H,
246 lac := 42
247}
248
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700249private template (value) GPRSIndicator ts_GPRSIndicator_def := {
250 ra_colour := 0,
251 si13_pos := '0'B
252}
253
254private template (value) SI3RestOctets ts_SI3RestOctets_def
255modifies ts_SI3RestOctets := {
256 gprs_ind := {
257 presence := CSN1_H,
258 ind := ts_GPRSIndicator_def
259 }
260}
261
262private template (value) SI4RestOctets ts_SI4RestOctets_def
263modifies ts_SI4RestOctets := {
264 gprs_ind := {
Vadim Yanitskiyab5363f2020-05-05 00:30:22 +0700265 presence := CSN1_H,
266 ind := ts_GPRSIndicator_def
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700267 }
268}
269
Harald Welte7484fc42018-02-24 14:09:45 +0100270/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100271template (value) SystemInformation ts_SI3_default := {
272 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100273 payload := {
274 si3 := {
275 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100276 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100277 ctrl_chan_desc := {
278 msc_r99 := true,
279 att := true,
280 bs_ag_blks_res := 1,
281 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100282 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100283 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
284 spare := '00'B,
285 bs_pa_mfrms := 0, /* 2 multiframes */
286 t3212 := 1 /* 6 minutes */
287 },
Harald Welte82ccef72018-02-25 16:17:33 +0100288 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100289 dn_ind := false,
290 pwrc := false,
291 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100292 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100293 },
Harald Weltef10153f2018-02-25 16:34:05 +0100294 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100295 rach_control := ts_RachCtrl_default,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700296 rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def))
Harald Welte7484fc42018-02-24 14:09:45 +0100297 }
298 }
299}
Harald Welte70767382018-02-21 12:16:40 +0100300
Harald Weltef8df4cb2018-03-10 15:15:08 +0100301template (value) SystemInformation ts_SI2_default := {
302 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100303 payload := {
304 si2 := {
305 bcch_freq_list := '00000000000000000000000000000000'O,
306 ncc_permitted := '11111111'B,
307 rach_control := ts_RachCtrl_default
308 }
309 }
310}
311
Harald Weltef8df4cb2018-03-10 15:15:08 +0100312template (value) SystemInformation ts_SI4_default := {
313 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100314 payload := {
315 si4 := {
316 lai := ts_LAI_default,
317 cell_sel_par := ts_CellSelPar_default,
318 rach_control := ts_RachCtrl_default,
319 cbch_chan_desc := omit,
320 cbch_mobile_alloc := omit,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700321 rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def))
Harald Weltef10153f2018-02-25 16:34:05 +0100322 }
323 }
324}
325
326function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
327runs on test_CT {
328 log("Setting ", rsl_si_type, ": ", si_enc);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +0700329 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
Harald Weltef10153f2018-02-25 16:34:05 +0100330}
331
332function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
333runs on test_CT {
334 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
335 log("Setting ", rsl_si_type, ": ", si_dec);
336 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
337}
338
Harald Welte505cf9b2018-09-15 17:47:23 +0300339friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100340 map(self:BTSVTY, system:BTSVTY);
341 f_vty_set_prompts(BTSVTY);
342 f_vty_transceive(BTSVTY, "enable");
343}
344
Harald Welte505cf9b2018-09-15 17:47:23 +0300345friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200346 map(self:BSCVTY, system:BSCVTY);
347 f_vty_set_prompts(BSCVTY, "OsmoBSC");
348 f_vty_transceive(BSCVTY, "enable");
349}
350
Harald Welte883340c2018-02-28 18:59:29 +0100351/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200352private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
353 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100354 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200355 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
356 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100357 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200358 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200359 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100360 }
361}
362
Harald Weltef26de0b2018-04-04 20:28:05 +0200363private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
364 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100365 timer T := 2.0;
366 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100367 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200368 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100369 return;
370 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200371 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100372
373 T.start;
374 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200375 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100376 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200377 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100378 }
379 }
380}
381
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700382private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
383 out integer trxc_conn_id) {
384 var Result res;
385
386 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
387 "", -1, -1, { udp := {} }, {});
388 if (not ispresent(res.connId)) {
389 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
390 "Could not connect to the control (TRXC) interface " &
391 "of FakeTRX, check your configuration");
392 }
393 trxc_conn_id := res.connId;
394}
395
Harald Welte70767382018-02-21 12:16:40 +0100396/* global init function */
Harald Welte10474062019-05-30 16:48:17 +0200397function f_init() runs on test_CT {
398 var charstring id := testcasename();
Harald Welte629cc6b2018-03-11 17:19:05 +0100399 g_AllChannels := {
400 /* TS 1..4: TCH/F */
401 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
402 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
403 /* TS 5: TCH/H */
404 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
405 /* TS 0: SDCCH/4 */
406 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
407 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
408 /* TS 6: SDCCH/8 */
409 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
410 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
411 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
412 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
413 };
414
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200415 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700416 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200417 g_AllChanTypes := {
418 /* TS 1..4: TCH/F */
419 valueof(ts_RslChanNr_Bm(1)),
420 /* TS 5: TCH/H */
421 valueof(ts_RslChanNr_Lm(5,1)),
422 /* TS 0: SDCCH/4 */
423 valueof(ts_RslChanNr_SDCCH4(0,2)),
424 /* TS 6: SDCCH/8 */
425 valueof(ts_RslChanNr_SDCCH8(6,4))
426 };
427 } else {
428 g_AllChanTypes := {
429 /* TS 1..4: TCH/F */
430 valueof(ts_RslChanNr_Bm(1)),
431 /* TS 0: SDCCH/4 */
432 valueof(ts_RslChanNr_SDCCH4(0,2)),
433 /* TS 6: SDCCH/8 */
434 valueof(ts_RslChanNr_SDCCH8(6,4))
435 };
436 }
Harald Welte70767382018-02-21 12:16:40 +0100437 f_init_rsl(id);
Harald Welte2d142592018-02-25 13:19:44 +0100438 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100439 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200440 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100441
442 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100443 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
444 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
445 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
446 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100447
Harald Weltef26de0b2018-04-04 20:28:05 +0200448 map(self:PCU, system:PCU);
449 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100450
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700451 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100452 var TrxcMessage ret;
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700453
454 /* Init TRXC interface to FakeTRX */
455 map(self:BTS_TRXC, system:BTS_TRXC);
456 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
457
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700458 /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700459 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700460 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60)));
Vadim Yanitskiyde535e02019-07-26 16:29:27 +0700461 /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
462 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60)));
Harald Welte84271622018-03-10 17:21:03 +0100463 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200464
465 /* Wait some extra time to make sure the BTS emits a stable carrier.
466 * (this is only relevant when running the tests with a physical BTS.) */
467 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100468}
469
Harald Welte68e495b2018-02-25 00:05:57 +0100470/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
471function f_init_l1ctl() runs on test_CT {
472 map(self:L1CTL, system:L1CTL);
473 f_connect_reset(L1CTL);
474}
475
Harald Welte70767382018-02-21 12:16:40 +0100476type function void_fn(charstring id) runs on ConnHdlr;
477
478/* create a new test component */
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700479function f_start_handler(void_fn fn, ConnHdlrPars pars,
480 boolean pcu_comp := false,
481 boolean trxc_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100482runs on test_CT return ConnHdlr {
483 var charstring id := testcasename();
484 var ConnHdlr vc_conn;
485
486 vc_conn := ConnHdlr.create(id);
487 /* connect to RSL Emulation main component */
488 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
489 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700490
491 /* The ConnHdlr component may want to talk to some ports directly,
492 * so we disconnect it from the test_CT and connect it to the component.
493 * This obviously only works for one component, i.e. no concurrency. */
Harald Weltef26de0b2018-04-04 20:28:05 +0200494 if (pcu_comp) {
Harald Weltef26de0b2018-04-04 20:28:05 +0200495 unmap(self:PCU, system:PCU);
496 map(vc_conn:PCU, system:PCU);
497 }
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700498 if (trxc_comp) {
499 unmap(self:BTS_TRXC, system:BTS_TRXC);
500 map(vc_conn:BTS_TRXC, system:BTS_TRXC);
501 }
Harald Welte70767382018-02-21 12:16:40 +0100502
503 vc_conn.start(f_handler_init(fn, id, pars));
504 return vc_conn;
505}
506
Harald Welte70767382018-02-21 12:16:40 +0100507private altstep as_Tguard() runs on ConnHdlr {
508 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200509 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100510 }
511}
512
Harald Welte990a3612019-05-27 14:02:13 +0200513friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
514 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100515}
516
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700517private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100518 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700519 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100520}
521
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700522private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100523 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700524 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100525}
526
527/* first function started in ConnHdlr component */
528private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
529runs on ConnHdlr {
530 g_pars := pars;
531 g_chan_nr := pars.chan_nr;
532
533 map(self:L1CTL, system:L1CTL);
534 f_connect_reset(L1CTL);
535
Harald Welted48c0c72019-06-05 10:01:15 +0200536 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700537 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100538 }
Harald Welte70767382018-02-21 12:16:40 +0100539
540 g_Tguard.start(pars.t_guard);
541 activate(as_Tguard());
542
543 f_rslem_register(0, pars.chan_nr);
544
545 /* call the user-supplied test case function */
546 fn.apply(id);
547}
548
Harald Welteb1726c92018-03-30 11:56:38 +0200549function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
550 boolean ignore_other := false)
551runs on ConnHdlr return RSL_Message {
552 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100553 timer T := 3.0;
554 RSL.send(tx);
555 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100556 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200557 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100558 T.stop;
559 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100560 }
Harald Welte1eba3742018-02-25 12:48:14 +0100561 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200562 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100563 }
Harald Welte21240e62018-03-11 21:43:35 +0100564 [not ignore_other] as_l1_sacch();
565 [not ignore_other] as_meas_res();
566 [not ignore_other] as_l1_dcch();
567 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200568 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100569 }
Harald Welte21240e62018-03-11 21:43:35 +0100570 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100571 }
Harald Welteb1726c92018-03-30 11:56:38 +0200572 return rx;
573}
574
575function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
576 boolean ignore_other := false)
577runs on ConnHdlr {
578 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100579}
580
Harald Welte8b01c792019-05-19 22:51:25 +0200581function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
582 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
583 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200584 if (encr_enable) {
585 /* append encryption related IEs, if requested */
586 var RSL_IE_EncryptionInfo encr_info;
587 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
588 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
589encr_info})) };
590 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200591 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200592 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100593}
594
Harald Welte70767382018-02-21 12:16:40 +0100595function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100596 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 +0100597 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100598}
599
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700600/* Default Mobile Allocation to be used for frequency hopping */
601private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn },
602 { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } };
603
Harald Welte2f2b2b72019-05-31 22:24:57 +0200604friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Harald Welte70767382018-02-21 12:16:40 +0100605 template RSL_IE_ChannelMode chan_mode,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700606 template (omit) MaioHsn maio_hsn := omit,
Harald Welte70767382018-02-21 12:16:40 +0100607 float t_guard := 20.0) := {
608 chan_nr := valueof(chan_nr),
609 chan_mode := valueof(chan_mode),
610 t_guard := t_guard,
611 l1_pars := {
612 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100613 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100614 meas_ul := {
615 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200616 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100617 rxqual := 0
618 },
619 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200620 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100621 rxqual := 0
622 }
623 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200624 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100625 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200626 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200627 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100628 },
Harald Weltee613f962018-04-18 22:38:16 +0200629 spec := omit,
Eric Wild61edb7e2019-06-03 12:38:31 +0200630 encr := omit,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700631 bts0_band := omit,
632 maio_hsn := maio_hsn,
633 ma_map := c_MA_null,
634 ma := l1ctl_ma_def
Harald Welte70767382018-02-21 12:16:40 +0100635}
636
Harald Welte93640c62018-02-25 16:59:33 +0100637/***********************************************************************
638 * Channel Activation / Deactivation
639 ***********************************************************************/
640
Harald Welte70767382018-02-21 12:16:40 +0100641/* Stress test: Do 500 channel activations/deactivations in rapid succession */
642function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
643 for (var integer i := 0; i < 500; i := i+1) {
644 f_rsl_chan_act(g_pars.chan_mode);
645 f_rsl_chan_deact();
646 }
647 setverdict(pass);
648}
649testcase TC_chan_act_stress() runs on test_CT {
650 var ConnHdlr vc_conn;
651 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +0200652 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100653 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
654 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200655 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100656}
657
658/* Test if re-activation of an already active channel fails as expected */
659function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
660 f_rsl_chan_act(g_pars.chan_mode);
661 /* attempt to activate the same lchan again -> expect reject */
662 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
663 alt {
664 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200665 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100666 }
667 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
668 setverdict(pass);
669 }
670 }
671 f_rsl_chan_deact();
672}
673testcase TC_chan_act_react() runs on test_CT {
674 var ConnHdlr vc_conn;
675 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100676 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100677 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
678 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100680}
681
682/* Attempt to de-activate a channel that's not active */
683function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
684 timer T := 3.0;
685 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
686 T.start;
687 alt {
688 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
689 setverdict(pass);
690 }
691 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200692 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100693 }
694 }
695}
696testcase TC_chan_deact_not_active() runs on test_CT {
697 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100698 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100699 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
700 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100702}
703
704/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
705function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
706 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
707 alt {
708 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200709 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100710 }
711 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
712 setverdict(pass);
713 }
714 }
715}
716private type record WrongChanNrCase {
717 RslChannelNr chan_nr,
718 charstring description
719}
720private type record of WrongChanNrCase WrongChanNrCases;
721private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
722 chan_nr := chan_nr,
723 description := desc
724}
725
726testcase TC_chan_act_wrong_nr() runs on test_CT {
727 var ConnHdlr vc_conn;
728 var ConnHdlrPars pars;
729
Harald Welte294b0a22018-03-10 23:26:48 +0100730 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100731
732 var WrongChanNrCases wrong := {
733 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
734 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
735 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
736 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
737 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
738 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
739 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
740 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
741 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
742 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
743 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
744 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
745 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
746 };
747
748 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
749 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
750 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
751 vc_conn.done;
752 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200753 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100754}
755
Harald Weltee613f962018-04-18 22:38:16 +0200756/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200757friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +0200758 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +0200759 f_init();
Harald Weltee613f962018-04-18 22:38:16 +0200760
761 /* test on each of the channels we have */
762 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
763 pars.chan_nr := valueof(g_AllChanTypes[i]);
764
765 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
766 vc_conn := f_start_handler(fn, pars);
767 vc_conn.done;
768 }
769
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200770 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200771}
772
Harald Welte93640c62018-02-25 16:59:33 +0100773/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100774 * SACCH handling
775 ***********************************************************************/
776
777private function f_exp_sacch(boolean exp) runs on ConnHdlr {
778 timer T_sacch := 3.0;
779 T_sacch.start;
780 alt {
781 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200782 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100783 }
784 [not exp] T_sacch.timeout {
785 setverdict(pass);
786 }
787 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
788 setverdict(pass);
789 }
790 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200791 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100792 }
793 [] L1CTL.receive { repeat; }
794 [] RSL.receive { repeat; }
795 }
796}
797
798/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
799private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
800 f_l1_tune(L1CTL);
801 RSL.clear;
802
803 /* activate the logical channel */
804 f_est_dchan();
805 L1CTL.clear;
806
807 /* check that SACCH actually are received as expected */
808 f_exp_sacch(true);
809
810 /* deactivate SACCH on the logical channel */
811 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
812 f_sleep(1.0);
813 L1CTL.clear;
814
815 /* check that no SACCH are received anymore */
816 f_exp_sacch(false);
817
818 /* release the channel */
819 f_rsl_chan_deact();
820 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
821}
822testcase TC_deact_sacch() runs on test_CT {
823 var ConnHdlr vc_conn;
824 var ConnHdlrPars pars;
825 f_init();
826 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
827 //for (var integer i := 0; i < 1; i := i+1) {
828 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
829 log(testcasename(), ": Starting for ", g_AllChannels[i]);
830 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
831 vc_conn.done;
832 }
833 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200834 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100835}
836
Harald Welte55700662018-03-12 13:15:43 +0100837/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100838private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
839 var L1ctlDlMessage dl;
840 /* check that the specified SI5 value is actually sent */
841 timer T_sacch := 3.0;
842 L1CTL.clear;
843 T_sacch.start;
844 alt {
845 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
846 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
847 if (match(l3, l3_exp)) {
848 setverdict(pass);
849 } else {
850 repeat;
851 }
852 }
853 [] L1CTL.receive { repeat; }
854 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200855 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100856 }
857 }
858}
859
Harald Welte55700662018-03-12 13:15:43 +0100860/* verify that given SACCH payload is not present */
861private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
862 var L1ctlDlMessage dl;
863 /* check that the specified SI5 value is actually sent */
864 timer T_sacch := 3.0;
865 L1CTL.clear;
866 T_sacch.start;
867 alt {
868 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
869 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
870 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200871 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100872 } else {
873 repeat;
874 }
875 }
876 [] L1CTL.receive { repeat; }
877 [] T_sacch.timeout {
878 setverdict(pass);
879 }
880 }
881}
882
Harald Welte629cc6b2018-03-11 17:19:05 +0100883/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100884private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
885 /* Set a known default SACCH filling for SI5 */
886 var octetstring si5 := f_rnd_octstring(19);
887 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
888
889 f_l1_tune(L1CTL);
890 RSL.clear;
891
892 /* activate the logical channel */
893 f_est_dchan();
894
895 /* check that the specified SI5 value is actually sent */
896 f_sacch_present(si5);
897
898 /* release the channel */
899 RSL.clear;
900 f_rsl_chan_deact();
901 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
902}
903testcase TC_sacch_filling() runs on test_CT {
904 var ConnHdlr vc_conn;
905 var ConnHdlrPars pars;
906 f_init();
907 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
908 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
909 log(testcasename(), ": Starting for ", g_AllChannels[i]);
910 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
911 vc_conn.done;
912 }
913 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200914 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100915}
916
Harald Welte629cc6b2018-03-11 17:19:05 +0100917/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100918private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
919 /* Set a known default SACCH filling for SI5 */
920 var octetstring si5 := f_rnd_octstring(19);
921 var octetstring si5_diff := f_rnd_octstring(19);
922 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
923
924 f_l1_tune(L1CTL);
925 RSL.clear;
926
927 log("Activating channel, expecting standard SI5");
928 /* activate the logical channel */
929 f_est_dchan();
930 /* check that the specified SI5 value is actually sent */
931 f_sacch_present(si5);
932
933 /* set channel-specific different SI5 */
934 log("Setting channel specific SACCH INFO, expecting it");
935 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
936 /* check that the specified lchan-specific value is now used */
937 f_sacch_present(si5_diff);
938
939 /* deactivate the channel and re-activate it, this should result in default SI5 */
940 log("De-activating and re-activating channel, expecting standard SI5");
941 f_rsl_chan_deact();
942 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
943 /* Verify that the TRX-wide default SACCH filling is present again */
944 f_sacch_present(si5);
945
946 /* release the channel */
947 RSL.clear;
948 f_rsl_chan_deact();
949 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
950}
951testcase TC_sacch_info_mod() runs on test_CT {
952 var ConnHdlr vc_conn;
953 var ConnHdlrPars pars;
954 f_init();
955 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
956 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
957 log(testcasename(), ": Starting for ", g_AllChannels[i]);
958 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
959 vc_conn.done;
960 }
961 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200962 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100963}
964
Harald Welte075d84c2018-03-12 13:07:24 +0100965/* Test SACCH scheduling of multiple different SI message types */
966private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
967 var octetstring si5 := f_rnd_octstring(19);
968 var octetstring si5bis := f_rnd_octstring(19);
969 var octetstring si5ter := f_rnd_octstring(19);
970 var octetstring si6 := f_rnd_octstring(19);
971
972 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
973 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
974 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
975 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
976
977 f_l1_tune(L1CTL);
978 RSL.clear;
979
980 /* activate the logical channel */
981 f_est_dchan();
982 L1CTL.clear;
983
984 /* check that SACCH actually are received as expected */
985 f_sacch_present(si5);
986 f_sacch_present(si5bis);
987 f_sacch_present(si5ter);
988 f_sacch_present(si6);
989
990 /* release the channel */
991 f_rsl_chan_deact();
992 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
993}
994testcase TC_sacch_multi() runs on test_CT {
995 var ConnHdlr vc_conn;
996 var ConnHdlrPars pars;
997 f_init();
998 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
999 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1000 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1001 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
1002 vc_conn.done;
1003 }
1004 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001005 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +01001006}
1007
Harald Welte55700662018-03-12 13:15:43 +01001008/* Test if SACH information is modified as expected */
1009private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
1010 var octetstring si5 := f_rnd_octstring(19);
1011 var octetstring si6 := f_rnd_octstring(19);
1012
1013 /* First, configure both SI5 and SI6 to be transmitted */
1014 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1015 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1016
1017 f_l1_tune(L1CTL);
1018 RSL.clear;
1019
1020 /* activate the logical channel */
1021 f_est_dchan();
1022 L1CTL.clear;
1023
1024 /* check that SACCH actually are received as expected */
1025 f_sacch_present(si5);
1026 f_sacch_present(si6);
1027
1028 /* disable SI6 */
1029 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1030
1031 /* check that SI5 is still transmitted */
1032 f_sacch_present(si5);
1033 /* check if SI6 is now gone */
1034 f_sacch_missing(si6);
1035
1036 /* release the channel */
1037 f_rsl_chan_deact();
1038 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1039}
1040testcase TC_sacch_multi_chg() runs on test_CT {
1041 var ConnHdlr vc_conn;
1042 var ConnHdlrPars pars;
1043 f_init();
1044 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1045 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1046 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1047 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1048 vc_conn.done;
1049 }
1050 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001051 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001052}
1053
Harald Weltec8d363c2019-05-19 20:36:48 +02001054/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1055private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1056 var octetstring si5 := f_rnd_octstring(19);
1057 var octetstring si6 := f_rnd_octstring(19);
1058 var octetstring si5_specific := f_rnd_octstring(19);
1059 var octetstring si6_specific := f_rnd_octstring(19);
1060
1061 /* First, configure both SI5 and SI6 to be transmitted */
1062 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1063 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1064
1065 f_l1_tune(L1CTL);
1066 RSL.clear;
1067
1068 /* activate channel with different SACCH filling */
1069 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1070 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1071 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1072 }));
1073 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1074 RSL_IE_Body:{sacch_info := sacch_info})) };
1075 f_est_dchan(more_ies := addl_ies);
1076
1077 /* check that SACCH actually are received as expected */
1078 f_sacch_present(si5_specific);
1079 f_sacch_present(si6_specific);
1080
1081 /* release the channel */
1082 f_rsl_chan_deact();
1083 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1084}
1085testcase TC_sacch_chan_act() runs on test_CT {
1086 var ConnHdlr vc_conn;
1087 var ConnHdlrPars pars;
1088 f_init();
1089
1090 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1091 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1092 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1093 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1094 vc_conn.done;
1095 }
1096 /* TODO: do the above in parallel, rather than sequentially? */
1097 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1098}
1099
Harald Welte8b01c792019-05-19 22:51:25 +02001100/* verify that SACCH DL transmission is started only if MS power IE present
1101 * see section 4.1.3 of 3GPP TS 48.058 */
1102private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1103 var octetstring si5 := f_rnd_octstring(19);
1104
1105 f_l1_tune(L1CTL);
1106 RSL.clear;
1107
1108 /* Step 1: Activate ASYNC 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_ASYNC);
1112 /* don't perform immediate assignment here, as we're testing non-IA case */
1113 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001114 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001115
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 2: Activate ASYNC HO channel with MS power IE */
1124
1125 /* Activate channel on BTS side */
1126 var RSL_IE_List 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_ASYNC);
1130 /* don't perform immediate assignment here, as we're testing non-IA case */
1131 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001132 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001133
1134 /* Verify that DL SACCH is being received */
1135 f_sacch_present(si5);
1136
1137 f_rsl_chan_deact();
1138 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1139}
1140testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1141 var ConnHdlr vc_conn;
1142 var ConnHdlrPars pars;
1143 f_init();
1144
1145 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1146 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1147 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1148 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1149 vc_conn.done;
1150 }
1151 /* TODO: do the above in parallel, rather than sequentially? */
1152 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1153}
1154
1155/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1156 * see section 4.1.4 of 3GPP TS 48.058 */
1157private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1158 var octetstring si5 := f_rnd_octstring(19);
1159 var RSL_IE_List addl_ies;
1160
1161 f_l1_tune(L1CTL);
1162 RSL.clear;
1163
1164 /* Step 1: Activate SYNC HO channel without MS power IE */
1165
1166 /* Activate channel on BTS side */
1167 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1168 /* don't perform immediate assignment here, as we're testing non-IA case */
1169 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001170 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001171
1172 /* Verify that no DL SACCH is being received */
1173 f_sacch_missing(?);
1174
1175 f_rsl_chan_deact();
1176 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1177
1178
1179 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1180
1181 /* Activate channel on BTS side */
1182 addl_ies := {
1183 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1184 };
1185 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1186 /* don't perform immediate assignment here, as we're testing non-IA case */
1187 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001188 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001189
1190 /* Verify that no DL SACCH is being received */
1191 f_sacch_missing(?);
1192
1193 f_rsl_chan_deact();
1194 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1195
1196
1197 /* Step 2b: Activate SYNC HO channel with TA IE */
1198
1199 /* Activate channel on BTS side */
1200 addl_ies := {
1201 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1202 };
1203 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1204 /* don't perform immediate assignment here, as we're testing non-IA case */
1205 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001206 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001207
1208 /* Verify that no DL SACCH is being received */
1209 f_sacch_missing(?);
1210
1211 f_rsl_chan_deact();
1212 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1213
1214
1215 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1216
1217 /* Activate channel on BTS side */
1218 addl_ies := {
1219 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1220 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1221 };
1222 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1223 /* don't perform immediate assignment here, as we're testing non-IA case */
1224 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001225 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001226
1227 /* Verify that DL SACCH is being received */
1228 f_sacch_present(si5);
1229
1230 f_rsl_chan_deact();
1231 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1232}
1233testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1234 var ConnHdlr vc_conn;
1235 var ConnHdlrPars pars;
1236 f_init();
1237
1238 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1239 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1240 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1241 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1242 vc_conn.done;
1243 }
1244 /* TODO: do the above in parallel, rather than sequentially? */
1245 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1246}
Harald Welte629cc6b2018-03-11 17:19:05 +01001247
1248
1249/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001250 * RACH Handling
1251 ***********************************************************************/
1252
Harald Welte8c24c2b2018-02-26 08:31:31 +01001253/* like L1SAP_IS_PACKET_RACH */
1254private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001255 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001256 return true;
1257 }
1258 return false;
1259}
1260
1261/* generate a random RACH for circuit-switched */
1262private function f_rnd_ra_cs() return OCT1 {
1263 var OCT1 ra;
1264 do {
1265 ra := f_rnd_octstring(1);
1266 } while (ra_is_ps(ra));
1267 return ra;
1268}
1269
Harald Welte883340c2018-02-28 18:59:29 +01001270/* generate a random RACH for packet-switched */
1271private function f_rnd_ra_ps() return OCT1 {
1272 var OCT1 ra;
1273 do {
1274 ra := f_rnd_octstring(1);
1275 } while (not ra_is_ps(ra));
1276 return ra;
1277}
1278
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001279/* generate a random 11-bit RA (packet-switched only) */
1280private function f_rnd_ra11_ps() return BIT11 {
1281 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1282 return int2bit(ra11, 11);
1283}
1284
Harald Welte8c24c2b2018-02-26 08:31:31 +01001285/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1286testcase TC_rach_content() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001287 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001288 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001289 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001290
Harald Welte8c24c2b2018-02-26 08:31:31 +01001291 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001292 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001293 for (var integer i := 0; i < 1000; i := i+1) {
1294 var OCT1 ra := f_rnd_ra_cs();
1295 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1296 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001297 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001298 }
1299 fn_last := fn;
1300
1301 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001302 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001303 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001304 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001305 T.stop;
1306 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001307 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001308 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001309 }
1310 [] RSL_CCHAN.receive { repeat; }
1311 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001312 test_failed := true;
1313 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001314 }
1315 }
1316 }
Maxba06feb2019-03-05 10:52:46 +01001317 if (test_failed) {
1318 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001319 }
Maxba06feb2019-03-05 10:52:46 +01001320 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001321 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001322}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001323
1324/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1325testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001326 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001327 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001328 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001329 f_l1_tune(L1CTL);
1330
1331 var GsmFrameNumber fn_last := 0;
1332 for (var integer i := 0; i < 1000; i := i+1) {
1333 var OCT1 ra := f_rnd_ra_cs();
1334 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1335 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001336 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001337 }
1338 fn_last := fn;
1339 }
1340 var integer rsl_chrqd := 0;
1341 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001342 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001343 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001344 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001345 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001346 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001347 repeat;
1348 }
1349 [] RSL_CCHAN.receive { repeat; }
1350 [] T.timeout { }
1351 }
1352 if (rsl_chrqd == 1000) {
1353 setverdict(pass);
1354 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001355 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001356 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001357 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001358}
1359
Harald Welte3453ab42019-05-24 21:19:58 +02001360private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1361 var charstring bts_str := "bts " & int2str(bts_nr);
1362 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1363}
1364
1365/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1366private template integer tr_rach_slots_per_interval := (90 .. 130);
1367
1368/* Expect 0 RACH load on an idle BTS that has just started up */
1369testcase TC_rach_load_idle_thresh0() runs on test_CT {
1370 var ASP_RSL_Unitdata rx_ud;
1371
1372 f_init_vty_bsc();
1373 /* send load indications even at 0% load */
1374 f_vty_load_ind_thresh(0);
1375 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1376 f_sleep(2.0);
1377
1378 f_init();
1379
1380 timer T := 5.0;
1381 T.start;
1382 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001383 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
Harald Welte3453ab42019-05-24 21:19:58 +02001384 setverdict(pass);
1385 repeat;
1386 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001387 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001388 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1389 repeat;
1390 }
1391 [] RSL_CCHAN.receive {
1392 repeat;
1393 }
1394 [] T.timeout { }
1395 }
1396
1397 f_vty_load_ind_thresh(10);
1398 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1399}
1400
1401/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1402testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1403 var ASP_RSL_Unitdata rx_ud;
1404
1405 f_init_vty_bsc();
1406 f_init();
1407
1408 timer T := 5.0;
1409 T.start;
1410 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001411 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001412 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1413 repeat;
1414 }
1415 [] RSL_CCHAN.receive {
1416 repeat;
1417 }
1418 [] T.timeout {
1419 setverdict(pass);
1420 }
1421 }
1422
1423 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1424}
1425
1426/* Expect 0 RACH load on an idle BTS that has just started up */
1427testcase TC_rach_load_count() runs on test_CT {
1428 var ASP_RSL_Unitdata rx_ud;
1429 var integer load_access_count := 0;
1430
1431 f_init_vty_bsc();
1432 /* send load indications even at 0% load */
1433 f_vty_load_ind_thresh(0);
1434 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1435 f_sleep(2.0);
1436 f_init();
1437
1438 f_init_l1ctl();
1439 f_sleep(1.0);
1440 f_l1_tune(L1CTL);
1441
1442 var GsmFrameNumber fn_last := 0;
1443 for (var integer i := 0; i < 1000; i := i+1) {
1444 var OCT1 ra := f_rnd_ra_cs();
1445 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1446 if (fn == fn_last) {
1447 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1448 }
1449 fn_last := fn;
1450 }
1451
1452 timer T := 5.0;
1453 T.start;
1454 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001455 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
Harald Welte3453ab42019-05-24 21:19:58 +02001456 -> value rx_ud {
1457 var RSL_IE_Body ie;
1458 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1459 load_access_count := load_access_count + ie.rach_load.access_count;
1460 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1461 setverdict(fail, "Access count cannot be < Busy count");
1462 }
1463 repeat;
1464 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001465 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001466 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1467 repeat;
1468 }
1469 [] RSL_CCHAN.receive {
1470 repeat;
1471 }
1472 [] T.timeout { }
1473 }
1474 if (load_access_count == 1000) {
1475 setverdict(pass);
1476 } else {
1477 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1478 }
1479
1480 f_vty_load_ind_thresh(10);
1481 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1482}
1483
Harald Welte54a2a2d2018-02-26 09:14:05 +01001484private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001485 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001486 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001487 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001488 f_sleep(0.5);
1489
1490 /* Transmit RACH request + wait for confirmation */
1491 var OCT1 ra := f_rnd_ra_cs();
1492 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1493
1494 /* Check for expected result */
1495 timer T := 1.5;
1496 T.start;
1497 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001498 [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welte54a2a2d2018-02-26 09:14:05 +01001499 setverdict(pass);
1500 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001501 [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001502 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001503 }
1504 [] RSL_CCHAN.receive { repeat; }
1505 [not expect_pass] T.timeout {
1506 setverdict(pass);
1507 }
1508 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001509 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001510 }
1511 }
1512}
1513
1514/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1515testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001516 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001517 f_init_l1ctl();
1518 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001519 f_sleep(1.0);
1520
1521 /* default max-ta is 63 (full range of GSM timing advance */
1522
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001523 /* We allow early arrival up to 2 symbols */
1524 f_rach_toffs(-1*256, true);
1525 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001526 f_rach_toffs(-10*256, false);
1527
1528 /* 0 / 32 / 63 bits is legal / permitted */
1529 f_rach_toffs(0, true);
1530 f_rach_toffs(32*256, true);
1531 f_rach_toffs(63*256, true);
1532
1533 /* more than 63 bits is not legal / permitted */
1534 f_rach_toffs(64*256, false);
1535 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001536 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001537}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001538
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001539function f_TC_ho_rach(charstring id) runs on ConnHdlr {
1540 var GsmFrameNumber fn;
1541 var RSL_Message rm;
1542
1543 f_l1_tune(L1CTL);
1544 RSL.clear;
1545
1546 /* Generate a random Handover Reference */
1547 var integer ho_ref := oct2int(f_rnd_octstring(1));
1548
1549 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1550 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1551 RSL_IE_Body:{ handover_ref := ho_ref }));
1552
1553 /* Activate a channel on the BTS side (no encryption) */
1554 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1555 act_type := t_RSL_IE_ActType_HO_SYNC);
1556
1557 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1558 * waiting for Immediate Assignment and sending Access Burst */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001559 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001560
1561 /* Send handover Access Burst */
1562 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1563
1564 /* TODO: test mismatching Handover Reference, and missing IE */
1565
1566 /* Wait for handover detection */
1567 timer T := 3.0;
1568 T.start;
1569 alt {
1570 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1571 log("Handover RACH has been detected: ", rm);
1572 setverdict(pass);
1573 }
1574 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1575 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1576 log2str("RSL_CHAN_RQD was not expected: ", rm));
1577 }
1578 [] RSL.receive { repeat; }
1579 [] T.timeout {
1580 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1581 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
1582 }
1583 }
1584
1585 /* Release the channel */
1586 f_rsl_chan_deact();
1587 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1588}
1589
1590/* Test handover RACH detection */
1591testcase TC_ho_rach() runs on test_CT {
1592 var ConnHdlrPars pars;
1593 var ConnHdlr vc_conn;
1594
1595 f_init();
1596
1597 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
1598 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1599 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1600 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
1601 vc_conn.done;
1602 }
1603
1604 /* TODO: do the above in parallel, rather than sequentially? */
1605 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1606}
1607
Harald Welte93640c62018-02-25 16:59:33 +01001608/***********************************************************************
1609 * Measurement Processing / Reporting
1610 ***********************************************************************/
1611
Harald Welte70767382018-02-21 12:16:40 +01001612template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1613 spare := '0'B,
1614 lpd := 0,
1615 sapi := sapi,
1616 c_r := c_r,
1617 ea := true
1618}
1619
Harald Welted879bd92018-03-12 15:01:23 +01001620template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001621 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001622 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001623 len := 0, /* overwritten */
1624 m := false,
1625 el := 1,
1626 payload := pl
1627}
1628
1629/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1630altstep as_l1_sacch() runs on ConnHdlr {
1631 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001632 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001633 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001634 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 +01001635 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001636 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001637
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001638 var template (value) SacchL1Header l1h := ts_SacchL1Header(
1639 g_pars.l1_pars.ms_power_level, false,
1640 g_pars.l1_pars.ms_actual_ta);
1641
1642 /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */
1643 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O);
1644
1645 log("Sending Measurement Report: ", l1h, l2);
1646 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01001647 repeat;
1648 }
1649}
1650
1651altstep as_l1_dcch() runs on ConnHdlr {
1652 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001653 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001654 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1655 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001656 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1657 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001658 repeat;
1659 }
1660}
1661
1662type record MeasElem {
1663 uint6_t rxlev,
1664 uint3_t rxqual
1665}
1666
1667type record MeasElemFS {
1668 MeasElem full,
1669 MeasElem sub
1670}
1671
1672type record ConnL1Pars {
1673 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001674 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001675 MeasElemFS meas_ul,
1676 int16_t timing_offset_256syms,
1677 uint5_t bs_power_level,
1678 uint5_t ms_power_level,
1679 uint8_t ms_actual_ta
1680}
1681
1682/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1683private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1684 return 63 + (toffs256s/256);
1685}
1686
Harald Welted5684392018-03-10 18:22:04 +01001687private function f_max(integer a, integer b) return integer {
1688 if (a > b) {
1689 return a;
1690 } else {
1691 return b;
1692 }
1693}
1694
1695private function f_min(integer a, integer b) return integer {
1696 if (a < b) {
1697 return a;
1698 } else {
1699 return b;
1700 }
1701}
1702
1703/* compute negative tolerance val-tolerance, ensure >= min */
1704private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1705 val := val - tolerance;
1706 return f_max(val, min);
1707}
1708
1709/* compute positive tolerance val+tolerance, ensure <= max */
1710private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1711 val := val + tolerance;
1712 return f_min(val, max);
1713}
1714
1715/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1716private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1717return template integer {
1718 var template integer ret;
1719 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1720 return ret;
1721}
1722
1723
Harald Welte70767382018-02-21 12:16:40 +01001724/* build a template for matching measurement results against */
1725private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1726 var ConnL1Pars l1p := g_pars.l1_pars;
1727 var template RSL_IE_UplinkMeas ul_meas := {
1728 len := 3,
1729 rfu := '0'B,
1730 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001731 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001732 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001733 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001734 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001735 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1736 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001737 supp_meas_info := omit
1738 };
Harald Welte685d5982018-02-27 20:42:05 +01001739 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001740 ul_meas.len := (3+8);
1741 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001742 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001743 toa256_min := ?,
1744 toa256_max := ?,
1745 toa256_std_dev := ?
1746 }
Harald Welte685d5982018-02-27 20:42:05 +01001747 }
Harald Welte70767382018-02-21 12:16:40 +01001748 var template RSL_IE_BS_Power bs_power := {
1749 reserved := 0,
1750 epc := false,
1751 fpc := false,
1752 power_level := l1p.bs_power_level
1753 };
1754 var template RSL_IE_L1Info l1_info := {
1755 ms_power_lvl := l1p.ms_power_level,
1756 fpc := false,
1757 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001758 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001759 };
1760 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001761 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001762 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1763 ?, t_toffs);
1764}
1765
Philipp Maierdd841d32019-12-17 14:44:54 +01001766/* build a template for matching measurement results that do not contain any
1767 * MS related measurement (l1_info, l3_info and ms timing offset). */
1768private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
1769 var ConnL1Pars l1p := g_pars.l1_pars;
1770 var template RSL_IE_UplinkMeas ul_meas := {
1771 len := 3,
1772 rfu := '0'B,
1773 dtx_d := l1p.dtx_enabled,
1774 rxlev_f_u := ?,
1775 reserved1 := '00'B,
1776 rxlev_s_u := ?,
1777 reserved2 := '00'B,
1778 rxq_f_u := ?,
1779 rxq_s_u := ?,
1780 supp_meas_info := omit
1781 };
1782 if (l1p.toa256_enabled) {
1783 ul_meas.len := (3+8);
1784 ul_meas.supp_meas_info := {
1785 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
1786 toa256_min := ?,
1787 toa256_max := ?,
1788 toa256_std_dev := ?
1789 }
1790 }
1791 var template RSL_IE_BS_Power bs_power := {
1792 reserved := 0,
1793 epc := false,
1794 fpc := false,
1795 power_level := l1p.bs_power_level
1796 };
1797
1798 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
1799}
1800
Harald Welte70767382018-02-21 12:16:40 +01001801/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001802altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001803 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01001804 var boolean chan_est := false;
1805
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001806 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01001807
1808 /* Receive osmocom specific measurement reports. This is the normal
1809 * case. Here we verify that the measurement reports we sent are
1810 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01001811 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1812 /* increment counter of next to-be-expected meas rep */
1813 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1814 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001815 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01001816
1817 /* The following two cases may only happen in the beginning
1818 * of the channel establishment phase. Once we have received
1819 * the "our" measurement report the first time, the channel
1820 * is established and empty or hardcoded TRXCON reports must
1821 * not occur anymore. */
1822 chan_est := true;
1823
1824 repeat;
1825 }
1826
1827 /* When the BTS has established the channel, the MS might need slightly
1828 * more time to establish the channel and actually start sending. The
1829 * result is then a measurement report that just lacks the measurement
1830 * information of the MS. This is normal and we tolerate this behavior. */
1831 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
1832 /* increment counter of next to-be-expected meas rep */
1833 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1834 /* Re-start the timer expecting the next MEAS RES */
1835 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001836 repeat;
1837 }
Philipp Maierdd841d32019-12-17 14:44:54 +01001838
1839 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
1840 * measurements if the TTCN3 side does not supply measurement input in
1841 * time. In those cases TRXCON will either use a cached measurement
1842 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
1843 * report the templates above will not match. We tolerate this
1844 * behavior, but only once. */
1845 [chan_est == false] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001846 /* increment counter of next to-be-expected meas rep */
1847 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1848 if (g_first_meas_res) {
1849 g_first_meas_res := false;
1850 repeat;
1851 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001852 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001853 }
Harald Welte70767382018-02-21 12:16:40 +01001854 }
1855 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001856 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001857 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001858 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001859 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001860 }
1861}
1862
Harald Weltee613f962018-04-18 22:38:16 +02001863private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1864 select (rsl_alg_id) {
1865 case (RSL_ALG_ID_A5_0) { return 0; }
1866 case (RSL_ALG_ID_A5_1) { return 1; }
1867 case (RSL_ALG_ID_A5_2) { return 2; }
1868 case (RSL_ALG_ID_A5_3) { return 3; }
1869 case (RSL_ALG_ID_A5_4) { return 4; }
1870 case (RSL_ALG_ID_A5_5) { return 5; }
1871 case (RSL_ALG_ID_A5_6) { return 6; }
1872 case (RSL_ALG_ID_A5_7) { return 7; }
1873 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001874 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1875 /* Make compiler happy by calling mtc.stop here. It is already
1876 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001877 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001878 }
1879 }
1880}
1881
1882private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1883 select (rsl_alg_id) {
1884 case (RSL_ALG_ID_A5_1) { return '000'B; }
1885 case (RSL_ALG_ID_A5_2) { return '001'B; }
1886 case (RSL_ALG_ID_A5_3) { return '010'B; }
1887 case (RSL_ALG_ID_A5_4) { return '011'B; }
1888 case (RSL_ALG_ID_A5_5) { return '100'B; }
1889 case (RSL_ALG_ID_A5_6) { return '101'B; }
1890 case (RSL_ALG_ID_A5_7) { return '110'B; }
1891 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001892 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1893 /* Make compiler happy by calling mtc.stop here. It is already
1894 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001895 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001896 }
1897 }
1898}
1899
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001900/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1901private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1902 var GsmFrameNumber fn;
1903 timer T := 8.0;
1904
1905 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1906 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1907
1908 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1909 /* Send the actual RACH */
1910 fn := f_L1CTL_RACH(L1CTL, ra);
1911
1912 T.start;
1913 alt {
1914 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1915 [] T.timeout {
1916 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1917 }
1918 }
1919 T.stop
1920 return fn;
1921}
Harald Weltee613f962018-04-18 22:38:16 +02001922
Harald Welte70767382018-02-21 12:16:40 +01001923/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001924private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001925 var GsmFrameNumber fn;
1926 var ImmediateAssignment imm_ass;
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001927 var ChannelDescription ch_desc;
Harald Welte70767382018-02-21 12:16:40 +01001928 var integer ra := 23;
1929
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001930 /* Send RACH request and wait for ChanReq */
1931 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001932
1933 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001934 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001935
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001936 /* Craft channel description (with or without frequency hopping parameters) */
1937 if (ispresent(g_pars.maio_hsn)) {
1938 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, maio_hsn := g_pars.maio_hsn));
1939 } else {
1940 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr));
1941 }
1942
Harald Welte70767382018-02-21 12:16:40 +01001943 /* Send IMM.ASS via CCHAN */
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001944 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.ma_map));
Harald Welte70767382018-02-21 12:16:40 +01001945 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1946
1947 /* receive IMM.ASS on MS side */
1948 var ImmediateAssignment ia_um;
1949 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001950
1951 /* Make sure that IMM.ASS contains hopping parameters (if enabled) */
1952 if (ch_desc.h != ia_um.chan_desc.h) {
1953 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch");
1954 }
1955
Harald Welte70767382018-02-21 12:16:40 +01001956 /* enable dedicated mode */
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001957 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.ma);
Harald Weltee613f962018-04-18 22:38:16 +02001958 /* enable encryption, if requested */
1959 if (encr_enable) {
1960 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1961 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1962 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001963
1964 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001965}
1966
1967/* establish DChan, verify existance + contents of measurement reports */
1968function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001969 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001970 RSL.clear;
1971
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001972 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001973 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07001974 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001975 }
Harald Welte70767382018-02-21 12:16:40 +01001976
1977 f_est_dchan();
1978
1979 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1980 * RSL measurement reports on Abis side */
1981 timer T := 8.0;
1982 T.start;
1983 alt {
1984 [] as_l1_sacch();
1985 [] as_meas_res();
1986 [] as_l1_dcch();
1987 [] L1CTL.receive { repeat; }
1988 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001989 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001990 * of any earlier errors, so if we reach this timeout, we're good */
1991 setverdict(pass);
1992 }
1993 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001994 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001995 }
1996 }
1997 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001998 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001999}
Harald Welte0472ab42018-03-12 15:02:26 +01002000
Eric Wildae8f2622019-06-18 17:05:11 +02002001function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
2002 timer T := 8.0;
2003 T.start;
2004 var RSL_Message rsl;
2005 alt {
2006 [] as_l1_sacch();
2007 [] L1CTL.receive { repeat; }
2008 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
2009 if (rsl.ies[3].body.bs_power.power_level == level) {
2010 setverdict(pass)
2011 } else {
2012 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
2013 }
2014 }
2015 [] T.timeout {
2016 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
2017 }
2018 }
2019}
2020
2021/* see if the rsl meas res contains our expeced bs power level
2022bs power set during assignment */
2023function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
2024 f_l1_tune(L1CTL);
2025 RSL.clear;
2026
2027 if (mp_bts_trxc_port != -1) {
2028 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2029 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2030 }
2031
2032 var uint5_t pwr_var := 1;
2033 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2034 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2035
2036 f_est_dchan(more_ies :={valueof(pwr)});
2037
2038 f_check_meas_bs_power_level(pwr_var);
2039
2040 f_rsl_chan_deact();
2041 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2042}
2043
2044/* see if the rsl meas res contains our expeced bs power level
2045bs power set after assignment */
2046function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
2047 f_l1_tune(L1CTL);
2048 RSL.clear;
2049
2050 if (mp_bts_trxc_port != -1) {
2051 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2052 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2053 }
2054
2055 var uint5_t pwr_var := 1;
2056 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2057
2058 f_est_dchan();
2059
2060 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2061
2062 f_check_meas_bs_power_level(pwr_var);
2063
2064 f_rsl_chan_deact();
2065 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2066}
2067
2068testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2069 var ConnHdlr vc_conn;
2070 var ConnHdlrPars pars;
2071 f_init();
2072 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2073 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2074 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2075 pcu_comp := false, trxc_comp := true);
2076 vc_conn.done;
2077 }
2078 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2079}
2080
2081testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2082 var ConnHdlr vc_conn;
2083 var ConnHdlrPars pars;
2084 f_init();
2085 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2086 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2087 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
2088 pcu_comp := false, trxc_comp := true);
2089 vc_conn.done;
2090 }
2091 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2092}
2093
Eric Wild61edb7e2019-06-03 12:38:31 +02002094/* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
2095second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds,
2096These power levels are valid for all bands and require no special handling */
2097function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
2098 var uint5_t pwr_var := 7;
2099 var L1ctlDlMessage l1_dl;
2100
2101 f_trxc_fake_rssi(rxlev2dbm(10));
2102 f_l1_tune(L1CTL);
2103 RSL.clear;
2104
2105 var RSL_IE_List addl_ies;
2106 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2107
2108 addl_ies := {
2109 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2110 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2111 };
2112
2113 /* establish with power parameters */
2114 f_est_dchan(more_ies := addl_ies);
2115
2116 /* set a high value to ensure L1 power control level increases */
2117 f_trxc_fake_rssi(rxlev2dbm(20));
2118
2119 timer T2 := 6.0;
2120 T2.start;
2121 alt {
2122 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002123 /* Update sent MS power to follow what BTS requests */
2124 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2125 if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002126 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002127 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002128 T2.stop;
2129 }
2130 [] L1CTL.receive { repeat; }
2131 [] T2.timeout {
2132 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2133 "Power Level in L1 header has not increased sufficiently");
2134 }
2135 }
2136
2137 /* set a low value to ensure L1 power control level decreases */
2138 f_trxc_fake_rssi(rxlev2dbm(0));
2139
2140 timer T4 := 6.0;
2141 T4.start;
2142 alt {
2143 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002144 /* Update sent MS power to follow what BTS requests */
2145 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2146 if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002147 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002148 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002149 T4.stop;
2150 setverdict(pass, "Power level in L1 decreased/increased as expected");
2151 }
2152 [] L1CTL.receive { repeat; }
2153 [] T4.timeout {
2154 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2155 "Power Level in L1 header has not decreased sufficiently");
2156 }
2157 }
2158
2159 f_rsl_chan_deact();
2160 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2161
2162}
2163
2164/* check that we do not exceed the max power */
2165function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
2166 var uint5_t pwr_var := 7;
2167 var L1ctlDlMessage l1_dl;
2168
2169 /* set a low value to ensure power increases */
2170 f_trxc_fake_rssi(rxlev2dbm(10));
2171 f_l1_tune(L1CTL);
2172 RSL.clear;
2173
2174 var RSL_IE_List addl_ies;
2175 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2176
2177 addl_ies := {
2178 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2179 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2180 };
2181
2182 /* establish with power parameters */
2183 f_est_dchan(more_ies := addl_ies);
2184
2185 timer T1 := 10.0;
2186 T1.start;
2187 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002188 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2189 /* Update sent MS power to follow what BTS requests */
2190 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2191 repeat;
2192 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002193 [] L1CTL.receive { repeat; }
2194 [] T1.timeout {
2195 if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){
2196 setverdict(fail, "Power level in L1 header should not have changed");
2197 }
2198 }
2199 }
2200
2201 f_rsl_chan_deact();
2202 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2203
2204}
2205
2206/* see if we reach the band max power */
2207function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
2208 var L1ctlDlMessage l1_dl;
2209 var uint5_t pwr_var := 15;
2210 var uint5_t pwr_max_var := f_get_max_power_from_band();
2211
2212 /* set a low value to ensure power increases */
2213 f_trxc_fake_rssi(rxlev2dbm(10));
2214 f_l1_tune(L1CTL);
2215 RSL.clear;
2216
2217 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2218 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2219
2220 /* establish with fixed power level */
2221 f_est_dchan(more_ies :={valueof(pwr)});
2222
2223 /* check our initial power level */
2224 f_wait_for_l1_power_level(pwr_var);
2225
2226 /* update power param to enable power loop
2227 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
2228 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
2229
2230 /* wait, then check that our power level was reduced */
2231 timer T1 := 10.0;
2232 T1.start;
2233 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002234 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2235 /* Update sent MS power to follow what BTS requests */
2236 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2237 repeat;
2238 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002239 [] L1CTL.receive { repeat; }
2240 [] T1.timeout {
2241 var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]);
2242 if( f_power_level_is_highest_dbm(rcv) ){
2243 setverdict(pass, "Power level in L1 header reduced as expected");
2244 } else {
2245 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2246 log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv));
2247 }
2248 }
2249 }
2250
2251 f_rsl_chan_deact();
2252 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2253
2254}
2255
2256/* see if we reach the band min power */
2257function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
2258 var L1ctlDlMessage l1_dl;
2259
2260 /* set a high value to ensure power decreases */
2261 f_trxc_fake_rssi(rxlev2dbm(50));
2262 f_l1_tune(L1CTL);
2263 RSL.clear;
2264
2265 var uint5_t pwr_var := 5;
2266 var uint5_t pwr_target_val := 15;
2267
2268 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2269 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2270
2271 /* establish with fixed power level */
2272 f_est_dchan(more_ies :={valueof(pwr)});
2273
2274 /* check our initial power level */
2275 f_wait_for_l1_power_level(pwr_var);
2276
2277 /* update power param to enable power loop
2278 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01002279 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02002280
2281 /* wait, then check that our power level was increased */
2282 timer T1 := 10.0;
2283 T1.start;
2284 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002285 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2286 /* Update sent MS power to follow what BTS requests */
2287 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2288 repeat;
2289 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002290 [] L1CTL.receive { repeat; }
2291 [] T1.timeout {
2292 if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){
2293 setverdict(pass, "Power level in L1 header increased to lowest power value");
2294 } else {
2295 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2296 "Power level in L1 header NOT increased to lowest power value");
2297 }
2298 }
2299 }
2300
2301 f_rsl_chan_deact();
2302 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2303
2304}
2305
Eric Wild095024b2019-06-17 15:08:57 +02002306/* see if we change the power level without receiving power parameters, which should not happen
2307rsl chan act WITHOUT power parameters */
Eric Wild280ccb82019-06-17 11:11:52 +02002308function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
2309 var L1ctlDlMessage l1_dl;
2310
2311 /* set a high value to ensure power decreases */
2312 f_trxc_fake_rssi(rxlev2dbm(50));
2313 f_l1_tune(L1CTL);
2314 RSL.clear;
2315
2316 var uint5_t pwr_var := 5;
2317
2318 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2319 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2320
2321 /* establish with fixed power level */
2322 f_est_dchan(more_ies :={valueof(pwr)});
2323
2324 /* check our initial power level */
2325 f_wait_for_l1_power_level(pwr_var);
2326
2327 /* wait, then check that our power level did not change */
2328 timer T1 := 10.0;
2329 T1.start;
2330 alt {
2331 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2332 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2333 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2334 "BS power control should not be active unless we receive a power parameters IE!");
2335 }
2336 repeat;
2337 }
2338 [] L1CTL.receive { repeat; }
2339 [] T1.timeout { setverdict(pass); }
2340 }
2341
2342 f_rsl_chan_deact();
2343 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2344
2345}
2346
Eric Wild095024b2019-06-17 15:08:57 +02002347/* see if we change the power level without receiving power parameters, which should not happen
2348ms power control WITHOUT power parameters */
2349function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
2350 var L1ctlDlMessage l1_dl;
2351
2352 /* set a high value to ensure power decreases */
2353 f_trxc_fake_rssi(rxlev2dbm(50));
2354 f_l1_tune(L1CTL);
2355 RSL.clear;
2356
2357 var uint5_t pwr_var := 5;
2358
2359 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2360 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2361
2362 /* establish with fixed power level */
2363 f_est_dchan(more_ies :={valueof(pwr)});
2364
2365 /* check our initial power level */
2366 f_wait_for_l1_power_level(pwr_var);
2367
2368 /* pwr control without power params IE, should NOT activate MS power control*/
2369 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2370
2371 /* wait, then check that our power level did not change */
2372 timer T1 := 10.0;
2373 T1.start;
2374 alt {
2375 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2376 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2377 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2378 "BS power control should not be active unless we receive a power parameters IE!");
2379 }
2380 repeat;
2381 }
2382 [] L1CTL.receive { repeat; }
2383 [] T1.timeout { setverdict(pass); }
2384 }
2385
2386 f_rsl_chan_deact();
2387 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2388
2389}
2390
Eric Wild61edb7e2019-06-03 12:38:31 +02002391function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
2392 var L1ctlDlMessage l1_dl;
2393 timer T0 := 10.0;
2394 T0.start;
2395 alt {
2396 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2397 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) {
2398 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2399 "Power level in L1 header != signaled (RSL) power level.");
2400 }
2401 }
2402 [] L1CTL.receive { repeat; }
2403 [] T0.timeout {
2404 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2405 "Timeout waiting for initial power level");
2406 }
2407 }
2408 T0.stop;
2409}
2410
2411private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
2412 var IntegerRecord min_dbm_level;
2413 var IntegerRecord max_dbm_level;
2414 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2415
2416 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
2417 if (min_dbm_level[i] == level) {
2418 return true;
2419 }
2420 }
2421 return false;
2422}
2423
2424private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
2425 var IntegerRecord min_dbm_level;
2426 var IntegerRecord max_dbm_level;
2427 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2428
2429 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
2430 if (max_dbm_level[i] == level) {
2431 return true;
2432 }
2433 }
2434 return false;
2435}
2436
2437private function f_get_max_power_from_band() runs on ConnHdlr return integer {
2438 var IntegerRecord min_dbm_level;
2439 var IntegerRecord max_dbm_level;
2440 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2441 return max_dbm_level[0];
2442}
2443
2444type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
2445template charstring BtsBand_allGSM:= pattern "GSM???";
2446private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
2447 // 45.005 4.1.1
2448 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
2449 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2450 2, 1, 0};
2451 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
2452 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
2453 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
2454 var IntegerRecord rv;
2455
2456 select(band){
2457 case (BtsBand_allGSM){
2458 rv := gsm_power;
2459 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
2460 max_dbm_level := {2, 1, 0};
2461 }
2462 case("DCS1800"){
2463 rv := dcs_power;
2464 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
2465 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
2466 }
2467 case("PCS1900"){
2468 rv := pcs_power;
2469 min_dbm_level := {15};
2470 max_dbm_level := {30};
2471 }
2472 }
2473
2474 return rv;
2475}
2476
2477private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
2478 return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0);
2479}
2480
2481testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
2482 var ConnHdlr vc_conn;
2483 var ConnHdlrPars pars;
2484 f_init();
2485 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2486 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2487 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2488 pars.bts0_band := f_vty_get_bts0_band();
2489 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
2490 vc_conn.done;
2491 }
2492 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2493 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2494}
2495
2496testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
2497 var ConnHdlr vc_conn;
2498 var ConnHdlrPars pars;
2499 f_init();
2500 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2501 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2502 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2503 pars.bts0_band := f_vty_get_bts0_band();
2504 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
2505 vc_conn.done;
2506 }
2507 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2508 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2509}
2510
2511testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
2512 var ConnHdlr vc_conn;
2513 var ConnHdlrPars pars;
2514 f_init();
2515 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2516 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2517 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2518 pars.bts0_band := f_vty_get_bts0_band();
2519 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
2520 vc_conn.done;
2521 }
2522 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2523 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2524}
2525
2526testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
2527 var ConnHdlr vc_conn;
2528 var ConnHdlrPars pars;
2529 f_init();
2530 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2531 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2532 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2533 pars.bts0_band := f_vty_get_bts0_band();
2534 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
2535 vc_conn.done;
2536 }
2537 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2538 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2539}
2540
Eric Wild280ccb82019-06-17 11:11:52 +02002541testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
2542 var ConnHdlr vc_conn;
2543 var ConnHdlrPars pars;
2544 f_init();
2545 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2546 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2547 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2548 pars.bts0_band := f_vty_get_bts0_band();
2549 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
2550 vc_conn.done;
2551 }
2552 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2553 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2554}
2555
Eric Wild095024b2019-06-17 15:08:57 +02002556testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
2557 var ConnHdlr vc_conn;
2558 var ConnHdlrPars pars;
2559 f_init();
2560 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2561 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2562 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2563 pars.bts0_band := f_vty_get_bts0_band();
2564 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
2565 vc_conn.done;
2566 }
2567 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2568 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2569}
2570
Harald Welte70767382018-02-21 12:16:40 +01002571testcase TC_meas_res_sign_tchf() runs on test_CT {
2572 var ConnHdlr vc_conn;
2573 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002574 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002575 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2576 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002577 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2578 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002579 vc_conn.done;
2580 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002581 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002582}
2583testcase TC_meas_res_sign_tchh() runs on test_CT {
2584 var ConnHdlr vc_conn;
2585 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002586 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002587 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2588 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002589 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2590 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002591 vc_conn.done;
2592 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002593 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002594}
2595testcase TC_meas_res_sign_sdcch4() runs on test_CT {
2596 var ConnHdlr vc_conn;
2597 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002598 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002599 for (var integer ss := 0; ss <= 3; ss := ss+1) {
2600 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002601 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2602 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002603 vc_conn.done;
2604 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002605 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002606}
2607testcase TC_meas_res_sign_sdcch8() runs on test_CT {
2608 var ConnHdlr vc_conn;
2609 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002610 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002611 for (var integer ss := 0; ss <= 7; ss := ss+1) {
2612 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002613 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2614 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002615 vc_conn.done;
2616 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002617 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002618}
Harald Welte685d5982018-02-27 20:42:05 +01002619testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
2620 var ConnHdlr vc_conn;
2621 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002622 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01002623 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
2624 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2625 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
2626 pars.l1_pars.toa256_enabled := true;
2627 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
2628 vc_conn.done;
2629 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002630 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01002631}
2632
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002633/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
2634 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
2635function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
2636 var L1ctlDlMessage l1_dl;
2637 var RSL_IE_MS_Power ms_power;
2638 var RSL_Message rsl;
2639 var uint5_t power_level := 0;
2640
2641 f_l1_tune(L1CTL);
2642 RSL.clear;
2643
2644 f_est_dchan();
2645
2646 ms_power.reserved := 0;
2647 ms_power.fpc_epc := false;
2648
2649 /* Send the first power control command. This will disable any BTS/TRX
2650 * internal power control and switch the MS (which is not in scope of
2651 * this test) to a constant power level. We start with a power level
2652 * of 0 */
2653 ms_power.power_level := power_level;
2654 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2655 RSL.send(rsl);
2656
2657 alt {
2658
2659 /* Pick all SACCH blocks for checking */
2660 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2661
2662 /* The first byte of the L1 header contains the power level.
2663 * The reserved bits and the fpc bit is set to 0, so we may
2664 * compare directly. */
2665 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
2666 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
2667 }
2668
2669 /* Signal a new power level via RSL for the next turn. */
2670 if (power_level < 31) {
2671 power_level := power_level + 1;
2672 ms_power.power_level := power_level;
2673 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2674 RSL.send(rsl);
2675 repeat;
2676 }
2677
2678 }
2679
2680 /* Ignore all other blocks */
2681 [] L1CTL.receive { repeat; }
2682
2683 }
2684
2685 f_rsl_chan_deact();
2686 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2687
2688 setverdict(pass);
2689}
2690
2691testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
2692 var ConnHdlr vc_conn;
2693 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002694 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002695
2696 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2697 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2698 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
2699 vc_conn.done;
2700 }
2701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2702}
Harald Welte70767382018-02-21 12:16:40 +01002703
Eric Wild6833cc92019-05-23 19:34:44 +02002704/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
2705TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
2706function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
2707 var L1ctlDlMessage l1_dl;
2708 var uint5_t ta_to_test := 16;
2709
2710
2711 f_l1_tune(L1CTL);
2712 RSL.clear;
2713
2714 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002715 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02002716
2717 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
2718
2719
2720 alt {
2721
2722 /* Pick all SACCH blocks for checking */
2723 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2724
2725 /* The second byte of the L1 header contains the TA. */
2726 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
2727 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
2728 }
2729
2730 }
2731
2732 /* Ignore all other blocks */
2733 [] L1CTL.receive { repeat; }
2734
2735 }
2736
2737 f_rsl_chan_deact();
2738 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2739
2740 setverdict(pass);
2741}
2742
2743testcase TC_rsl_chan_initial_ta() runs on test_CT {
2744 var ConnHdlr vc_conn;
2745 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002746 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02002747 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002748 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
2749 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02002750 vc_conn.done;
2751 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2752}
2753
Eric Wilde57e1a62019-05-28 13:30:55 +02002754/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
2755function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
2756 var L1ctlDlMessage l1_dl;
2757 var uint5_t ms_power_level := 7;
2758
2759 var RSL_IE_MS_Power ms_power;
2760 ms_power.reserved := 0;
2761 ms_power.fpc_epc := false;
2762 ms_power.power_level := ms_power_level;
2763
2764 f_l1_tune(L1CTL);
2765 RSL.clear;
2766
2767 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
2768
2769 timer T := 1.0;
2770 T.start;
2771 alt {
2772 /* Pick all SACCH blocks for checking */
2773 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2774 /* The first byte of the L1 header contains the power level.. */
2775 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) {
2776 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2777 }
2778 }
2779 /* Ignore all other blocks */
2780 [] L1CTL.receive { repeat; }
2781 [] T.timeout {
2782 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2783 }
2784 }
2785
2786 f_rsl_chan_deact();
2787 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2788 setverdict(pass);
2789}
2790
2791testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
2792 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2793 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
2794}
2795
Harald Welte0472ab42018-03-12 15:02:26 +01002796/* 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 +01002797private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002798 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002799 RSL.clear;
2800
2801 f_est_dchan();
2802 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01002803 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01002804
2805 timer T := 40.0;
2806 T.start;
2807 alt {
2808 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
2809 setverdict(pass)
2810 }
2811 [] RSL.receive { repeat };
2812 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002813 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01002814 }
2815 }
2816 f_rsl_chan_deact();
2817}
2818testcase TC_conn_fail_crit() runs on test_CT {
2819 var ConnHdlr vc_conn;
2820 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002821 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002822 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
2823 pars.t_guard := 60.0;
2824 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
2825 vc_conn.done;
2826}
2827
Harald Welte93640c62018-02-25 16:59:33 +01002828/***********************************************************************
2829 * Paging
2830 ***********************************************************************/
2831
Harald Welte68e495b2018-02-25 00:05:57 +01002832function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
2833 if (tmsi == 'FFFFFFFF'O) {
2834 return true;
2835 } else {
2836 return false;
2837 }
2838}
Harald Welte70767382018-02-21 12:16:40 +01002839
Philipp Maier82cb0b12018-08-31 14:41:39 +02002840type record allowedFn { integer frame_nr }
2841template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2842template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2843template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2844template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2845template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2846template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2847template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2848template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2849function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2850{
2851 var integer frame_nr_51;
2852 frame_nr_51 := frame_nr mod 51
2853
2854 var allowedFn fn_check;
2855 fn_check.frame_nr := frame_nr_51;
2856
2857 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002858 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002859 return;
2860 }
2861
2862 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2863 return;
2864 }
2865 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2866 return;
2867 }
2868 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2869 return;
2870 }
2871 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2872 return;
2873 }
2874 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2875 return;
2876 }
2877 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2878 return;
2879 }
2880 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2881 return;
2882 }
2883 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2884 return;
2885 }
2886
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002887 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002888 return;
2889}
2890
2891altstep 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 +01002892runs on test_CT {
2893 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002894 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002895 repeat;
2896 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002897 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002898 var octetstring without_plen :=
2899 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2900 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002901
2902 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2903
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07002904 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
2905 /* Ignore empty RR Paging Request (PCH filling) messages.
2906 * TODO: does it make sense to count them? */
2907 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002908 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2909 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002910 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002911 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2912 }
2913 } else if (match(rr, tr_PAGING_REQ2)) {
2914 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2915 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2916 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2917 }
2918 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2919 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2920 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002921 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002922 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2923 }
2924 } else if (match(rr, tr_PAGING_REQ3)) {
2925 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2926 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2927 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2928 }
2929 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2930 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2931 }
2932 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2933 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2934 }
2935 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2936 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2937 }
2938 }
2939 repeat;
2940 }
2941}
2942
2943type record PagingTestCfg {
2944 boolean combined_ccch,
2945 integer bs_ag_blks_res,
2946 float load_factor,
2947 boolean exp_load_ind,
2948 boolean exp_overload,
2949 boolean use_tmsi
2950}
2951
2952type record PagingTestState {
2953 integer num_paging_sent,
2954 integer num_paging_rcv_msgs,
2955 integer num_paging_rcv_ids,
2956 integer num_overload
2957}
2958
2959/* receive + ignore RSL RF RES IND */
2960altstep as_rsl_res_ind() runs on test_CT {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07002961 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002962 repeat;
2963 }
2964}
2965
2966/* Helper function for paging related testing */
2967private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Harald Welte10474062019-05-30 16:48:17 +02002968 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01002969 f_init_l1ctl();
2970 f_l1_tune(L1CTL);
2971
2972 var PagingTestState st := {
2973 num_paging_sent := 0,
2974 num_paging_rcv_msgs := 0,
2975 num_paging_rcv_ids := 0,
2976 num_overload := 0
2977 };
2978
2979 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2980 var float max_pch_imsi_per_sec;
2981 if (cfg.use_tmsi) {
2982 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2983 } else {
2984 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2985 }
2986 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2987 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002988 var float time_total := 20.0;
2989 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2990 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002991
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002992 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2993 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002994
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002995 timer T_itv := 0.0;
2996 T_itv.start;
2997 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002998 alt {
2999 /* check for presence of CCCH LOAD IND (paging load) */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003000 [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Harald Welte68e495b2018-02-25 00:05:57 +01003001 st.num_overload := st.num_overload + 1;
3002 repeat;
3003 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003004 [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003005 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01003006 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003007 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003008 log("Rx LOAD_IND");
3009 /* FIXME: analyze/verify interval + contents */
3010 repeat;
3011 }
3012 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02003013 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003014 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003015 [] T_itv.timeout {
3016 /* Send paging cmds based on elapsed time */
3017 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
3018 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003019 var MobileIdentityV mi;
3020
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003021 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003022 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003023 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003024 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003025 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003026 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003027
3028 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003029 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003030
3031 st.num_paging_sent := st.num_paging_sent + 1;
3032 }
3033 if (st.num_paging_sent < pkt_total) {
3034 /* Wait for interval to next PAGING COMMAND */
3035 var float time_now := T_total.read;
3036 var float next_sched := int2float(st.num_paging_sent)*interval;
3037 if (next_sched > time_now) {
3038 T_itv.start(next_sched - time_now);
3039 } else {
3040 T_itv.start(0.0);
3041 }
3042 } else {
3043 /* We are done, no need to keep counting */
3044 T_total.stop;
3045 }
3046 }
3047 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01003048 [] as_rsl_res_ind();
3049 }
3050 }
3051
3052 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
3053 timer T_wait := 18.0;
3054 T_wait.start;
3055 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02003056 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003057 [] L1CTL.receive { repeat; }
3058 /* 65535 == empty paging queue, we can terminate*/
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003059 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
3060 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01003061 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003062 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01003063 }
3064 [] as_rsl_res_ind();
3065 }
3066
3067 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
3068 " rcvd_ids=", st.num_paging_rcv_ids);
3069 return st;
3070}
3071
3072/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
3073 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3074 * - that CCCH LOAD IND (PCH) are being generated
3075 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3076testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003077 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003078 var PagingTestCfg cfg := {
3079 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003080 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003081 load_factor := 0.8,
3082 exp_load_ind := true,
3083 exp_overload := false,
3084 use_tmsi := false
3085 };
3086 var PagingTestState st := f_TC_paging(cfg);
3087 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003088 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3089 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003090 } else {
3091 setverdict(pass);
3092 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003093 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003094}
3095
3096/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
3097 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3098 * - that CCCH LOAD IND (PCH) are being generated
3099 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3100testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003101 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003102 var PagingTestCfg cfg := {
3103 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003104 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003105 load_factor := 0.8,
3106 exp_load_ind := true,
3107 exp_overload := false,
3108 use_tmsi := true
3109 };
3110 var PagingTestState st := f_TC_paging(cfg);
3111 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003112 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3113 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003114 } else {
3115 setverdict(pass);
3116 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003117 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003118}
3119
3120/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
3121 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3122 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3123 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3124testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003125 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003126 var PagingTestCfg cfg := {
3127 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003128 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003129 load_factor := 2.0,
3130 exp_load_ind := true,
3131 exp_overload := true,
3132 use_tmsi := false
3133 };
3134 var PagingTestState st := f_TC_paging(cfg);
3135 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3136 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003137 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003138 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003139 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 +01003140 } else {
3141 setverdict(pass);
3142 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003143 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003144}
3145
3146/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
3147 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3148 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3149 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3150testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003151 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003152 var PagingTestCfg cfg := {
3153 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003154 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003155 load_factor := 2.0,
3156 exp_load_ind := true,
3157 exp_overload := true,
3158 use_tmsi := true
3159 };
3160 var PagingTestState st := f_TC_paging(cfg);
3161 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
3162 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003163 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003164 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003165 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 +01003166 } else {
3167 setverdict(pass);
3168 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003169 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003170}
3171
3172
Harald Welte93640c62018-02-25 16:59:33 +01003173/***********************************************************************
3174 * Immediate Assignment / AGCH
3175 ***********************************************************************/
Vadim Yanitskiya9eeb7b2020-05-27 01:42:49 +07003176private const MobileAllocation c_MA_null := {
Harald Weltee8d750e2018-06-10 21:41:35 +02003177 len := 0,
3178 ma := ''B
3179}
Harald Welte93640c62018-02-25 16:59:33 +01003180
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003181template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
Vadim Yanitskiye9f68be2020-05-27 02:08:35 +07003182 uint12_t arfcn := mp_trx0_arfcn) := {
Harald Weltee8d750e2018-06-10 21:41:35 +02003183 chan_nr := chan_nr,
3184 tsc := tsc,
3185 h := false,
3186 arfcn := arfcn,
3187 maio_hsn := omit
3188}
3189
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003190template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
3191 template (value) MaioHsn maio_hsn) := {
3192 chan_nr := chan_nr,
3193 tsc := tsc,
3194 h := true,
3195 arfcn := omit,
3196 maio_hsn := maio_hsn
3197}
3198
Harald Weltee8d750e2018-06-10 21:41:35 +02003199private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
3200 return int2str(num_tx) & " sent, "
3201 & int2str(num_rx) & " received, "
3202 & int2str(num_del) & " deleted";
3203}
3204
3205private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
3206 var L1ctlDlMessage l1_dl;
3207 timer T := 10.0;
3208 var integer num_tx := 0;
3209 var integer num_rx := 0;
3210 var integer num_del := 0;
3211 var charstring res_str;
3212 var float rx_ratio;
3213
Harald Welte10474062019-05-30 16:48:17 +02003214 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02003215 f_init_l1ctl();
3216 f_l1_tune(L1CTL);
3217
3218 for (var integer i := 0; i < num_total; i := i+1) {
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003219 var ChannelDescription ch_desc := valueof(ts_ChanDescH0(valueof(t_RslChanNr_SDCCH4(0, 0))));
Harald Weltee8d750e2018-06-10 21:41:35 +02003220 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
3221 var octetstring ia_enc := enc_GsmRrMessage(ia);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003222 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02003223 num_tx := num_tx+1;
3224 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01003225 }
3226 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02003227 T.start;
3228 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003229 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
Harald Weltee8d750e2018-06-10 21:41:35 +02003230 num_del := num_del+1;
3231 repeat;
3232 }
3233 [] RSL_CCHAN.receive {
3234 repeat;
3235 }
3236 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
3237 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3238 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
3239 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
3240 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003241 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02003242 } else {
3243 num_rx := num_rx+1;
3244 }
3245 repeat;
3246 }
3247 [] L1CTL.receive { repeat; }
3248 [] T.timeout { }
3249 }
3250 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
3251 log("AGCH test: " & res_str);
3252 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003253 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02003254 }
3255 rx_ratio := int2float(num_rx) / int2float(num_tx);
3256 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003257 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 +02003258 } else {
3259 setverdict(pass);
3260 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003261 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003262}
3263
Harald Weltee8d750e2018-06-10 21:41:35 +02003264/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
3265testcase TC_imm_ass_1000_20ms() runs on test_CT {
3266 f_TC_imm_ass(1000, 0.02, 0.25);
3267}
3268
3269/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
3270testcase TC_imm_ass_200_0ms() runs on test_CT {
3271 f_TC_imm_ass(200, 0.0, 0.05);
3272}
3273
3274/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
3275testcase TC_imm_ass_200_76ms() runs on test_CT {
3276 f_TC_imm_ass(150, 0.076, 1.00);
3277}
3278
3279
3280
Harald Welte48494ca2018-02-25 16:59:50 +01003281/***********************************************************************
3282 * BCCH
3283 ***********************************************************************/
3284
3285/* tuple of Frame Number + decoded SI */
3286type record SystemInformationFn {
3287 GsmFrameNumber frame_number,
3288 SystemInformation si
3289}
3290
3291/* an arbitrary-length vector of decoded SI + gsmtap header */
3292type record of SystemInformationFn SystemInformationVector;
3293
3294/* an array of SI-vectors indexed by TC value */
3295type SystemInformationVector SystemInformationVectorPerTc[8];
3296
3297/* determine if a given SI vector contains given SI type at least once */
3298function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3299 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3300 var integer fn_mod51 := arr[i].frame_number mod 51;
3301 if (not bcch_ext and fn_mod51 == 2 or
3302 bcch_ext and fn_mod51 == 6) {
3303 if (arr[i].si.header.message_type == key) {
3304 return true;
3305 }
3306 }
3307 }
3308 return false;
3309}
3310
3311/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
3312function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3313 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003314 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003315 }
3316}
3317
3318/* check if a given SI vector contains given SI type at least once on any TC */
3319function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
3320 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
3321 if (f_si_vecslot_contains(arr[tc], key) or
3322 f_si_vecslot_contains(arr[tc], key, true)) {
3323 return true;
3324 }
3325 }
3326 return false;
3327}
3328
3329/* determine if a given SI vector contains given SI type at least N of M times */
3330function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
3331 var integer count := 0;
3332 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003333 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01003334 }
3335 for (var integer i:= 0; i < m; i := i + 1) {
3336 var integer fn_mod51 := arr[i].frame_number mod 51;
3337 if (not bcch_ext and fn_mod51 == 2 or
3338 bcch_ext and fn_mod51 == 6) {
3339 if (arr[i].si.header.message_type == key) {
3340 count := count + 1;
3341 }
3342 }
3343 }
3344 if (count >= n) {
3345 return true;
3346 } else {
3347 return false;
3348 }
3349}
3350
3351/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
3352function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
3353 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003354 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003355 }
3356}
3357
3358/* determine if a given SI vector contains given SI type at least once */
3359function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3360 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3361 var integer fn_mod51 := arr[i].frame_number mod 51;
3362 if (not bcch_ext and fn_mod51 == 2 or
3363 bcch_ext and fn_mod51 == 6) {
3364 if (arr[i].si.header.message_type != key) {
3365 return false;
3366 }
3367 }
3368 }
3369 return true;
3370}
3371
3372/* ensure a given TC slot of the SI vector contains only given SI type */
3373function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3374 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003375 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003376 }
3377}
3378
3379/* SI configuration of cell, against which we validate actual SI messages */
3380type set SystemInformationConfig {
3381 boolean bcch_extended,
3382 boolean si1_present,
3383 boolean si2bis_present,
3384 boolean si2ter_present,
3385 boolean si2quater_present,
3386 boolean si7_present,
3387 boolean si8_present,
3388 boolean si9_present,
3389 boolean si13_present,
3390 boolean si13alt_present,
3391 boolean si15_present,
3392 boolean si16_present,
3393 boolean si17_present,
3394 boolean si2n_present,
3395 boolean si21_present,
3396 boolean si22_present
3397}
3398
3399/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
3400function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
3401 var integer i;
3402 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
3403 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003404 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01003405 }
3406 }
3407 if (cfg.si1_present) {
3408 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
3409 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
3410 * when TC = 0, it can assume that System Information Type 1 is not in use. */
3411 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3412 /* make sure *ALL* contain SI1 */
3413 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3414 }
3415 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
3416 /* iii) A SI 2 message will be sent at least every time TC = 1 */
3417 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
3418 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
3419 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
3420 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
3421
3422 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
3423 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
3424 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
3425 * consecutive occurrences of TC = 4. */
3426 if (cfg.si2bis_present and not cfg.si2ter_present) {
3427 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3428 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
3429 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
3430 } else if (cfg.si2ter_present and cfg.si2bis_present) {
3431 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3432 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
3433 }
3434
3435 if (cfg.si7_present or cfg.si8_present) {
3436 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
3437 * if System Information type 4 does not contain all information needed for cell
3438 * selection and reselection. */
3439 if (not cfg.bcch_extended) {
3440 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
3441 }
3442 if (cfg.si7_present) {
3443 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
3444 }
3445 if (cfg.si8_present) {
3446 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
3447 }
3448 }
3449
3450 if (cfg.si2quater_present) {
3451 /* iii) System information type 2 quater is sent if needed, as determined by the system
3452 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
3453 * and 2ter are used, otherwise it shall be sent at least once within any of 4
3454 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
3455 * within any of 4 consecutive occurrences of TC = 5. */
3456 if (not (cfg.bcch_extended)) {
3457 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
3458 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
3459 } else {
3460 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
3461 }
3462 } else {
3463 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
3464 }
3465 }
3466 if (cfg.si9_present) {
3467 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
3468 * in system information type 3 as defined in 3GPP TS 44.018. */
3469 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
3470 }
3471 if (cfg.si13_present) {
3472 /* vii) System Information type 13 is only related to the GPRS service. System Information
3473 * Type 13 need only be sent if GPRS support is indicated in one or more of System
3474 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
3475 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
3476 * In the case that the message is sent on the BCCH Norm, it is sent at least once
3477 * within any of 4 consecutive occurrences of TC=4. */
3478 if (not cfg.bcch_extended) {
3479 log("not-bccch-extended");
3480 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
3481 } else {
3482 log("bccch-extended");
3483 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
3484 }
3485 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003486 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003487 }
3488 }
3489 if (cfg.si16_present or cfg.si17_present) {
3490 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
3491 * should not be sent in a cell where network sharing is used (see rule xv). */
3492 if (cfg.si22_present) {
3493 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3494 }
3495 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003496 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003497 }
3498 if (not cfg.bcch_extended) {
3499 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
3500 }
3501 if (cfg.si16_present) {
3502 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
3503 }
3504 if (cfg.si17_present) {
3505 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
3506 }
3507 }
3508
3509 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
3510 * broadcast information. The frequency with which they are sent is determined by the
3511 * system operator. System Information type 9 identifies the scheduling of System
3512 * Information type 18 and 20 messages. */
3513
3514 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
3515 * Information Type 19 is present, then its scheduling shall be indicated in System
3516 * Information Type 9. */
3517
3518 if (cfg.si15_present) {
3519 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
3520 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
3521 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
3522 * 4 consecutive occurrences of TC = 1. */
3523 if (not cfg.bcch_extended) {
3524 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
3525 } else {
3526 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
3527 }
3528 }
3529 if (cfg.si13alt_present) {
3530 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
3531 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
3532 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
3533 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
3534 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
3535 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
3536 * of TC = 4. */
3537 if (cfg.si13_present) {
3538 testcase.stop("Error: Cannot have SI13alt and SI13");
3539 }
3540 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003541 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003542 }
3543 if (not cfg.bcch_extended) {
3544 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
3545 } else {
3546 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
3547 }
3548 }
3549 if (cfg.si2n_present) {
3550 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
3551 * as determined by the system operator. In the case that the message is sent on the
3552 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
3553 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
3554 * consecutive occurrences of TC = 4. */
3555 if (not cfg.bcch_extended) {
3556 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
3557 } else {
3558 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
3559 }
3560 }
3561 if (cfg.si21_present) {
3562 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
3563 * determined by the system operator. If Extended Access Barring is in use in the cell
3564 * then this message is sent at least once within any of 4 consecutive occurrences of
3565 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
3566 * cell then this message shall only be sent on BCCH Ext. */
3567 if (not cfg.bcch_extended) {
3568 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
3569 } else {
3570 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
3571 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003572 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01003573 }
3574 }
3575 }
3576 if (cfg.si22_present) {
3577 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
3578 * should not be sent in a cell where SoLSA is used (see rule viii). System
3579 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
3580 * =2 and TC=6. */
3581 if (cfg.si16_present or cfg.si17_present) {
3582 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3583 }
3584 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
3585 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003586 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003587 }
3588 if (not cfg.bcch_extended) {
3589 testcase.stop("Error: SI22 requires BCCH Extd!");
3590 } else {
3591 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
3592 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
3593 }
3594 }
3595}
3596
3597/* sample Systme Information for specified duration via L1CTL */
3598function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
3599 timer T := duration;
3600 var SystemInformationVectorPerTc si_per_tc;
3601 var L1ctlDlMessage l1_dl;
3602
3603 /* initialize all per-TC vectors empty */
3604 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3605 si_per_tc[i] := {};
3606 }
3607
3608 /* flush all previous L1 queued msgs */
3609 pt.clear;
3610
3611 T.start;
3612 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003613 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01003614 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3615 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
3616 log("Ignoring non-RR SI ", l1_dl);
3617 repeat;
3618 }
3619 var SystemInformationFn sig := {
3620 frame_number := l1_dl.dl_info.frame_nr,
3621 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
3622 }
3623 var integer tc := f_gsm_compute_tc(sig.frame_number);
3624 log("SI received at TC=", tc, ": ", sig.si);
3625 /* append to the per-TC bucket */
3626 si_per_tc[tc] := si_per_tc[tc] & { sig };
3627 repeat;
3628 }
3629 [] pt.receive { repeat; }
3630 [] T.timeout { }
3631 }
3632
3633 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3634 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
3635 }
3636 log("si_per_tc=", si_per_tc);
3637 return si_per_tc;
3638}
3639
3640/* helper function: Set given SI via RSL + validate scheduling.
3641 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
3642function f_TC_si_sched() runs on test_CT {
3643 var SystemInformationVectorPerTc si_per_tc;
3644 f_init_l1ctl();
3645 f_l1_tune(L1CTL);
3646
3647 /* Sample + Validate Scheduling */
3648 si_per_tc := f_l1_sample_si(L1CTL);
3649 f_validate_si_scheduling(si_cfg, si_per_tc);
3650
3651 setverdict(pass);
3652}
3653
3654testcase TC_si_sched_default() runs on test_CT {
3655 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01003656 /* 2+3+4 are mandatory and set in f_init() */
3657 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003658 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01003659}
3660
3661testcase TC_si_sched_1() runs on test_CT {
3662 f_init();
3663 si_cfg.si1_present := true;
3664 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003665 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003666 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003667}
3668
3669testcase TC_si_sched_2bis() runs on test_CT {
3670 f_init();
3671 si_cfg.si2bis_present := true;
3672 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3673 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003674 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003675}
3676
3677testcase TC_si_sched_2ter() runs on test_CT {
3678 f_init();
3679 si_cfg.si2ter_present := true;
3680 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3681 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003682 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003683}
3684
3685testcase TC_si_sched_2ter_2bis() runs on test_CT {
3686 f_init();
3687 si_cfg.si2bis_present := true;
3688 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3689 si_cfg.si2ter_present := true;
3690 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3691 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003692 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003693}
3694
3695testcase TC_si_sched_2quater() runs on test_CT {
3696 f_init();
3697 si_cfg.si2quater_present := true;
3698 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3699 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003700 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003701}
3702
3703testcase TC_si_sched_13() runs on test_CT {
3704 f_init();
3705 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003706 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003707 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003708 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003709}
3710
3711testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
3712 f_init();
3713 si_cfg.si2bis_present := true;
3714 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3715 si_cfg.si2ter_present := true;
3716 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3717 si_cfg.si2quater_present := true;
3718 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3719 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003720 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003721 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003722 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003723}
3724
3725
Harald Welte68e495b2018-02-25 00:05:57 +01003726testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003727 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01003728 /* FIXME: enable / disable individual BCCH info */
3729 //ts_RSL_BCCH_INFO(si_type, info);
3730 /* expect no ERROR REPORT after either of them *
3731 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003732 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003733}
3734
Harald Welte93640c62018-02-25 16:59:33 +01003735/***********************************************************************
3736 * Low-Level Protocol Errors / ERROR REPORT
3737 ***********************************************************************/
3738
Harald Welte01d982c2018-02-25 01:31:40 +01003739private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
3740 timer T := 5.0;
3741 T.start;
3742 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003743 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
Harald Welte01d982c2018-02-25 01:31:40 +01003744 setverdict(pass);
3745 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003746 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003747 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003748 }
3749 [] RSL_CCHAN.receive {
3750 repeat;
3751 }
3752 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003753 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003754 }
3755 }
3756}
3757
3758/* Provoke a protocol error (message too short) and match on ERROR REPORT */
3759testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003760 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003761 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3762 rsl.ies := omit;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003763 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003764
3765 f_exp_err_rep(RSL_ERR_PROTO);
3766}
3767
3768/* Provoke a mandatory IE error and match on ERROR REPORT */
3769testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003770 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003771
3772 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3773 rsl.ies := { rsl.ies[0] };
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003774 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003775
3776 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
3777}
3778
3779/* Provoke an IE content error and match on ERROR REPORT */
3780testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003781 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003782 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3783 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003784 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003785
3786 f_exp_err_rep(RSL_ERR_IE_CONTENT);
3787}
3788
Harald Welteee25aae2019-05-19 14:32:37 +02003789/* attempt to activate channel with wrong RSL Message Discriminator IE */
3790function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
3791 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3792 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
3793 RSL.send(rsl);
3794 f_rslem_unregister(0, g_chan_nr);
3795}
3796testcase TC_err_rep_wrong_mdisc() runs on test_CT {
3797 var ConnHdlr vc_conn;
3798 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3799
Harald Welte10474062019-05-30 16:48:17 +02003800 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003801
3802 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
3803 vc_conn.done;
3804 f_exp_err_rep(RSL_ERR_MSG_DISCR);
3805
3806 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3807}
3808
3809/* Send messages with wrong message type */
3810function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
3811 var template (value) RSL_Message rsl_tx;
3812 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3813 rsl_tx.msg_type := RSL_MT_NOT_CMD;
3814 RSL.send(rsl_tx);
3815 f_rslem_unregister(0, g_chan_nr);
3816}
3817function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
3818 var template (value) RSL_Message rsl_tx;
3819 /* we first have to activate the dedicated channel */
3820 f_rsl_chan_act(g_pars.chan_mode);
3821 /* ... to then send an invalid RLL message */
3822 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
3823 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
3824 RSL.send(rsl_tx);
3825 f_rslem_unregister(0, g_chan_nr);
3826}
3827testcase TC_err_rep_wrong_msg_type() runs on test_CT {
3828 var ConnHdlr vc_conn;
3829 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3830 var template (value) RSL_Message rsl_tx;
3831
Harald Welte10474062019-05-30 16:48:17 +02003832 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003833
3834 /* Common Channel with wrong message type */
3835 RSL_CCHAN.clear;
3836 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3837 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003838 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02003839 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3840
3841 /* TRX Management */
3842 RSL_CCHAN.clear;
3843 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
3844 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003845 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02003846 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3847
3848 /* Dedicated Channel */
3849 RSL_CCHAN.clear;
3850 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3851 vc_conn.done;
3852 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3853
3854 /* RLL */
3855 RSL_CCHAN.clear;
3856 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3857 vc_conn.done;
3858 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3859}
3860
3861/* Send messages in wrong sequence (RLL to an inactive lchan) */
3862function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3863 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3864 f_rslem_unregister(0, g_chan_nr);
3865}
3866testcase TC_err_rep_wrong_sequence() runs on test_CT {
3867 var ConnHdlr vc_conn;
3868 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3869
Harald Welte10474062019-05-30 16:48:17 +02003870 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003871
3872 RSL_CCHAN.clear;
3873 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3874 vc_conn.done;
3875 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3876}
3877
Harald Welte93640c62018-02-25 16:59:33 +01003878/***********************************************************************
3879 * IPA CRCX/MDCX/DLCS media stream handling
3880 ***********************************************************************/
3881
Harald Weltea871a382018-02-25 02:03:14 +01003882/* Send IPA DLCX to inactive lchan */
3883function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003884 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3885 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003886}
3887testcase TC_ipa_dlcx_not_active() runs on test_CT {
3888 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003889 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01003890 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3891 vc_conn.done;
3892}
Harald Welte68e495b2018-02-25 00:05:57 +01003893
Harald Weltea3f1df92018-02-25 12:49:55 +01003894/* Send IPA CRCX twice to inactive lchan */
3895function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3896 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3897 "IPA CRCX ACK");
3898 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3899 "IPA CRCX NACK");
3900}
3901testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3902 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003903 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003904 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3905 vc_conn.done;
3906}
3907
3908/* Regular sequence of CRCX/MDCX/DLCX */
3909function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3910 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3911 "IPA CRCX ACK");
3912 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3913 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3914 var uint7_t rtp_pt2 := f_rnd_int(127);
3915 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3916 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3917 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3918 "IPA MDCX ACK");
3919 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3920 "IPA DLCX ACK");
3921}
3922testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3923 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003924 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003925 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3926 vc_conn.done;
3927}
3928
Harald Welte3ae11da2018-02-25 13:36:06 +01003929/* Sequence of CRCX, 2x MDCX, DLCX */
3930function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3931 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3932 "IPA CRCX ACK");
3933 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3934 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3935 var uint7_t rtp_pt2 := f_rnd_int(127);
3936 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3937 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3938 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3939 "IPA MDCX ACK");
3940 /* Second MDCX */
3941 remote_ip := f_rnd_int(c_UINT32_MAX);
3942 remote_port := f_rnd_int(c_UINT16_MAX);
3943 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3944 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3945 "IPA MDCX ACK");
3946 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3947 "IPA DLCX ACK");
3948}
3949testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3950 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003951 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01003952 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3953 vc_conn.done;
3954}
3955
Harald Welte9912eb52018-02-25 13:30:15 +01003956/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3957function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3958 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3959 "IPA CRCX NACK");
3960}
3961testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3962 var ConnHdlrPars pars;
3963 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02003964 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01003965
3966 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3967 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3968 vc_conn.done;
3969
3970 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3971 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3972 vc_conn.done;
3973}
3974
Harald Weltea3f1df92018-02-25 12:49:55 +01003975
Harald Welte883340c2018-02-28 18:59:29 +01003976/***********************************************************************
3977 * PCU Socket related tests
3978 ***********************************************************************/
3979
Harald Welte07bd2d22019-05-25 11:03:30 +02003980/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003981friend 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 +01003982runs on test_CT {
3983 timer T := 3.0;
3984
3985 /* we don't expect any RTS.req before PDCH are active */
3986 T.start;
3987 alt {
3988 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003989 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003990 }
3991 [] PCU.receive { repeat; }
3992 [] T.timeout { }
3993 }
3994
3995 /* Send PDCH activate request for known PDCH timeslot */
3996 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3997
3998 /* we now expect RTS.req for this timeslot (only) */
3999 T.start;
4000 alt {
4001 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
4002 setverdict(pass);
4003 }
4004 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4005 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004006 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01004007 }
4008 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004009 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01004010 }
4011 [] PCU.receive { repeat; }
4012 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004013 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004014 }
4015 [not exp_success] T.timeout {
4016 setverdict(pass);
4017 }
4018 }
4019}
4020
Harald Welte07bd2d22019-05-25 11:03:30 +02004021/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004022friend 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 +01004023runs on test_CT {
4024 timer T := 3.0;
4025
4026 /* Send PDCH activate request for known PDCH timeslot */
4027 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
4028
4029 PCU.clear;
4030 /* we now expect no RTS.req for this timeslot */
4031 T.start;
4032 alt {
4033 [] 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 +02004034 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004035 }
4036 [] PCU.receive { repeat; }
4037 [] T.timeout {
4038 setverdict(pass);
4039 }
4040 }
4041}
4042
Harald Weltead033dc2019-05-25 17:28:16 +02004043friend function f_init_pcu_test() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004044 f_init();
4045 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
4046}
4047
Harald Welte883340c2018-02-28 18:59:29 +01004048/* PDCH activation via PCU socket; check for presence of RTS.req */
4049testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004050 f_init_pcu_test();
4051
Harald Welte883340c2018-02-28 18:59:29 +01004052 f_TC_pcu_act_req(0, 0, 7, true);
4053}
4054
4055/* PDCH activation via PCU socket on non-PDCU timeslot */
4056testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004057 f_init_pcu_test();
4058
Harald Welte883340c2018-02-28 18:59:29 +01004059 f_TC_pcu_act_req(0, 0, 1, false);
4060}
4061
4062/* PDCH activation via PCU socket on wrong BTS */
4063testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004064 f_init_pcu_test();
4065
Harald Welte883340c2018-02-28 18:59:29 +01004066 f_TC_pcu_act_req(23, 0, 7, false);
4067}
4068
4069/* PDCH activation via PCU socket on wrong TRX */
4070testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004071 f_init_pcu_test();
4072
Harald Welte883340c2018-02-28 18:59:29 +01004073 f_TC_pcu_act_req(0, 23, 7, false);
4074}
4075
4076/* PDCH deactivation via PCU socket; check for absence of RTS.req */
4077testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004078 f_init_pcu_test();
4079
Harald Welte883340c2018-02-28 18:59:29 +01004080 /* Activate PDCH */
4081 f_TC_pcu_act_req(0, 0, 7, true);
4082 f_sleep(1.0);
4083 /* and De-Activate again */
4084 f_TC_pcu_deact_req(0, 0, 7);
4085}
4086
4087/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
4088testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004089 f_init_pcu_test();
4090
Harald Welte883340c2018-02-28 18:59:29 +01004091 f_TC_pcu_deact_req(0, 0, 1);
4092}
4093
4094/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
4095testcase TC_pcu_ver_si13() runs on test_CT {
4096 const octetstring si13 := '00010203040506070909'O;
4097 var PCUIF_send_data sd;
4098 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01004099 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004100
4101 /* Set SI13 via RSL */
4102 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01004103
Harald Welte883340c2018-02-28 18:59:29 +01004104 T.start;
4105 alt {
4106 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
4107 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
4108 setverdict(pass);
4109 } else {
4110 repeat;
4111 }
4112 }
4113 [] PCU.receive { repeat; }
4114 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004115 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01004116 }
4117 }
4118}
4119
4120private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
4121
4122/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02004123friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01004124 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
4125runs on test_CT
4126{
4127 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
4128 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
4129}
4130
4131/* 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 +02004132friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
4133 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01004134runs on test_CT
4135{
4136 var PCUIF_send_data sd;
4137
4138 timer T := 3.0;
4139 T.start;
4140 alt {
4141 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4142 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
4143 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
4144 sd.data.u.rts_req.fn, sapi, data);
4145 }
4146 [] PCU.receive { repeat; }
4147 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004148 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01004149 }
4150 }
4151}
4152
4153/* Send DATA.req on invalid BTS */
4154testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004155 var TfiUsfArr tua := f_TfiUsfArrInit();
4156 var octetstring data := '0000'O & f_rnd_octstring(21);
4157
4158 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004159
Harald Welte883340c2018-02-28 18:59:29 +01004160 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004161 f_TfiUsfArrSet(tua, 7, 0);
4162 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4163 f_sleep(1.0);
4164
4165 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004166}
4167
4168/* Send DATA.req on invalid TRX */
4169testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004170 var TfiUsfArr tua := f_TfiUsfArrInit();
4171 var octetstring data := '0000'O & f_rnd_octstring(21);
4172
4173 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004174
Harald Welte883340c2018-02-28 18:59:29 +01004175 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004176 f_TfiUsfArrSet(tua, 7, 0);
4177 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4178 f_sleep(1.0);
4179
4180 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004181}
4182
4183/* Send DATA.req on invalid timeslot */
4184testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004185 var TfiUsfArr tua := f_TfiUsfArrInit();
4186 var octetstring data := '0000'O & f_rnd_octstring(21);
4187
4188 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004189
Harald Welte883340c2018-02-28 18:59:29 +01004190 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004191 f_TfiUsfArrSet(tua, 7, 0);
4192 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4193 f_sleep(1.0);
4194
4195 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004196}
4197
4198/* Send DATA.req on timeslot that hasn't been activated */
4199testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004200 var TfiUsfArr tua := f_TfiUsfArrInit();
4201 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01004202
Harald Welte7162a612019-05-26 12:56:09 +02004203 f_virtphy_common();
4204
4205 f_TfiUsfArrSet(tua, 7, 0);
4206 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4207 f_sleep(1.0);
4208
4209 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004210}
4211
Harald Weltead033dc2019-05-25 17:28:16 +02004212private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02004213 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
4214 boolean wait_rts := true)
4215runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004216 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02004217 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02004218
4219 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02004220 if (wait_rts) {
4221 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
4222 } else {
4223 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
4224 }
Harald Weltead033dc2019-05-25 17:28:16 +02004225
4226 T.start;
4227 alt {
Harald Welte7162a612019-05-26 12:56:09 +02004228 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02004229 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
4230 setverdict(pass);
4231 }
Harald Welte7162a612019-05-26 12:56:09 +02004232 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
4233 setverdict(fail, "Received unexpected ", rx_dl);
4234 }
Harald Weltead033dc2019-05-25 17:28:16 +02004235 [] L1CTL.receive {
4236 repeat;
4237 }
Harald Welte7162a612019-05-26 12:56:09 +02004238 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02004239 setverdict(fail, "Timeout waiting for ", data);
4240 }
Harald Welte7162a612019-05-26 12:56:09 +02004241 [not expect_data] T.timeout {
4242 setverdict(pass);
4243 }
Harald Weltead033dc2019-05-25 17:28:16 +02004244 }
4245}
4246
4247private function f_disable_dynamic_ts() runs on test_CT
4248{
4249 f_init_vty_bsc();
4250 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
4251 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
4252 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
4253 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Max2c6f5632019-03-18 17:25:17 +01004254 f_init_pcu_test();
Harald Weltead033dc2019-05-25 17:28:16 +02004255}
4256
4257private function f_virtphy_common() runs on test_CT {
4258 f_disable_dynamic_ts();
4259 f_init_l1ctl();
4260 f_l1_tune(L1CTL);
4261}
4262
4263testcase TC_pcu_data_req_pdtch() runs on test_CT {
4264 var TfiUsfArr tua := f_TfiUsfArrInit();
4265 var octetstring data := '0000'O & f_rnd_octstring(21);
4266
4267 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004268
Harald Welte883340c2018-02-28 18:59:29 +01004269 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004270 f_TfiUsfArrSet(tua, 7, 0);
4271 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4272 f_sleep(1.0);
4273
4274 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01004275}
4276
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004277/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01004278testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004279 var TfiUsfArr tua := f_TfiUsfArrInit();
4280 var octetstring data := '0000'O & f_rnd_octstring(21);
4281
4282 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004283
Harald Welte883340c2018-02-28 18:59:29 +01004284 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004285 f_TfiUsfArrSet(tua, 7, 0);
4286 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4287 f_sleep(1.0);
4288
4289 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01004290}
4291
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004292private function f_TC_pcu_ptcch_ul(uint16_t ra)
4293runs on test_CT {
4294 var template PCUIF_Message pcu_rach_ind;
4295 var PCUIF_send_data sd;
4296 var GsmFrameNumber fn;
4297 timer T;
4298
4299 /* Send an Access Burst on PTCCH/U over the Um-interface */
4300 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
4301 chan_nr := ts_RslChanNr_PDCH(7),
4302 link_id := ts_RslLinkID_OSMO_PTCCH(0));
4303
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004304 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
4305 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004306
4307 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
4308 T.start(52.0 * 4.615 / 1000.0);
4309 alt {
4310 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
4311 log("Rx an Access Burst on the PCU interface: ", sd.data);
4312 setverdict(pass);
4313 T.stop;
4314 }
4315 [] PCU.receive { repeat; }
4316 [] T.timeout {
4317 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
4318 /* Keep going, that's not the end of the world */
4319 }
4320 }
4321}
4322
4323testcase TC_pcu_ptcch() runs on test_CT {
4324 var L1ctlDlMessage dl;
4325 var octetstring data;
4326 timer T;
4327
4328 f_init_pcu_test();
4329 f_init_l1ctl();
4330 f_l1_tune(L1CTL);
4331
4332 /* Activate PDCH channel on TS7 */
4333 f_TC_pcu_act_req(0, 0, 7, true);
4334
4335 /* Tune trxcon to that PDCH channel */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07004336 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004337
4338 /* Verify PTCCH/U: send several access bursts, make sure they're received */
4339 for (var integer i := 0; i < 16; i := i + 1) {
4340 log("Sending an Access Burst towards the L1CTL interface");
4341 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
4342 }
4343
4344 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
4345 data := f_rnd_octstring(23);
4346
4347 /* Verify PTCCH/D: send a random data block, make sure it's received */
4348 log("Sending a PTCCH/D block towards the PCU interface: ", data);
4349 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
4350
4351 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
4352 * let's give it more time in case if we miss the beginning. */
4353 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
4354 alt {
4355 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
4356 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
4357 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4358 frame := data)) -> value dl {
4359 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
4360 setverdict(pass);
4361 T.stop;
4362 }
4363 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
4364 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
4365 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4366 l2_data := data)) -> value dl {
4367 log("Rx PTCCH/D data block on L1CTL: ", dl);
4368 setverdict(pass);
4369 T.stop;
4370 }
4371 [] L1CTL.receive { repeat; }
4372 [] T.timeout {
4373 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
4374 }
4375 }
4376}
4377
Harald Welte883340c2018-02-28 18:59:29 +01004378/* Send AGCH from PCU; check it appears on Um side */
4379testcase TC_pcu_data_req_agch() runs on test_CT {
4380 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01004381 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004382 f_init_l1ctl();
4383 f_l1_tune(L1CTL);
4384
4385 f_TC_pcu_act_req(0, 0, 7, true);
4386 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
4387
4388 T.start;
4389 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004390 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01004391 setverdict(pass);
4392 }
4393 [] L1CTL.receive { repeat; }
4394 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004395 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004396 }
4397 }
4398}
4399
Harald Welte928622b2019-05-26 13:22:59 +02004400/* Send AGCH from PCU; check it appears on Um side */
4401testcase TC_pcu_data_req_pch() runs on test_CT {
4402 timer T := 3.0;
4403 f_init_pcu_test();
4404 f_init_l1ctl();
4405 f_l1_tune(L1CTL);
4406
4407 f_TC_pcu_act_req(0, 0, 7, true);
4408 /* three characters prefix: last 3 digits of IMSI as ASCII */
4409 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
4410
4411 T.start;
4412 alt {
4413 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
4414 setverdict(pass);
4415 }
4416 [] L1CTL.receive { repeat; }
4417 [] T.timeout {
4418 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
4419 }
4420 }
4421}
4422
Harald Welte883340c2018-02-28 18:59:29 +01004423/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
4424testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
4425 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01004426 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004427 f_init_l1ctl();
4428 f_l1_tune(L1CTL);
4429
4430 /* append 3 last imsi digits so BTS can compute pagng group */
4431 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
4432
4433 timer T := 0.5;
4434 T.start;
4435 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004436 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01004437 /* TODO: verify paging group */
4438 setverdict(pass);
4439 }
4440 [] L1CTL.receive { repeat; }
4441 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004442 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004443 }
4444 }
4445}
4446
4447/* Send RACH from Um side, expect it to show up on PCU socket */
4448testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004449 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004450 f_init_l1ctl();
4451 f_l1_tune(L1CTL);
4452
4453 var GsmFrameNumber fn_last := 0;
4454 for (var integer i := 0; i < 1000; i := i+1) {
4455 var OCT1 ra := f_rnd_ra_ps();
4456 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
4457 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004458 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01004459 }
4460 fn_last := fn;
4461
4462 timer T := 2.0;
4463 T.start;
4464 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004465 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn))) {
Harald Welte883340c2018-02-28 18:59:29 +01004466 T.stop;
4467 }
4468 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004469 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004470 }
4471 [] PCU.receive { repeat; }
4472 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004473 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004474 }
4475 }
4476 }
4477 setverdict(pass);
4478}
4479
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004480/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
4481 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
4482testcase TC_pcu_ext_rach_content() runs on test_CT {
4483 var template PCUIF_Message pcu_rach_ind;
4484 var GsmFrameNumber fn_last := 0;
4485 var L1ctlRachSynchSeq synch_seq;
4486 var PCUIF_BurstType pcu_bt;
4487 var GsmFrameNumber fn;
4488 var BIT11 ra11;
4489
4490 f_init_pcu_test();
4491 f_init_l1ctl();
4492 f_l1_tune(L1CTL);
4493
4494 for (var integer i := 0; i < 1000; i := i+1) {
4495 /* We need to test both TS1 & TS2 */
4496 if (i rem 2 == 0) {
4497 synch_seq := RACH_SYNCH_SEQ_TS1;
4498 pcu_bt := BURST_TYPE_1;
4499 } else {
4500 synch_seq := RACH_SYNCH_SEQ_TS2;
4501 pcu_bt := BURST_TYPE_2;
4502 }
4503
4504 ra11 := f_rnd_ra11_ps();
4505 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
4506 if (fn == fn_last) {
4507 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4508 "Two RACH in same FN?!?");
4509 }
4510 fn_last := fn;
4511
4512 /* Compose the expected message */
4513 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004514 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004515 ra := bit2int(ra11),
4516 is_11bit := 1,
4517 burst_type := pcu_bt,
4518 fn := fn);
4519
4520 timer T := 2.0;
4521 T.start;
4522 alt {
4523 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
4524 T.stop;
4525 }
4526 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
4527 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
4528 }
4529 [] PCU.receive { repeat; }
4530 [] T.timeout {
4531 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
4532 }
4533 }
4534 }
4535 setverdict(pass);
4536}
4537
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004538private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
4539runs on test_CT {
4540 var template PCUIF_send_data sdt;
4541 var PCUIF_send_data sd;
4542 var int16_t lqual_cb;
4543 timer T := 1.0;
4544
4545 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
4546 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
4547
4548 /* Send a random PDTCH frame over Um */
4549 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
4550 '0000'O & f_rnd_octstring(21)));
4551
4552 T.start;
4553 alt {
4554 /* If expected link quality is above the threshold */
4555 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
4556 lqual_cb := sd.data.u.data_ind.lqual_cb;
4557 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
4558
4559 /* Make sure the actual link quality matches the expected value */
4560 if (not match(lqual_cb, lqual_cb_exp)) {
4561 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
4562 "expected value ", lqual_cb_exp));
4563 } else {
4564 setverdict(pass);
4565 }
4566 }
4567 /* If expected link quality is below the threshold */
4568 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
4569 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4570 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
4571 }
4572 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
4573 [] PCU.receive { repeat; }
4574 [lqual_cb_exp < thresh] T.timeout {
4575 log("Rx nothing, as expected");
4576 setverdict(pass);
4577 }
4578 [lqual_cb_exp >= thresh] T.timeout {
4579 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4580 "Timeout waiting for PCUIF_DATA.ind");
4581 }
4582 }
4583}
4584
4585/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
4586testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
4587 f_init_pcu_test();
4588 PCU.clear;
4589
4590 f_init_l1ctl();
4591 f_l1_tune(L1CTL);
4592
4593 /* Activate a PDCH channel on TS7 */
4594 f_TC_pcu_act_req(0, 0, 7, true);
4595
4596 /* Tune trxcon to that PDCH channel on TS7 */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07004597 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004598
4599 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
4600 for (var int16_t i := -256; i <= 1280; i := i + 128) {
4601 var TrxcMessage ret;
4602
4603 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
4604 valueof(ts_TRXC_FAKE_CI(i)));
4605
4606 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
4607 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
4608 }
4609}
4610
Harald Welte883340c2018-02-28 18:59:29 +01004611/* Send PAGING via RSL, expect it to shw up on PCU socket */
4612testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004613 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004614
4615 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004616 var MobileIdentityLV mi_lv;
4617 var octetstring mi_lv_enc;
4618 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01004619 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004620
Harald Welte883340c2018-02-28 18:59:29 +01004621 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004622 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01004623 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004624 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01004625 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004626
4627 /* Fancy encoding for PCUIF */
4628 mi_lv := valueof(ts_MI_LV(mi));
4629 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
4630 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01004631
4632 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004633 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01004634 T.start;
4635 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004636 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01004637 }
4638 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004639 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004640 }
4641 [] PCU.receive { repeat; }
4642 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004643 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004644 }
4645 }
4646 }
4647 setverdict(pass);
4648}
4649
Harald Welted66c9b82019-05-25 09:03:15 +02004650/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
4651testcase TC_pcu_time_ind() runs on test_CT {
4652 var PCUIF_send_data pcu_sd;
4653 var integer num_time_ind := 0;
4654 var integer first_fn, last_fn;
4655 var float test_duration := 5.0;
4656 timer T;
4657
4658 f_init_pcu_test();
4659 f_TC_pcu_act_req(0, 0, 7, true);
4660
4661 PCU.clear;
4662 T.start(test_duration);
4663 alt {
4664 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
4665 num_time_ind := num_time_ind + 1;
4666 if (not isbound(first_fn)) {
4667 first_fn := pcu_sd.data.u.time_ind.fn;
4668 }
4669 last_fn := pcu_sd.data.u.time_ind.fn;
4670 repeat;
4671 }
4672 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
4673 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
4674 repeat;
4675 }
4676 [] PCU.receive {
4677 repeat;
4678 }
4679 [] T.timeout {}
4680 }
4681 var integer fn_expired := last_fn - first_fn;
4682 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
4683
4684 /* verify the number of frames expired matches our expectation */
4685 const float c_GSM_FN_DURATION_MS := 4.61538;
4686 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004687 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02004688 if (not match(fn_expired, t_fn_expected)) {
4689 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4690 }
4691
4692 /* There are three TIME.ind in every fn MOD 13 */
4693 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
4694 /* Add some tolerance */
4695 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
4696 if (not match(num_time_ind, t_time_ind_exp)) {
4697 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
4698 }
4699
4700 setverdict(pass);
4701}
4702
Harald Welte4832c862019-05-25 14:57:18 +02004703/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
4704testcase TC_pcu_rts_req() runs on test_CT {
4705 var PCUIF_send_data pcu_sd;
4706 var integer first_fn, last_fn;
4707 var integer num_rts_pdtch := 0;
4708 var integer num_rts_ptcch := 0;
4709 var float test_duration := 5.0;
4710 timer T;
4711
4712 f_init_pcu_test();
4713 f_TC_pcu_act_req(0, 0, 7, true);
4714
4715 PCU.clear;
4716 T.start(test_duration);
4717 alt {
4718 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
4719 -> value pcu_sd {
4720 num_rts_pdtch := num_rts_pdtch + 1;
4721 if (not isbound(first_fn)) {
4722 first_fn := pcu_sd.data.u.rts_req.fn;
4723 }
4724 last_fn := pcu_sd.data.u.rts_req.fn;
4725 repeat;
4726 }
4727 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
4728 -> value pcu_sd {
4729 num_rts_ptcch := num_rts_ptcch + 1;
4730 if (not isbound(first_fn)) {
4731 first_fn := pcu_sd.data.u.rts_req.fn;
4732 }
4733 last_fn := pcu_sd.data.u.rts_req.fn;
4734 repeat;
4735 }
4736 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
4737 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
4738 repeat;
4739 }
4740 [] PCU.receive {
4741 repeat;
4742 }
4743 [] T.timeout {}
4744 }
4745 var integer fn_expired := last_fn - first_fn;
4746 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
4747 ", num_rts_ptcch=", num_rts_ptcch);
4748
4749 /* verify the number of frames expired matches our expectation */
4750 const float c_GSM_FN_DURATION_MS := 4.61538;
4751 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004752 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02004753 if (not match(fn_expired, t_fn_expected)) {
4754 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4755 }
4756
4757 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
4758 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
4759 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
4760 if (not match(num_rts_ptcch, t_ptcch_exp)) {
4761 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
4762 t_ptcch_exp);
4763 }
4764
4765 /* We have 12 PDTCH blocks every 52-multiframe */
4766 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
4767 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
4768 if (not match(num_rts_pdtch, t_pdtch_exp)) {
4769 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
4770 t_pdtch_exp);
4771 }
4772
4773 setverdict(pass);
4774}
4775
Harald Welte07bd2d22019-05-25 11:03:30 +02004776/* test for generating Abis side OML ALERT from the PCU */
4777testcase TC_pcu_oml_alert() runs on test_CT {
4778 var PCUIF_send_data pcu_sd;
4779 var integer num_time_ind := 0;
4780 var integer first_fn, last_fn;
4781 var float test_duration := 5.0;
4782 timer T;
4783
4784 f_init_pcu_test();
4785 f_TC_pcu_act_req(0, 0, 7, true);
4786
4787 /* re-connect CTRL port from BTS to BSC */
4788 f_ipa_ctrl_stop();
4789 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
4790
4791 /* Send that OML Alert */
4792 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
4793
4794 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
4795 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
4796 setverdict(pass);
4797}
4798
Harald Welteeaa9a862019-05-26 23:01:08 +02004799template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
4800 template (value) RoutingAreaIdentificationV rai,
4801 template (value) OCT1 cause) := {
4802 discriminator := '0000'B, /* overwritten */
4803 tiOrSkip := {
4804 skipIndicator := '0000'B
4805 },
4806 msgs := {
4807 rrm := {
4808 gPRS_suspensionRequest := {
4809 messageType := '00110100'B,
4810 tLLI := tlli,
4811 routingAreaIdentification := rai,
4812 suspensionCause := cause,
4813 service_Support := omit
4814 }
4815 }
4816 }
4817}
4818
4819/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
4820private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
4821 var PCUIF_Message first_info;
4822 var integer pcu_conn_id := -1;
4823 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4824 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
4825 var OCT4 tlli := '01020304'O;
4826 var OCT1 cause := '23'O;
4827 timer T := 5.0;
4828
4829 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4830
4831 f_l1_tune(L1CTL);
4832 RSL.clear;
4833
4834 f_est_dchan();
4835 L1CTL.clear;
4836
4837 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4838
4839 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
4840 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
4841 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
4842
4843 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
4844 T.start;
4845 alt {
4846 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
4847 setverdict(pass);
4848 }
4849 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
4850 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
4851 }
4852 [] PCU.receive {
4853 repeat;
4854 }
4855 [] T.timeout {
4856 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
4857 }
4858 }
Alexander Couzensa0634832019-06-07 00:28:56 +02004859
4860 /* release the channel */
4861 f_rsl_chan_deact();
4862 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4863 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02004864}
4865testcase TC_pcu_rr_suspend() runs on test_CT {
4866 var ConnHdlrPars pars;
4867 var ConnHdlr vc_conn;
4868
4869 f_init();
4870
4871 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
4872 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
4873 vc_conn.done;
4874}
Harald Welte07bd2d22019-05-25 11:03:30 +02004875
Harald Weltea2e0e942019-05-27 18:12:53 +02004876/* Ensure that PCUIF socket can accept only a single connection */
4877testcase TC_pcu_socket_connect_multi() runs on test_CT {
4878 timer T := 5.0;
4879
4880 /* this (among other things) establishes the first connection to the PCUIF socket */
4881 f_init();
4882
4883 /* try to establish a second connection, expect it to fail */
4884 PCU.send(UD_connect:{mp_pcu_socket, -1});
4885 T.start;
4886 alt {
4887 [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) {
4888 setverdict(pass);
4889 }
4890 [] PCU.receive(UD_connect_result:?) {
4891 setverdict(fail, "Unexpected unix domain connect result");
4892 }
4893 [] T.timeout {
4894 setverdict(pass);
4895 }
4896 }
4897 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4898}
4899
Harald Weltec8effb72019-05-27 18:23:04 +02004900/* Ensure that PCUIF socket can disconnect + reconnect */
4901testcase TC_pcu_socket_reconnect() runs on test_CT {
4902 /* this (among other things) establishes the first connection to the PCUIF socket */
4903 f_init();
4904
4905 f_sleep(1.0);
4906
4907 f_pcuif_close(PCU, g_pcu_conn_id);
4908 g_pcu_conn_id := -1;
4909
4910 f_sleep(1.0);
4911
4912 /* re-connect */
4913 PCU.clear;
4914 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
4915 setverdict(pass);
4916
4917 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4918}
4919
Harald Weltebe030482019-05-27 22:29:35 +02004920/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004921private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
4922runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02004923 var L1ctlDlMessage l1_dl;
4924 var SystemInformation si;
4925 timer T := 5.0;
4926 T.start;
4927 alt {
4928 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
4929 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
4930 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
4931 log("Ignoring non-RR SI ", l1_dl);
4932 repeat;
4933 }
4934 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004935 if (si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02004936 repeat;
4937 }
4938 }
4939 [] pt.receive {
4940 repeat;
4941 }
4942 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004943 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4944 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02004945 }
4946 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004947 return si;
Harald Weltebe030482019-05-27 22:29:35 +02004948}
4949
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004950/* Check if GPRS Indicator is present in RR System Information of a given type */
4951private function f_si_has_gprs_indicator(RrMessageType si_type)
4952runs on test_CT return boolean {
4953 var SystemInformation si := f_get_si(L1CTL, si_type);
4954
4955 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
4956 var RestOctets ro := si.payload.si3.rest_octets;
4957 var SI3RestOctets rest := dec_SI3RestOctets(ro);
4958 return rest.gprs_ind.presence == '1'B;
4959 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
4960 var RestOctets ro := si.payload.si4.rest_octets;
4961 var SI4RestOctets rest := dec_SI4RestOctets(ro);
4962 return rest.gprs_ind.presence == '1'B;
4963 }
4964
4965 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
4966 return false;
Harald Weltebe030482019-05-27 22:29:35 +02004967}
4968
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004969/* Make sure that GPRS Indicator is absent when the PCU is not connected */
4970private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
4971runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02004972 /* don't call f_init() as this would connect PCU socket */
4973 f_init_rsl(testcasename());
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004974
4975 /* Send both System Information Type 3 and 4 (with GPRS Indicator) */
Harald Weltebe030482019-05-27 22:29:35 +02004976 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004977 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Weltebe030482019-05-27 22:29:35 +02004978
4979 f_init_l1ctl();
4980 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02004981 f_sleep(2.0);
4982 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004983
4984 if (f_si_has_gprs_indicator(si_type)) {
4985 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02004986 } else {
4987 setverdict(pass);
4988 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004989
Harald Weltebe030482019-05-27 22:29:35 +02004990 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4991}
4992
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004993testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
4994 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
4995}
Harald Weltebe030482019-05-27 22:29:35 +02004996
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004997testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
4998 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
4999}
5000
5001/* Ensure that GPRS capability is advertised after PCU socket connect */
5002private function f_TC_pcu_socket_connect(RrMessageType si_type)
5003runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005004 /* this (among other things) establishes the first connection to the PCUIF socket */
5005 f_init();
5006 f_init_l1ctl();
5007 f_l1_tune(L1CTL);
5008
5009 f_sleep(2.0);
5010 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005011
5012 if (not f_si_has_gprs_indicator(si_type)) {
5013 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02005014 } else {
5015 setverdict(pass);
5016 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005017
Harald Weltebe030482019-05-27 22:29:35 +02005018 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5019}
5020
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005021testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
5022 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
5023}
Harald Weltebe030482019-05-27 22:29:35 +02005024
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005025testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
5026 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
5027}
5028
5029/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
5030private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
5031runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005032 /* this (among other things) establishes the first connection to the PCUIF socket */
5033 f_init();
5034 f_init_l1ctl();
5035 f_l1_tune(L1CTL);
5036
5037 f_pcuif_close(PCU, g_pcu_conn_id);
5038 g_pcu_conn_id := -1;
5039
5040 f_sleep(1.0);
5041
5042 /* re-connect */
5043 PCU.clear;
5044 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5045
5046 f_sleep(2.0);
5047 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005048
5049 if (f_si_has_gprs_indicator(si_type)) {
5050 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02005051 } else {
5052 setverdict(pass);
5053 }
5054
5055 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5056}
5057
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005058testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
5059 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
5060}
5061
5062testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
5063 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
5064}
5065
Oliver Smithf5239c72019-08-28 10:01:25 +02005066/* Verify that the cell_id of SI3 (TS 04.08 9.1.35) and other values are passed properly to the PCU socket (OS#3854) */
5067testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
5068 var SystemInformation si3 := valueof(ts_SI3_default);
5069
5070 f_init();
5071
5072 /* Verify cell_id */
5073 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
5074 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
5075 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02005076 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
5077 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
5078 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02005079 }
5080
5081 /* Verify LAC */
5082 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
5083 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
5084 if (lac_si3 != lac_pcu) {
5085 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
5086 }
5087
5088 setverdict(pass);
5089}
Harald Welted66c9b82019-05-25 09:03:15 +02005090
Harald Welte3d04ae62018-04-04 20:29:05 +02005091/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02005092 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02005093 ***********************************************************************/
5094
5095private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5096runs on ConnHdlr {
5097 var PCUIF_send_data sd;
5098 /* Expect BTS to immediately acknowledge activation as PDCH */
5099 PCU.clear;
5100 f_rsl_chan_act(g_pars.chan_mode);
5101 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005102 timer T_wait := 2.0;
5103 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005104 alt {
5105 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5106 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005107 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5108 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5109 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005110 }
5111 }
5112 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005113 [] T_wait.timeout {
5114 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5115 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5116 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005117 }
5118 /* try to activate this PDCH from the PCU point of view */
5119 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5120 /* FIXME: is there a response? */
5121}
5122
5123private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5124runs on ConnHdlr {
5125 var PCUIF_send_data sd;
5126 /* Send RSL CHAN REL (deactivate) */
5127 PCU.clear;
5128 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5129 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005130 timer T_wait := 2.0;
5131 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005132 alt {
5133 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5134 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005135 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5136 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5137 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005138 }
5139 }
5140 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005141 [] T_wait.timeout {
5142 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5143 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5144 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005145 }
5146 /* Emulate PCU asking BTS to deactivate PDCH */
5147 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5148 alt {
5149 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
5150 setverdict(pass);
5151 }
5152 [] RSL.receive { repeat; }
5153 }
5154}
5155
5156/* Activate Osmocom-style dynamic PDCH from BSC side */
5157function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
5158 var PCUIF_Message first_info;
5159 var integer ts_nr := g_chan_nr.tn;
5160 var integer trx_nr := 0;
5161 var integer bts_nr := 0;
5162 var integer pcu_conn_id := -1;
5163
5164 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5165
5166 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5167 f_sleep(3.0);
5168 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5169 setverdict(pass);
5170}
5171testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
5172 var ConnHdlrPars pars;
5173 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005174 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005175
5176 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5177 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
5178 vc_conn.done;
5179}
5180
5181/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
5182function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
5183 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02005184 var integer pcu_conn_id := -1;
5185
5186 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5187
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02005188 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5189 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
5190 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02005191 setverdict(pass);
5192}
5193testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
5194 var ConnHdlrPars pars;
5195 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005196 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005197
5198 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5199 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
5200 vc_conn.done;
5201}
5202
5203/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
5204function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
5205 var PCUIF_Message first_info;
5206 var integer ts_nr := g_chan_nr.tn;
5207 var integer trx_nr := 0;
5208 var integer bts_nr := 0;
5209 var integer pcu_conn_id := -1;
5210
5211 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5212
5213 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02005214 /* Send a second Chan Activ and expect it to be NACKed */
5215 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5216 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02005217 setverdict(pass);
5218}
5219testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
5220 var ConnHdlrPars pars;
5221 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005222 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005223
5224 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5225 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
5226 vc_conn.done;
5227}
5228
5229/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
5230function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
5231 var PCUIF_Message first_info;
5232 var integer ts_nr := g_chan_nr.tn;
5233 var integer trx_nr := 0;
5234 var integer bts_nr := 0;
5235 var integer pcu_conn_id := -1;
5236 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
5237
5238 /* register for the TCH/F channel number */
5239 f_rslem_register(0, chan_nr);
5240
5241 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5242
5243 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
5244 "RSL CHAN ACT");
5245 setverdict(pass);
5246}
5247testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
5248 var ConnHdlrPars pars;
5249 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005250 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005251
5252 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5253 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
5254 vc_conn.done;
5255}
5256
5257/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
5258function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
5259 var PCUIF_Message first_info;
5260 var integer ts_nr := g_chan_nr.tn;
5261 var integer trx_nr := 0;
5262 var integer bts_nr := 0;
5263 var integer pcu_conn_id := -1;
5264 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
5265 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
5266
5267 /* register for the TCH/H channel numbers */
5268 f_rslem_register(0, chan_nr[0]);
5269 f_rslem_register(0, chan_nr[1]);
5270
5271 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5272
5273 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
5274 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
5275 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
5276 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
5277 setverdict(pass);
5278}
5279testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
5280 var ConnHdlrPars pars;
5281 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005282 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005283
5284 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5285 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
5286 vc_conn.done;
5287}
5288
Harald Welte9bbbfb52018-04-05 09:33:19 +02005289/***********************************************************************
5290 * IPA Style Dynamic Timeslot Support
5291 ***********************************************************************/
5292
5293private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5294runs on ConnHdlr {
5295 var PCUIF_send_data sd;
5296 /* Expect BTS to immediately acknowledge activation as PDCH */
5297 PCU.clear;
5298 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5299 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005300 timer T_wait := 2.0;
5301 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005302 alt {
5303 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5304 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 +01005305 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5306 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5307 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005308 }
5309 }
5310 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005311 [] T_wait.timeout {
5312 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5313 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5314 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005315 }
5316 /* try to activate this PDCH from the PCU point of view */
5317 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5318 /* FIXME: is there a response? */
5319
5320 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
5321}
5322
5323private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5324runs on ConnHdlr {
5325 var PCUIF_send_data sd;
5326 /* Send RSL CHAN REL (deactivate) */
5327 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
5328 PCU.clear;
5329 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005330 timer T_wait := 2.0;
5331 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005332 alt {
5333 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5334 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 +01005335 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5336 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5337 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005338 }
5339 }
5340 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005341 [] T_wait.timeout {
5342 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5343 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5344 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005345 }
5346 /* Emulate PCU asking BTS to deactivate PDCH */
5347 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5348 alt {
5349 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
5350 setverdict(pass);
5351 }
5352 [] RSL.receive { repeat; }
5353 }
5354}
5355
5356/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
5357function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
5358 var PCUIF_Message first_info;
5359 var integer ts_nr := g_chan_nr.tn;
5360 var integer trx_nr := 0;
5361 var integer bts_nr := 0;
5362 var integer pcu_conn_id := -1;
5363
5364 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5365
5366 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5367 f_sleep(3.0);
5368 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5369
5370 setverdict(pass);
5371
5372}
5373testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
5374 var ConnHdlrPars pars;
5375 var ConnHdlr vc_conn;
5376 f_init();
5377
5378 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5379 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
5380 vc_conn.done;
5381}
5382
5383/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
5384function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
5385 var PCUIF_Message first_info;
5386 var integer ts_nr := g_chan_nr.tn;
5387 var integer trx_nr := 0;
5388 var integer bts_nr := 0;
5389 var integer pcu_conn_id := -1;
5390
5391 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5392
5393 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5394 "RSL CHAN ACT");
5395 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5396 "RF CHAN REL", true);
5397 setverdict(pass);
5398}
5399testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
5400 var ConnHdlrPars pars;
5401 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005402 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005403
5404 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5405 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
5406 vc_conn.done;
5407}
5408
5409/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
5410function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
5411 var PCUIF_Message first_info;
5412 var integer ts_nr := g_chan_nr.tn;
5413 var integer trx_nr := 0;
5414 var integer bts_nr := 0;
5415 var integer pcu_conn_id := -1;
5416
5417 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5418
5419 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5420 "RSL CHAN ACT");
5421
5422 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5423 alt {
5424 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
5425 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005426 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02005427 }
5428 [] RSL.receive { repeat; }
5429 }
5430
5431 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5432 "RF CHAN REL", true);
5433 setverdict(pass);
5434}
5435testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
5436 var ConnHdlrPars pars;
5437 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005438 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005439
5440 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5441 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
5442 vc_conn.done;
5443}
5444
5445/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
5446function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
5447 var PCUIF_Message first_info;
5448 var integer ts_nr := g_chan_nr.tn;
5449 var integer trx_nr := 0;
5450 var integer bts_nr := 0;
5451 var integer pcu_conn_id := -1;
5452
5453 /* register for the TCH/F channel number */
5454 f_rslem_register(0, g_chan_nr);
5455
5456 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5457
5458 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5459
5460 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5461 "RSL CHAN ACT");
5462
5463 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5464
5465 setverdict(pass);
5466}
5467testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
5468 var ConnHdlrPars pars;
5469 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005470 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005471
5472 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5473 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
5474 vc_conn.done;
5475}
5476
5477
Harald Welte0472ab42018-03-12 15:02:26 +01005478/***********************************************************************
5479 * LAPDm / RLL related
5480 ***********************************************************************/
5481
5482private function f_tx_lapdm(template (value) LapdmFrame l,
5483 template (value) RslLinkId link_id) runs on ConnHdlr {
5484 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005485 var template (value) SacchL1Header l1h;
5486
5487 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01005488 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005489 /* Compose dummy L1 header */
5490 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta);
5491 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1h, f_pad_oct(l2, 21, '2B'O)));
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02005492 } else {
5493 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005494 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, f_pad_oct(l2, 23, '2B'O)));
Harald Welte0472ab42018-03-12 15:02:26 +01005495 }
Harald Welte0472ab42018-03-12 15:02:26 +01005496}
5497
5498type record RllTestCase {
5499 uint3_t sapi,
5500 RslLinkId link_id,
5501 octetstring l3,
5502 boolean exp
5503}
5504type record of RllTestCase RllTestCases;
5505template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
5506 sapi := sapi,
5507 link_id := id,
5508 l3 := l3,
5509 exp := exp
5510}
5511
5512/* execute the same callback function with a set of different parameters (tcs) on a
5513 * variety of logical channels */
5514private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
5515 var ConnHdlrPars pars;
5516 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005517 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01005518
5519 /* test on each of the channels we have */
5520 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
5521 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
5522
5523 /* test each of the test cases on the current channel */
5524 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
5525 pars.spec.rll := tcs[j];
5526 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
5527 vc_conn := f_start_handler(fn, pars);
5528 vc_conn.done;
5529 }
5530 }
5531
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005532 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01005533}
5534
5535/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
5536private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
5537 var RllTestCase tc := g_pars.spec.rll;
5538 timer T := 3.0;
5539
5540 f_l1_tune(L1CTL);
5541 RSL.clear;
5542
5543 /* activate the logical channel */
5544 f_est_dchan();
5545 L1CTL.clear;
5546
5547 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
5548 T.start;
5549 alt {
5550 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
5551 if (tc.exp) {
5552 setverdict(pass);
5553 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005554 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005555 }
5556 }
5557 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
5558 if (tc.exp) {
5559 setverdict(pass);
5560 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005561 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005562 }
5563 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005564 /* We also expect to receive the measurements */
5565 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005566 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005567 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005568 }
5569 [not tc.exp] T.timeout {
5570 setverdict(pass);
5571 }
5572 }
5573
5574 f_rsl_chan_deact();
5575 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5576 f_rslem_unregister(0, g_chan_nr);
5577}
5578testcase TC_rll_est_ind() runs on test_CT {
5579 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02005580 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01005581 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02005582 /* normal SAPI0 establishment */
5583 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01005584 /* SAPI 3 doesn't support contention resolution */
5585 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
5586 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
5587 /* normal SAPI3 establishment on main DCCH */
5588 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5589 /* normal SAPI3 establishment on SACCH */
5590 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5591 };
5592 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
5593}
5594
5595/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
5596private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
5597 var RllTestCase tc := g_pars.spec.rll;
5598 var L1ctlDlMessage dl;
5599 timer T := 3.0;
5600
5601 f_l1_tune(L1CTL);
5602 RSL.clear;
5603
5604 /* activate the logical channel */
5605 f_est_dchan();
5606 L1CTL.clear;
5607
5608 /* Send a RSL EST REQ for SAPI3 on main DCCH */
5609 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
5610 T.start;
5611 alt {
5612 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5613 var LapdmFrame lapdm;
5614 var octetstring l2 := dl.payload.data_ind.payload;
5615 if (dl.dl_info.link_id.c == SACCH) {
5616 /* remove L1 header */
5617 l2 := substr(l2, 2, lengthof(l2)-2);
5618 }
5619 lapdm.ab := dec_LapdmFrameAB(l2);
5620 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
5621 setverdict(pass);
5622 } else {
5623 repeat;
5624 }
5625 }
5626 [] L1CTL.receive { repeat; }
5627 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005628 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01005629 }
5630 }
5631
5632 f_rsl_chan_deact();
5633 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5634 f_rslem_unregister(0, g_chan_nr);
5635}
5636testcase TC_rll_est_req_DCCH_3() runs on test_CT {
5637 var RllTestCases tcs := {
5638 /* normal SAPI3 establishment on main DCCH */
5639 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
5640 };
5641 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5642}
5643testcase TC_rll_est_req_ACCH_3() runs on test_CT {
5644 var RllTestCases tcs := {
5645 /* normal SAPI3 establishment on SACCH */
5646 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5647 }
5648 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5649}
5650
5651/* altstep to receive a LAPDm frame matching the given template */
5652private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
5653 var L1ctlDlMessage dl;
5654 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5655 var LapdmFrame lapdm;
5656 var octetstring l2 := dl.payload.data_ind.payload;
5657 if (dl.dl_info.link_id.c == SACCH) {
5658 /* remove L1 header */
5659 l2 := substr(l2, 2, lengthof(l2)-2);
5660 }
5661 if (ischosen(exp.ab)) {
5662 lapdm.ab := dec_LapdmFrameAB(l2);
5663 } else if (ischosen(exp.b4)) {
5664 lapdm.b4 := dec_LapdmFrameB4(l2);
5665 } else if (ischosen(exp.bbis)) {
5666 lapdm.bbis := dec_LapdmFrameBbis(l2);
5667 }
5668 log("Rx LAPDm ", lapdm);
5669 if (match(lapdm, exp)) {
5670 setverdict(pass);
5671 } else {
5672 repeat;
5673 }
5674 }
5675 [] L1CTL.receive { repeat; }
5676}
5677private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
5678 timer T := t;
5679 T.start;
5680 alt {
5681 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005682 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01005683 }
5684 [] as_l1_exp_lapdm(exp);
5685 }
5686}
5687
5688/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
5689private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5690 /* send SABM from MS -> BTS */
5691 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
5692 /* expect RLL EST IND on Abis */
5693 alt {
5694 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
5695 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
5696 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005698 }
5699 [] RSL.receive { repeat; }
5700 }
5701 /* expect UA from BTS -> MS */
5702 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
5703}
5704
5705/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
5706private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
5707 var RllTestCase tc := g_pars.spec.rll;
5708
5709 f_l1_tune(L1CTL);
5710 RSL.clear;
5711
5712 /* activate the logical channel */
5713 f_est_dchan();
5714 L1CTL.clear;
5715
5716 /* first establish the link-layer */
5717 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5718
5719 /* then send the DISC */
5720 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
5721 /* ... and expect the REL IND on the RSL side */
5722 alt {
5723 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
5724 setverdict(pass);
5725 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005726 /* We also expect to receive the measurements */
5727 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005728 }
5729
5730 /* release the channel */
5731 f_rsl_chan_deact();
5732 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5733 f_rslem_unregister(0, g_chan_nr);
5734}
5735testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
5736 var RllTestCases tcs := {
5737 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
5738 };
5739 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5740}
5741
5742testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
5743 var RllTestCases tcs := {
5744 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
5745 };
5746 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5747}
5748testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
5749 var RllTestCases tcs := {
5750 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
5751 };
5752 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5753}
5754testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
5755 var RllTestCases tcs := {
5756 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5757 };
5758 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5759}
5760
5761/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
5762private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
5763 var RllTestCase tc := g_pars.spec.rll;
5764 f_l1_tune(L1CTL);
5765 RSL.clear;
5766
5767 /* activate the logical channel */
5768 f_est_dchan();
5769 L1CTL.clear;
5770
5771 /* first establish the link-layer */
5772 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5773
5774 /* then send the REL REQ via RSL */
5775 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
5776 /* ... and expect the DISC on the Um side */
5777 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02005778 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01005779 /* FIXME: send a UA in resposne to the DISC */
5780 }
5781 }
5782
5783 /* release the channel */
5784 f_rsl_chan_deact();
5785 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5786 f_rslem_unregister(0, g_chan_nr);
5787}
5788testcase TC_rll_rel_req() runs on test_CT {
5789 var RllTestCases tcs := {
5790 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
5791 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
5792 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5793 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5794 };
5795 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
5796}
5797
5798/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
5799testcase TC_rll_data_req() runs on test_CT {
5800}
5801
5802/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
5803testcase TC_rll_data_ind() runs on test_CT {
5804}
5805
5806/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
5807private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
5808 var RllTestCase tc := g_pars.spec.rll;
5809
5810 f_l1_tune(L1CTL);
5811 RSL.clear;
5812
5813 f_est_dchan();
5814 L1CTL.clear;
5815
5816 /* Send UNITDATA REQ on RSL side */
5817 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
5818 /* Expect it to arrive on the other side */
5819 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02005820 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005821 } else {
Harald Weltee613f962018-04-18 22:38:16 +02005822 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005823 }
5824
5825 /* release the channel */
5826 f_rsl_chan_deact();
5827 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5828 f_rslem_unregister(0, g_chan_nr);
5829}
5830testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
5831 var octetstring l3 := f_rnd_octstring(15);
5832 var RllTestCases tcs := {
5833 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5834 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5835 };
5836 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5837}
5838testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
5839 var octetstring l3 := f_rnd_octstring(19);
5840 var RllTestCases tcs := {
5841 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5842 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5843 };
5844 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5845}
5846
5847/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
5848private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
5849 var RllTestCase tc := g_pars.spec.rll;
5850
5851 f_l1_tune(L1CTL);
5852 RSL.clear;
5853
5854 f_est_dchan();
5855 L1CTL.clear;
5856
5857 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02005858 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01005859 /* Expdct RLL UNITDATA IND on RSL side */
5860 alt {
5861 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
5862 setverdict(pass);
5863 }
5864 [] RSL.receive { repeat; }
5865 }
5866
5867 /* release the channel */
5868 f_rsl_chan_deact();
5869 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5870 f_rslem_unregister(0, g_chan_nr);
5871}
5872testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02005873 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01005874 var RllTestCases tcs := {
5875 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5876 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5877 };
5878 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5879}
5880testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
5881 var octetstring l3 := f_rnd_octstring(18);
5882 var RllTestCases tcs := {
5883 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5884 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5885 };
5886 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5887}
5888
Harald Weltee613f962018-04-18 22:38:16 +02005889/***********************************************************************
5890 * Encryption Related
5891 ***********************************************************************/
5892
5893/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5894function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5895 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
5896 if (link_id.c == SACCH) {
5897 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
5898 } else {
5899 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
5900 }
5901}
5902
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005903/* Expect (or not expect) other kinds of messages */
5904private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
5905 [exp_any] RSL.receive { repeat; }
5906 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005907 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005908 }
5909}
5910
Harald Weltee613f962018-04-18 22:38:16 +02005911/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07005912private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005913 RslLinkId link_id,
5914 octetstring l3,
5915 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005916 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005917) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02005918 timer T := 3.0;
5919 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
5920 T.start;
5921 /* Expect RLL UNITDATA IND on RSL side */
5922 alt {
5923 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
5924 setverdict(pass);
5925 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005926 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005927 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02005928 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005929 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02005930 }
Harald Weltee613f962018-04-18 22:38:16 +02005931 }
5932}
5933
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005934/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
5935private function f_data_mo(
5936 RslLinkId link_id,
5937 boolean p, uint3_t nr, uint3_t ns,
5938 octetstring l3,
5939 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005940 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005941) runs on ConnHdlr {
5942 timer T := 3.0;
5943 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
5944 T.start;
5945 /* Expect RLL DATA IND on RSL side */
5946 alt {
5947 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
5948 setverdict(pass);
5949 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005950 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005951 [] as_rsl_any_ind(exp_any);
5952 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005953 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005954 }
5955 }
5956}
5957
Harald Weltee613f962018-04-18 22:38:16 +02005958/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
5959function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
5960 f_l1_tune(L1CTL);
5961 f_est_dchan(true);
5962
5963 /* now we actually need to transmit some data both ways to check if the encryption works */
5964 var L1ctlDlMessage dl;
5965
Stefan Sperling603d98e2018-07-25 16:47:28 +02005966 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02005967 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5968
5969 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5970 f_unitdata_mt(link_id, l3);
5971
5972 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
5973 f_unitdata_mo(link_id, l3);
5974
5975 /* release the channel */
5976 f_rsl_chan_deact();
5977 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5978 f_rslem_unregister(0, g_chan_nr);
5979}
5980testcase TC_chan_act_a51() runs on test_CT {
5981 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5982 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
5983 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5984}
5985testcase TC_chan_act_a52() runs on test_CT {
5986 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5987 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
5988 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5989}
5990testcase TC_chan_act_a53() runs on test_CT {
5991 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5992 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
5993 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5994}
5995
Eric Wildf1827a72019-05-28 17:37:35 +02005996/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
5997 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
5998function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
5999 f_l1_tune(L1CTL);
6000 f_est_dchan(true);
6001
6002 /* now we actually need to transmit some data both ways to check if the encryption works */
6003 var L1ctlDlMessage dl;
6004
6005 var octetstring l3 := f_rnd_octstring(20);
6006 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6007
6008 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
6009 f_unitdata_mt(link_id, l3);
6010
6011 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
6012 f_unitdata_mo(link_id, l3);
6013
6014 var RSL_Message rsl;
6015 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false))));
6016
6017 /* modify key to break proper encryption */
6018 g_pars.encr.key := f_rnd_octstring(8);
6019 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
6020 rsl.ies := rsl.ies & { ei };
6021 RSL.send(rsl);
6022
6023 timer T0 := 1.0;
6024 T0.start;
6025 /* Expect RSL MODIFY ACK */
6026 alt {
6027 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
6028 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
6029 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
6030 }
6031 [] T0.timeout {
6032 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
6033 }
6034 }
6035
6036 var octetstring l3msg := f_rnd_octstring(15);
6037 timer T1 := 3.0;
6038 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
6039 due to broken encryption */
6040 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
6041 T1.start;
6042 alt {
6043 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
6044 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
6045 }
6046 [] T1.timeout {
6047 setverdict(pass);
6048 }
6049 }
6050
6051 /* release the channel */
6052 f_rsl_chan_deact();
6053 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6054 f_rslem_unregister(0, g_chan_nr);
6055}
6056testcase TC_rsl_modify_encr() runs on test_CT {
6057 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6058 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6059 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
6060}
Harald Weltee613f962018-04-18 22:38:16 +02006061
6062/* Test unencrypted channel activation followed by explicit ENCR CMD later */
6063function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
6064 /* L3 payload doesn't matter, as it is passed transparently */
6065 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
6066 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
6067 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6068
6069 f_l1_tune(L1CTL);
6070
6071 /* first establish a dedicated channel in the clear */
6072 f_est_dchan(false);
6073
6074 /* Establish ABM */
6075 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
6076
6077 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
6078 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
6079 /* expect the L3 to arrive still unencrypted on the MS side */
6080 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
6081
6082 /* configure L1 to apply ciphering */
6083 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
6084 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
6085
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006086 /* send first ciphered I-frame in response and expect it on RSL */
6087 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02006088
6089 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
6090 * and hence enable encryption also on the downlink */
6091
6092 /* expect bi-directional communication work in encrypted mode */
6093 f_unitdata_mo(link_id, f_rnd_octstring(15));
6094 f_unitdata_mt(link_id, f_rnd_octstring(15));
6095
6096 /* release the channel */
6097 f_rsl_chan_deact();
6098 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6099 f_rslem_unregister(0, g_chan_nr);
6100}
6101testcase TC_encr_cmd_a51() runs on test_CT {
6102 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6103 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6104 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6105}
6106testcase TC_encr_cmd_a52() runs on test_CT {
6107 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6108 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
6109 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6110}
6111testcase TC_encr_cmd_a53() runs on test_CT {
6112 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6113 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
6114 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6115}
6116
6117private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
6118 var LapdmFrame lf;
6119 var octetstring reenc;
6120
6121 /* decode the LAPDm frame */
6122 if (ischosen(exp_match.ab)) {
6123 lf.ab := dec_LapdmFrameAB(enc);
6124 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006125 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02006126 }
6127
6128 /* check if decoder result matches expectation */
6129 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006130 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006131 } else {
6132 log(name, ": matched");
6133 setverdict(pass);
6134 }
6135
6136 /* test if re-encoded frame equals original input */
6137 reenc := enc_LapdmFrame(lf);
6138 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006139 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006140 } else {
6141 setverdict(pass);
6142 }
6143}
6144
6145testcase TC_lapdm_selftest() runs on test_CT {
6146 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
6147 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
6148 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
6149 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
6150 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
6151 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
6152 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
6153}
6154
Stefan Sperling4880be42018-08-07 18:12:59 +02006155/***********************************************************************
6156 * DTX Related (see GSM 05.08, section 8.3)
6157 ***********************************************************************/
6158
6159/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
6160function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
6161 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
6162 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
6163 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
6164 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
6165}
6166function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
6167 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
6168 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
6169}
6170function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
6171 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
6172 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
6173 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
6174 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
6175}
6176function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
6177 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
6178 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
6179 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
6180 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
6181 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
6182 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
6183 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
6184 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
6185}
6186
6187function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
6188 var L1ctlDlMessage dl;
6189 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
6190 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
6191 var GsmFrameNumber first_fn;
6192 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006193 var integer nfill_frames_sacch := 0;
6194 var integer nfill_frames_nonsacch := 0;
6195 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02006196 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
6197 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006198 const integer frame_dtx_tchf_mod := 104;
6199 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
6200 * which operates in terms of blocks rather than frames. */
6201 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
6202 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02006203 timer T := 5.0;
6204
6205 f_l1_tune(L1CTL);
6206 RSL.clear;
6207 L1CTL.clear;
6208
6209 /* activate TCHF signalling channel */
6210 f_est_dchan(false);
6211
6212 T.start;
6213 alt {
6214 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
6215 var GsmFrameNumber fn := dl.dl_info.frame_nr;
6216 var octetstring l2 := dl.payload.data_ind.payload;
6217
6218 if (is_first_frame) {
6219 is_first_frame := false;
6220 first_fn := dl.dl_info.frame_nr;
6221 }
6222
6223 if (dl.dl_info.link_id.c == SACCH) {
6224 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
6225 if (not match(l2_fill_frame_sacch, l2)) {
6226 repeat;
6227 }
6228 } else if (not match(l2_fill_frame, l2)) {
6229 repeat;
6230 }
6231
6232 if (dtxd) {
6233 if (not f_g_chan_is_tchf()) {
6234 T.stop;
6235 f_rsl_chan_deact();
6236 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006237 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 +02006238 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006239 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006240 T.stop;
6241 f_rsl_chan_deact();
6242 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006243
6244 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
6245 * 2 SACCH, 1 TCH/F */
6246 expected_fill_frames := 3;
6247
6248 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
6249 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6250 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006251 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006252 } else {
6253 setverdict(pass);
6254 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006255 } else {
6256 if (dl.dl_info.link_id.c == SACCH) {
6257 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02006258 repeat;
6259 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006260 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
6261 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
6262 * we should only see the subset of frames numbers which correspond to a block boundary.
6263 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
6264 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
6265 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
6266 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6267 repeat;
6268 }
6269 }
6270 log("Received DTX TCH fill frame with bad frame number: ", fn,
6271 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
6272 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
6273 f_rsl_chan_deact();
6274 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006275 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006276 }
Stefan Sperling4880be42018-08-07 18:12:59 +02006277 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006278 if (dl.dl_info.link_id.c == SACCH) {
6279 nfill_frames_sacch := nfill_frames_sacch + 1;
6280 } else {
6281 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6282 }
6283 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006284 T.stop;
6285 if (f_g_chan_is_tchf()) {
6286 /* Without DTX we can expect 25 fill frames for every 104 frames.
6287 * (24 FACCH + 1 SACCH filling) */
6288 expected_fill_frames := 25;
6289 } else if (f_g_chan_is_tchh()) {
6290 /* We can expect 2 fill frames for every 104 frames. */
6291 expected_fill_frames := 2;
6292 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
6293 /* We can expect 5 fill frames for every 104 frames. */
6294 expected_fill_frames := 5;
6295 } else {
6296 f_rsl_chan_deact();
6297 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006298 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02006299 }
6300
6301 f_rsl_chan_deact();
6302 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006303
6304 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006305 setverdict(pass);
6306 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006307 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6308 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006309 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006310 }
6311 } else {
6312 repeat;
6313 }
6314 }
6315 }
6316 [] L1CTL.receive { repeat; }
6317 [] T.timeout {
6318 f_rsl_chan_deact();
6319 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006320 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006321 }
6322 }
6323}
6324
6325function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
6326 f_test_l2_fill_frames(false);
6327}
6328
6329function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
6330 f_test_l2_fill_frames(true);
6331}
6332
6333function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
6334 var ConnHdlr vc_conn;
6335 var ConnHdlrPars pars;
6336 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02006337 f_init();
Stefan Sperling4880be42018-08-07 18:12:59 +02006338 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
6339 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
6340 if (dtxd) {
6341 if (i >= 4) { /* DTX is only allowed on TCH/F */
6342 break;
6343 }
6344 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
6345 } else {
6346 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
6347 }
6348 vc_conn.done;
6349 }
6350}
6351
6352/* Verify that L2 fill frames are sent on TCH in signaling mode if
6353 * there is nothing to transmit while DTX is disabled on downlink. */
6354testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
6355 f_tch_sign_l2_fill_frame(false);
6356}
6357
6358/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
6359 * there is nothing to transmit while DTX is enabled on downlink. */
6360testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
6361 f_tch_sign_l2_fill_frame(true);
6362}
Harald Welte0472ab42018-03-12 15:02:26 +01006363
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006364testcase TC_chopped_ipa_ping() runs on test_CT {
6365 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6366}
6367
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006368testcase TC_chopped_ipa_payload() runs on test_CT {
6369 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6370}
6371
Harald Welte0472ab42018-03-12 15:02:26 +01006372/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
6373/* protocol error as per 44.006 */
6374/* link layer failure (repetition of I-frame N200 times without ACK */
6375/* repetition of SABM or DISC N200 times without ACK */
6376/* receptiom of SABM in multi-frame established state */
6377
6378
Harald Welte68e495b2018-02-25 00:05:57 +01006379/* TODO Areas:
6380
6381* channel activation
6382** with BS_Power / MS_Power, bypassing power control loop
6383** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01006384** with timing advance from initial activation on
6385* mode modify
6386** encryption
6387** multirate
6388* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01006389** unsupported algorithm
6390* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01006391* BS Power Control
6392* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01006393* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01006394* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01006395** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01006396* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01006397** DATA_IND from BTS->PCU
6398** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01006399
6400*/
Harald Welte70767382018-02-21 12:16:40 +01006401
6402control {
6403 execute( TC_chan_act_stress() );
6404 execute( TC_chan_act_react() );
6405 execute( TC_chan_deact_not_active() );
6406 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01006407 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01006408 execute( TC_sacch_filling() );
6409 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01006410 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01006411 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02006412 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02006413 execute( TC_sacch_chan_act_ho_async() );
6414 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01006415 execute( TC_rach_content() );
6416 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01006417 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07006418 execute( TC_ho_rach() );
Harald Welte3453ab42019-05-24 21:19:58 +02006419 execute( TC_rach_load_idle_thresh0() );
6420 execute( TC_rach_load_idle_below_thresh() );
6421 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01006422 execute( TC_meas_res_sign_tchf() );
6423 execute( TC_meas_res_sign_tchh() );
6424 execute( TC_meas_res_sign_sdcch4() );
6425 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01006426 execute( TC_meas_res_sign_tchh_toa256() );
Eric Wildae8f2622019-06-18 17:05:11 +02006427 execute( TC_rsl_bs_pwr_static_ass() );
6428 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01006429 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02006430 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02006431 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02006432 execute( TC_rsl_ms_pwr_dyn_up() );
6433 execute( TC_rsl_ms_pwr_dyn_down() );
6434 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
6435 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02006436 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02006437 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02006438 execute( TC_rsl_modify_encr() );
Harald Welte70767382018-02-21 12:16:40 +01006439 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01006440 execute( TC_paging_imsi_80percent() );
6441 execute( TC_paging_tmsi_80percent() );
6442 execute( TC_paging_imsi_200percent() );
6443 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01006444 execute( TC_rsl_protocol_error() );
6445 execute( TC_rsl_mand_ie_error() );
6446 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01006447 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01006448 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01006449 execute( TC_si_sched_2bis() );
6450 execute( TC_si_sched_2ter() );
6451 execute( TC_si_sched_2ter_2bis() );
6452 execute( TC_si_sched_2quater() );
6453 execute( TC_si_sched_13() );
6454 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01006455 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01006456 execute( TC_ipa_crcx_twice_not_active() );
6457 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01006458 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01006459 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01006460
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006461 if (mp_pcu_socket != "") {
6462 execute( TC_pcu_act_req() );
6463 execute( TC_pcu_act_req_wrong_ts() );
6464 execute( TC_pcu_act_req_wrong_bts() );
6465 execute( TC_pcu_act_req_wrong_trx() );
6466 execute( TC_pcu_deact_req() );
6467 execute( TC_pcu_deact_req_wrong_ts() );
6468 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02006469 if (mp_l1_supports_gprs) {
6470 execute( TC_pcu_data_req_pdtch() );
6471 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02006472 execute( TC_pcu_data_req_wrong_bts() );
6473 execute( TC_pcu_data_req_wrong_trx() );
6474 execute( TC_pcu_data_req_wrong_ts() );
6475 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02006476 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07006477 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006478 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02006479 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006480 execute( TC_pcu_data_req_imm_ass_pch() );
6481 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07006482 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07006483 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006484 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02006485 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02006486 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02006487 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02006488 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02006489 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02006490 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02006491 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006492 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006493 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006494 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006495 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006496 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02006497 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01006498 execute( TC_dyn_osmo_pdch_act_deact() );
6499 execute( TC_dyn_osmo_pdch_double_act() );
6500 execute( TC_dyn_ipa_pdch_act_deact() );
6501 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
6502
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006503 } else {
6504 log("PCU socket path not available, skipping PCU tests");
6505 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006506
Harald Welte3d04ae62018-04-04 20:29:05 +02006507 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02006508 execute( TC_dyn_osmo_pdch_tchf_act() );
6509 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02006510 execute( TC_dyn_ipa_pdch_tchf_act() );
6511 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01006512
6513 execute( TC_rll_est_ind() );
6514 execute( TC_rll_est_req_DCCH_3() );
6515 execute( TC_rll_est_req_ACCH_3() );
6516 execute( TC_rll_rel_ind_DCCH_0() );
6517 execute( TC_rll_rel_ind_DCCH_3() );
6518 execute( TC_rll_rel_ind_ACCH_0() );
6519 execute( TC_rll_rel_ind_ACCH_3() );
6520 execute( TC_rll_rel_req() );
6521 execute( TC_rll_unit_data_req_DCCH() );
6522 execute( TC_rll_unit_data_req_ACCH() );
6523 execute( TC_rll_unit_data_ind_DCCH() );
6524 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02006525
6526 execute( TC_chan_act_a51() );
6527 execute( TC_chan_act_a52() );
6528 execute( TC_chan_act_a53() );
6529 execute( TC_encr_cmd_a51() );
6530 execute( TC_encr_cmd_a52() );
6531 execute( TC_encr_cmd_a53() );
6532
Harald Welteee25aae2019-05-19 14:32:37 +02006533 execute( TC_err_rep_wrong_mdisc() );
6534 execute( TC_err_rep_wrong_msg_type() );
6535 execute( TC_err_rep_wrong_sequence() );
6536
Harald Weltee613f962018-04-18 22:38:16 +02006537 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02006538
6539 execute( TC_tch_sign_l2_fill_frame() );
6540 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006541
6542 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006543 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01006544}
6545
6546
6547}