blob: 12e1a3a06917728ba41695e42bb46f0507518c26 [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003import from Misc_Helpers all;
Harald Welte70767382018-02-21 12:16:40 +01004import from General_Types all;
5import from GSM_Types all;
6import from GSM_RR_Types all;
7import from Osmocom_Types all;
8import from GSM_Types all;
Harald Welte82ccef72018-02-25 16:17:33 +01009import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010010import from L1CTL_PortType all;
11import from L1CTL_Types all;
12import from LAPDm_Types all;
13import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020014import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010015
16import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010017import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010018import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020019import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010020import from RSL_Emulation all;
21
22import from IPL4asp_Types all;
23import from TRXC_Types all;
24import from TRXC_CodecPort all;
25import from TRXC_CodecPort_CtrlFunct all;
26
Harald Welte883340c2018-02-28 18:59:29 +010027import from PCUIF_Types all;
28import from PCUIF_CodecPort all;
29
Harald Welte7484fc42018-02-24 14:09:45 +010030import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010031import from MobileL3_RRM_Types all;
32import from MobileL3_Types all;
33import from L3_Templates all;
Harald Welte7484fc42018-02-24 14:09:45 +010034
Harald Welte8da48242018-02-27 20:41:32 +010035import from Osmocom_VTY_Functions all;
36import from TELNETasp_PortType all;
37
Harald Welte505cf9b2018-09-15 17:47:23 +030038friend module BTS_Tests_SMSCB;
39
Harald Welte70767382018-02-21 12:16:40 +010040/* The tests assume a BTS with the following timeslot configuration:
41 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020042 * TS1 : TCH/F
43 * TS2 : TCH/F
44 * TS3 : TCH/F_PDCH (IPA Style)
45 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010046 * TS5 : TCH/H
47 * TS6 : SDCCH/8
48 * TS7 : PDCH
49 */
50
51modulepar {
52 charstring mp_rsl_ip := "127.0.0.2";
53 integer mp_rsl_port := 3003;
54 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070055 charstring mp_bts_trxc_ip := "127.0.0.1";
56 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010057 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020058 charstring mp_ctrl_ip := "127.0.0.1";
59 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020060 charstring mp_bsc_ctrl_ip := "127.0.0.1";
61 integer mp_bsc_ctrl_port := 4249;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020062 integer mp_tolerance_rxqual := 1;
63 integer mp_tolerance_rxlev := 3;
64 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020065 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020066 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020067 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020068 integer mp_ms_actual_ta_exp := 0;
69 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +010070 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +020071 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +020072 float mp_ipa_up_delay := 0.0;
Harald Welte70767382018-02-21 12:16:40 +010073}
74
Harald Welte629cc6b2018-03-11 17:19:05 +010075type record of RslChannelNr ChannelNrs;
76
Harald Welte70767382018-02-21 12:16:40 +010077type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010078 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010079 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010080 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010081 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010082 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010083 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010084
85 /* L1CTL port (for classic tests) */
86 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010087
Harald Welte54a2a2d2018-02-26 09:14:05 +010088 /* TRXC port (for classic tests) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070089 port TRXC_CODEC_PT BTS_TRXC;
90 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +010091
Harald Weltef50e3ae2018-09-10 10:27:56 +020092 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010093 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020094 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010095
Harald Welte883340c2018-02-28 18:59:29 +010096 /* PCU Interface of BTS */
97 port PCUIF_CODEC_PT PCU;
98 var integer g_pcu_conn_id;
99 /* Last PCU INFO IND we received */
100 var PCUIF_Message g_pcu_last_info;
101
Harald Welte48494ca2018-02-25 16:59:50 +0100102 /* SI configuration */
103 var SystemInformationConfig si_cfg := {
104 bcch_extended := false,
105 si1_present := false,
106 si2bis_present := false,
107 si2ter_present := false,
108 si2quater_present := false,
109 si7_present := false,
110 si8_present := false,
111 si9_present := false,
112 si13_present := false,
113 si13alt_present := false,
114 si15_present := false,
115 si16_present := false,
116 si17_present := false,
117 si2n_present := false,
118 si21_present := false,
119 si22_present := false
120 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100121
122 /* all logical channels available on the BTS */
123 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100124 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100125}
126
127/* an individual call / channel */
128type component ConnHdlr extends RSL_DchanHdlr {
129 port L1CTL_PT L1CTL;
130
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700131 port TRXC_CODEC_PT BTS_TRXC;
132 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100133
134 timer g_Tguard;
135 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
136
137 var ConnHdlrPars g_pars;
138 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100139 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200140
141 /* PCU Interface of BTS */
142 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100143}
144
145function f_init_rsl(charstring id) runs on test_CT {
146 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
147 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
148
149 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
150 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
151 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
152
153 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
154 vc_RSL.start(RSL_Emulation.main(false));
155}
156
157type record ConnHdlrPars {
158 RslChannelNr chan_nr,
159 RSL_IE_ChannelMode chan_mode,
160 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100161 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200162 TestSpecUnion spec optional,
163 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100164}
165
166/* Test-specific parameters */
167type union TestSpecUnion {
168 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100169}
170
Harald Welte82ccef72018-02-25 16:17:33 +0100171template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100172 max_retrans := RACH_MAX_RETRANS_7,
173 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100174 cell_barr_access := false,
175 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100176 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100177};
178
Harald Weltef10153f2018-02-25 16:34:05 +0100179template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100180 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200181 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100182 acs := '0'B,
183 neci := true,
184 rxlev_access_min := 0
185}
186
187template (value) LocationAreaIdentification ts_LAI_default := {
188 mcc_mnc := '262F42'H,
189 lac := 42
190}
191
Harald Welte7484fc42018-02-24 14:09:45 +0100192/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100193template (value) SystemInformation ts_SI3_default := {
194 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100195 payload := {
196 si3 := {
197 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100198 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100199 ctrl_chan_desc := {
200 msc_r99 := true,
201 att := true,
202 bs_ag_blks_res := 1,
203 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100204 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100205 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
206 spare := '00'B,
207 bs_pa_mfrms := 0, /* 2 multiframes */
208 t3212 := 1 /* 6 minutes */
209 },
Harald Welte82ccef72018-02-25 16:17:33 +0100210 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100211 dn_ind := false,
212 pwrc := false,
213 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100214 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100215 },
Harald Weltef10153f2018-02-25 16:34:05 +0100216 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100217 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100218 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100219 }
220 }
221}
Harald Welte70767382018-02-21 12:16:40 +0100222
Harald Weltef8df4cb2018-03-10 15:15:08 +0100223template (value) SystemInformation ts_SI2_default := {
224 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100225 payload := {
226 si2 := {
227 bcch_freq_list := '00000000000000000000000000000000'O,
228 ncc_permitted := '11111111'B,
229 rach_control := ts_RachCtrl_default
230 }
231 }
232}
233
Harald Weltef8df4cb2018-03-10 15:15:08 +0100234template (value) SystemInformation ts_SI4_default := {
235 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100236 payload := {
237 si4 := {
238 lai := ts_LAI_default,
239 cell_sel_par := ts_CellSelPar_default,
240 rach_control := ts_RachCtrl_default,
241 cbch_chan_desc := omit,
242 cbch_mobile_alloc := omit,
243 rest_octets := ''O
244 }
245 }
246}
247
248function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
249runs on test_CT {
250 log("Setting ", rsl_si_type, ": ", si_enc);
251 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
252}
253
254function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
255runs on test_CT {
256 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
257 log("Setting ", rsl_si_type, ": ", si_dec);
258 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
259}
260
Harald Welte505cf9b2018-09-15 17:47:23 +0300261friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100262 map(self:BTSVTY, system:BTSVTY);
263 f_vty_set_prompts(BTSVTY);
264 f_vty_transceive(BTSVTY, "enable");
265}
266
Harald Welte505cf9b2018-09-15 17:47:23 +0300267friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200268 map(self:BSCVTY, system:BSCVTY);
269 f_vty_set_prompts(BSCVTY, "OsmoBSC");
270 f_vty_transceive(BSCVTY, "enable");
271}
272
Harald Welte883340c2018-02-28 18:59:29 +0100273/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200274private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
275 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100276 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200277 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
278 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100279 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200280 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200281 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100282 }
283}
284
Harald Weltef26de0b2018-04-04 20:28:05 +0200285private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
286 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100287 timer T := 2.0;
288 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100289 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200290 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100291 return;
292 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200293 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100294
295 T.start;
296 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200297 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100298 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100300 }
301 }
302}
303
Harald Welte70767382018-02-21 12:16:40 +0100304/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100305function f_init(charstring id := "BTS-Test") runs on test_CT {
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100306 timer T := mp_ipa_up_timeout;
Harald Welte629cc6b2018-03-11 17:19:05 +0100307 g_AllChannels := {
308 /* TS 1..4: TCH/F */
309 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
310 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
311 /* TS 5: TCH/H */
312 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
313 /* TS 0: SDCCH/4 */
314 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
315 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
316 /* TS 6: SDCCH/8 */
317 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
318 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
319 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
320 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
321 };
322
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200323 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700324 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200325 g_AllChanTypes := {
326 /* TS 1..4: TCH/F */
327 valueof(ts_RslChanNr_Bm(1)),
328 /* TS 5: TCH/H */
329 valueof(ts_RslChanNr_Lm(5,1)),
330 /* TS 0: SDCCH/4 */
331 valueof(ts_RslChanNr_SDCCH4(0,2)),
332 /* TS 6: SDCCH/8 */
333 valueof(ts_RslChanNr_SDCCH8(6,4))
334 };
335 } else {
336 g_AllChanTypes := {
337 /* TS 1..4: TCH/F */
338 valueof(ts_RslChanNr_Bm(1)),
339 /* TS 0: SDCCH/4 */
340 valueof(ts_RslChanNr_SDCCH4(0,2)),
341 /* TS 6: SDCCH/8 */
342 valueof(ts_RslChanNr_SDCCH8(6,4))
343 };
344 }
Harald Welte70767382018-02-21 12:16:40 +0100345 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200346 T.start;
347 alt {
348 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
349 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200350 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Harald Welte83f6dbf2018-06-03 18:26:50 +0200351 }
352 }
Harald Welte2d142592018-02-25 13:19:44 +0100353 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100354 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200355 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100356
357 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100358 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
359 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
360 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
361 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100362
Harald Weltef26de0b2018-04-04 20:28:05 +0200363 map(self:PCU, system:PCU);
364 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100365
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700366 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100367 var TrxcMessage ret;
368 /* start with a default moderate timing offset equalling TA=2 */
369 f_main_trxc_connect();
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700370 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
Harald Welte84271622018-03-10 17:21:03 +0100371 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200372
373 /* Wait some extra time to make sure the BTS emits a stable carrier.
374 * (this is only relevant when running the tests with a physical BTS.) */
375 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100376}
377
Harald Welte68e495b2018-02-25 00:05:57 +0100378/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
379function f_init_l1ctl() runs on test_CT {
380 map(self:L1CTL, system:L1CTL);
381 f_connect_reset(L1CTL);
382}
383
Harald Welte70767382018-02-21 12:16:40 +0100384type function void_fn(charstring id) runs on ConnHdlr;
385
386/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200387function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100388runs on test_CT return ConnHdlr {
389 var charstring id := testcasename();
390 var ConnHdlr vc_conn;
391
392 vc_conn := ConnHdlr.create(id);
393 /* connect to RSL Emulation main component */
394 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
395 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200396 if (pcu_comp) {
397 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
398 * it from the test_CT and connect it to the component. This obviously only
399 * works for one component, i.e. no concurrency */
400 unmap(self:PCU, system:PCU);
401 map(vc_conn:PCU, system:PCU);
402 }
Harald Welte70767382018-02-21 12:16:40 +0100403
404 vc_conn.start(f_handler_init(fn, id, pars));
405 return vc_conn;
406}
407
Harald Welte7484fc42018-02-24 14:09:45 +0100408template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
409 streamId := sid,
410 rsl := rsl
411}
412
413template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
414 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
415 streamId := sid,
416 rsl := rsl
417}
418
Harald Welte70767382018-02-21 12:16:40 +0100419private altstep as_Tguard() runs on ConnHdlr {
420 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200421 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100422 }
423}
424
Harald Welte505cf9b2018-09-15 17:47:23 +0300425friend function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200426 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100427}
428
429private function f_trxc_connect() runs on ConnHdlr {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700430 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte70767382018-02-21 12:16:40 +0100431 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700432 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Weltea4d8f352018-03-01 15:47:20 +0100433 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200434 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200435 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +0200436 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700437 g_bts_trxc_conn_id := res.connId;
Harald Welte70767382018-02-21 12:16:40 +0100438}
439
440private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100441 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700442 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100443}
444
445private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100446 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700447 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100448}
449
450/* first function started in ConnHdlr component */
451private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
452runs on ConnHdlr {
453 g_pars := pars;
454 g_chan_nr := pars.chan_nr;
455
456 map(self:L1CTL, system:L1CTL);
457 f_connect_reset(L1CTL);
458
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700459 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100460 f_trxc_connect();
461 }
Harald Welte70767382018-02-21 12:16:40 +0100462
463 g_Tguard.start(pars.t_guard);
464 activate(as_Tguard());
465
466 f_rslem_register(0, pars.chan_nr);
467
468 /* call the user-supplied test case function */
469 fn.apply(id);
470}
471
Harald Welteb1726c92018-03-30 11:56:38 +0200472function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
473 boolean ignore_other := false)
474runs on ConnHdlr return RSL_Message {
475 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100476 timer T := 3.0;
477 RSL.send(tx);
478 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100479 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200480 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100481 T.stop;
482 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100483 }
Harald Welte1eba3742018-02-25 12:48:14 +0100484 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200485 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100486 }
Harald Welte21240e62018-03-11 21:43:35 +0100487 [not ignore_other] as_l1_sacch();
488 [not ignore_other] as_meas_res();
489 [not ignore_other] as_l1_dcch();
490 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200491 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100492 }
Harald Welte21240e62018-03-11 21:43:35 +0100493 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100494 }
Harald Welteb1726c92018-03-30 11:56:38 +0200495 return rx;
496}
497
498function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
499 boolean ignore_other := false)
500runs on ConnHdlr {
501 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100502}
503
Harald Welte8b01c792019-05-19 22:51:25 +0200504function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
505 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
506 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200507 if (encr_enable) {
508 /* append encryption related IEs, if requested */
509 var RSL_IE_EncryptionInfo encr_info;
510 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
511 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
512encr_info})) };
513 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200514 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200515 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100516}
517
Harald Welte70767382018-02-21 12:16:40 +0100518function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100519 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 +0100520 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100521}
522
Harald Welte70767382018-02-21 12:16:40 +0100523private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
524 template RSL_IE_ChannelMode chan_mode,
525 float t_guard := 20.0) := {
526 chan_nr := valueof(chan_nr),
527 chan_mode := valueof(chan_mode),
528 t_guard := t_guard,
529 l1_pars := {
530 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100531 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100532 meas_ul := {
533 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200534 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100535 rxqual := 0
536 },
537 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200538 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100539 rxqual := 0
540 }
541 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200542 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100543 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200544 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200545 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100546 },
Harald Weltee613f962018-04-18 22:38:16 +0200547 spec := omit,
548 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100549}
550
Harald Welte93640c62018-02-25 16:59:33 +0100551/***********************************************************************
552 * Channel Activation / Deactivation
553 ***********************************************************************/
554
Harald Welte70767382018-02-21 12:16:40 +0100555/* Stress test: Do 500 channel activations/deactivations in rapid succession */
556function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
557 for (var integer i := 0; i < 500; i := i+1) {
558 f_rsl_chan_act(g_pars.chan_mode);
559 f_rsl_chan_deact();
560 }
561 setverdict(pass);
562}
563testcase TC_chan_act_stress() runs on test_CT {
564 var ConnHdlr vc_conn;
565 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
566 f_init(testcasename());
567 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
568 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200569 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100570}
571
572/* Test if re-activation of an already active channel fails as expected */
573function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
574 f_rsl_chan_act(g_pars.chan_mode);
575 /* attempt to activate the same lchan again -> expect reject */
576 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
577 alt {
578 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200579 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100580 }
581 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
582 setverdict(pass);
583 }
584 }
585 f_rsl_chan_deact();
586}
587testcase TC_chan_act_react() runs on test_CT {
588 var ConnHdlr vc_conn;
589 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100590 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100591 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
592 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200593 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100594}
595
596/* Attempt to de-activate a channel that's not active */
597function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
598 timer T := 3.0;
599 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
600 T.start;
601 alt {
602 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
603 setverdict(pass);
604 }
605 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200606 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100607 }
608 }
609}
610testcase TC_chan_deact_not_active() runs on test_CT {
611 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100612 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100613 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
614 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200615 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100616}
617
618/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
619function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
620 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
621 alt {
622 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200623 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100624 }
625 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
626 setverdict(pass);
627 }
628 }
629}
630private type record WrongChanNrCase {
631 RslChannelNr chan_nr,
632 charstring description
633}
634private type record of WrongChanNrCase WrongChanNrCases;
635private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
636 chan_nr := chan_nr,
637 description := desc
638}
639
640testcase TC_chan_act_wrong_nr() runs on test_CT {
641 var ConnHdlr vc_conn;
642 var ConnHdlrPars pars;
643
Harald Welte294b0a22018-03-10 23:26:48 +0100644 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100645
646 var WrongChanNrCases wrong := {
647 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
648 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
649 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
650 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
651 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
652 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
653 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
654 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
655 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
656 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
657 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
658 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
659 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
660 };
661
662 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
663 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
664 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
665 vc_conn.done;
666 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200667 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100668}
669
Harald Weltee613f962018-04-18 22:38:16 +0200670/* execute the same callback function on a variety of logical channels */
671private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
672 var ConnHdlr vc_conn;
673 f_init(testcasename());
674
675 /* test on each of the channels we have */
676 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
677 pars.chan_nr := valueof(g_AllChanTypes[i]);
678
679 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
680 vc_conn := f_start_handler(fn, pars);
681 vc_conn.done;
682 }
683
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200684 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200685}
686
Harald Welte93640c62018-02-25 16:59:33 +0100687/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100688 * SACCH handling
689 ***********************************************************************/
690
691private function f_exp_sacch(boolean exp) runs on ConnHdlr {
692 timer T_sacch := 3.0;
693 T_sacch.start;
694 alt {
695 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200696 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100697 }
698 [not exp] T_sacch.timeout {
699 setverdict(pass);
700 }
701 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
702 setverdict(pass);
703 }
704 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200705 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100706 }
707 [] L1CTL.receive { repeat; }
708 [] RSL.receive { repeat; }
709 }
710}
711
712/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
713private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
714 f_l1_tune(L1CTL);
715 RSL.clear;
716
717 /* activate the logical channel */
718 f_est_dchan();
719 L1CTL.clear;
720
721 /* check that SACCH actually are received as expected */
722 f_exp_sacch(true);
723
724 /* deactivate SACCH on the logical channel */
725 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
726 f_sleep(1.0);
727 L1CTL.clear;
728
729 /* check that no SACCH are received anymore */
730 f_exp_sacch(false);
731
732 /* release the channel */
733 f_rsl_chan_deact();
734 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
735}
736testcase TC_deact_sacch() runs on test_CT {
737 var ConnHdlr vc_conn;
738 var ConnHdlrPars pars;
739 f_init();
740 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
741 //for (var integer i := 0; i < 1; i := i+1) {
742 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
743 log(testcasename(), ": Starting for ", g_AllChannels[i]);
744 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
745 vc_conn.done;
746 }
747 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200748 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100749}
750
Harald Welte55700662018-03-12 13:15:43 +0100751/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100752private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
753 var L1ctlDlMessage dl;
754 /* check that the specified SI5 value is actually sent */
755 timer T_sacch := 3.0;
756 L1CTL.clear;
757 T_sacch.start;
758 alt {
759 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
760 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
761 if (match(l3, l3_exp)) {
762 setverdict(pass);
763 } else {
764 repeat;
765 }
766 }
767 [] L1CTL.receive { repeat; }
768 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200769 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100770 }
771 }
772}
773
Harald Welte55700662018-03-12 13:15:43 +0100774/* verify that given SACCH payload is not present */
775private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
776 var L1ctlDlMessage dl;
777 /* check that the specified SI5 value is actually sent */
778 timer T_sacch := 3.0;
779 L1CTL.clear;
780 T_sacch.start;
781 alt {
782 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
783 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
784 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200785 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100786 } else {
787 repeat;
788 }
789 }
790 [] L1CTL.receive { repeat; }
791 [] T_sacch.timeout {
792 setverdict(pass);
793 }
794 }
795}
796
Harald Welte629cc6b2018-03-11 17:19:05 +0100797/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100798private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
799 /* Set a known default SACCH filling for SI5 */
800 var octetstring si5 := f_rnd_octstring(19);
801 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
802
803 f_l1_tune(L1CTL);
804 RSL.clear;
805
806 /* activate the logical channel */
807 f_est_dchan();
808
809 /* check that the specified SI5 value is actually sent */
810 f_sacch_present(si5);
811
812 /* release the channel */
813 RSL.clear;
814 f_rsl_chan_deact();
815 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
816}
817testcase TC_sacch_filling() runs on test_CT {
818 var ConnHdlr vc_conn;
819 var ConnHdlrPars pars;
820 f_init();
821 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
822 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
823 log(testcasename(), ": Starting for ", g_AllChannels[i]);
824 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
825 vc_conn.done;
826 }
827 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200828 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100829}
830
Harald Welte629cc6b2018-03-11 17:19:05 +0100831/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100832private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
833 /* Set a known default SACCH filling for SI5 */
834 var octetstring si5 := f_rnd_octstring(19);
835 var octetstring si5_diff := f_rnd_octstring(19);
836 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
837
838 f_l1_tune(L1CTL);
839 RSL.clear;
840
841 log("Activating channel, expecting standard SI5");
842 /* activate the logical channel */
843 f_est_dchan();
844 /* check that the specified SI5 value is actually sent */
845 f_sacch_present(si5);
846
847 /* set channel-specific different SI5 */
848 log("Setting channel specific SACCH INFO, expecting it");
849 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
850 /* check that the specified lchan-specific value is now used */
851 f_sacch_present(si5_diff);
852
853 /* deactivate the channel and re-activate it, this should result in default SI5 */
854 log("De-activating and re-activating channel, expecting standard SI5");
855 f_rsl_chan_deact();
856 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
857 /* Verify that the TRX-wide default SACCH filling is present again */
858 f_sacch_present(si5);
859
860 /* release the channel */
861 RSL.clear;
862 f_rsl_chan_deact();
863 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
864}
865testcase TC_sacch_info_mod() runs on test_CT {
866 var ConnHdlr vc_conn;
867 var ConnHdlrPars pars;
868 f_init();
869 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
870 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
871 log(testcasename(), ": Starting for ", g_AllChannels[i]);
872 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
873 vc_conn.done;
874 }
875 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200876 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100877}
878
Harald Welte075d84c2018-03-12 13:07:24 +0100879/* Test SACCH scheduling of multiple different SI message types */
880private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
881 var octetstring si5 := f_rnd_octstring(19);
882 var octetstring si5bis := f_rnd_octstring(19);
883 var octetstring si5ter := f_rnd_octstring(19);
884 var octetstring si6 := f_rnd_octstring(19);
885
886 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
887 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
888 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
889 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
890
891 f_l1_tune(L1CTL);
892 RSL.clear;
893
894 /* activate the logical channel */
895 f_est_dchan();
896 L1CTL.clear;
897
898 /* check that SACCH actually are received as expected */
899 f_sacch_present(si5);
900 f_sacch_present(si5bis);
901 f_sacch_present(si5ter);
902 f_sacch_present(si6);
903
904 /* release the channel */
905 f_rsl_chan_deact();
906 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
907}
908testcase TC_sacch_multi() runs on test_CT {
909 var ConnHdlr vc_conn;
910 var ConnHdlrPars pars;
911 f_init();
912 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
913 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
914 log(testcasename(), ": Starting for ", g_AllChannels[i]);
915 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
916 vc_conn.done;
917 }
918 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200919 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100920}
921
Harald Welte55700662018-03-12 13:15:43 +0100922/* Test if SACH information is modified as expected */
923private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
924 var octetstring si5 := f_rnd_octstring(19);
925 var octetstring si6 := f_rnd_octstring(19);
926
927 /* First, configure both SI5 and SI6 to be transmitted */
928 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
929 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
930
931 f_l1_tune(L1CTL);
932 RSL.clear;
933
934 /* activate the logical channel */
935 f_est_dchan();
936 L1CTL.clear;
937
938 /* check that SACCH actually are received as expected */
939 f_sacch_present(si5);
940 f_sacch_present(si6);
941
942 /* disable SI6 */
943 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
944
945 /* check that SI5 is still transmitted */
946 f_sacch_present(si5);
947 /* check if SI6 is now gone */
948 f_sacch_missing(si6);
949
950 /* release the channel */
951 f_rsl_chan_deact();
952 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
953}
954testcase TC_sacch_multi_chg() runs on test_CT {
955 var ConnHdlr vc_conn;
956 var ConnHdlrPars pars;
957 f_init();
958 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
959 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
960 log(testcasename(), ": Starting for ", g_AllChannels[i]);
961 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
962 vc_conn.done;
963 }
964 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200965 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +0100966}
967
Harald Weltec8d363c2019-05-19 20:36:48 +0200968/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
969private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
970 var octetstring si5 := f_rnd_octstring(19);
971 var octetstring si6 := f_rnd_octstring(19);
972 var octetstring si5_specific := f_rnd_octstring(19);
973 var octetstring si6_specific := f_rnd_octstring(19);
974
975 /* First, configure both SI5 and SI6 to be transmitted */
976 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
977 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
978
979 f_l1_tune(L1CTL);
980 RSL.clear;
981
982 /* activate channel with different SACCH filling */
983 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
984 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
985 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
986 }));
987 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
988 RSL_IE_Body:{sacch_info := sacch_info})) };
989 f_est_dchan(more_ies := addl_ies);
990
991 /* check that SACCH actually are received as expected */
992 f_sacch_present(si5_specific);
993 f_sacch_present(si6_specific);
994
995 /* release the channel */
996 f_rsl_chan_deact();
997 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
998}
999testcase TC_sacch_chan_act() runs on test_CT {
1000 var ConnHdlr vc_conn;
1001 var ConnHdlrPars pars;
1002 f_init();
1003
1004 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1005 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1006 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1007 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1008 vc_conn.done;
1009 }
1010 /* TODO: do the above in parallel, rather than sequentially? */
1011 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1012}
1013
Harald Welte8b01c792019-05-19 22:51:25 +02001014/* verify that SACCH DL transmission is started only if MS power IE present
1015 * see section 4.1.3 of 3GPP TS 48.058 */
1016private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1017 var octetstring si5 := f_rnd_octstring(19);
1018
1019 f_l1_tune(L1CTL);
1020 RSL.clear;
1021
1022 /* Step 1: Activate ASYNC HO channel without MS power IE */
1023
1024 /* Activate channel on BTS side */
1025 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1026 /* don't perform immediate assignment here, as we're testing non-IA case */
1027 /* enable dedicated mode */
1028 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1029
1030 /* Verify that no DL SACCH is being received */
1031 f_sacch_missing(?);
1032
1033 f_rsl_chan_deact();
1034 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1035
1036
1037 /* Step 2: Activate ASYNC HO channel with MS power IE */
1038
1039 /* Activate channel on BTS side */
1040 var RSL_IE_List addl_ies := {
1041 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1042 };
1043 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1044 /* don't perform immediate assignment here, as we're testing non-IA case */
1045 /* enable dedicated mode */
1046 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1047
1048 /* Verify that DL SACCH is being received */
1049 f_sacch_present(si5);
1050
1051 f_rsl_chan_deact();
1052 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1053}
1054testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1055 var ConnHdlr vc_conn;
1056 var ConnHdlrPars pars;
1057 f_init();
1058
1059 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1060 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1061 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1062 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1063 vc_conn.done;
1064 }
1065 /* TODO: do the above in parallel, rather than sequentially? */
1066 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1067}
1068
1069/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1070 * see section 4.1.4 of 3GPP TS 48.058 */
1071private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1072 var octetstring si5 := f_rnd_octstring(19);
1073 var RSL_IE_List addl_ies;
1074
1075 f_l1_tune(L1CTL);
1076 RSL.clear;
1077
1078 /* Step 1: Activate SYNC HO channel without MS power IE */
1079
1080 /* Activate channel on BTS side */
1081 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1082 /* don't perform immediate assignment here, as we're testing non-IA case */
1083 /* enable dedicated mode */
1084 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1085
1086 /* Verify that no DL SACCH is being received */
1087 f_sacch_missing(?);
1088
1089 f_rsl_chan_deact();
1090 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1091
1092
1093 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1094
1095 /* Activate channel on BTS side */
1096 addl_ies := {
1097 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1098 };
1099 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1100 /* don't perform immediate assignment here, as we're testing non-IA case */
1101 /* enable dedicated mode */
1102 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1103
1104 /* Verify that no DL SACCH is being received */
1105 f_sacch_missing(?);
1106
1107 f_rsl_chan_deact();
1108 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1109
1110
1111 /* Step 2b: Activate SYNC HO channel with TA IE */
1112
1113 /* Activate channel on BTS side */
1114 addl_ies := {
1115 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1116 };
1117 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1118 /* don't perform immediate assignment here, as we're testing non-IA case */
1119 /* enable dedicated mode */
1120 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1121
1122 /* Verify that no DL SACCH is being received */
1123 f_sacch_missing(?);
1124
1125 f_rsl_chan_deact();
1126 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1127
1128
1129 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1130
1131 /* Activate channel on BTS side */
1132 addl_ies := {
1133 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1134 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1135 };
1136 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1137 /* don't perform immediate assignment here, as we're testing non-IA case */
1138 /* enable dedicated mode */
1139 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1140
1141 /* Verify that DL SACCH is being received */
1142 f_sacch_present(si5);
1143
1144 f_rsl_chan_deact();
1145 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1146}
1147testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1148 var ConnHdlr vc_conn;
1149 var ConnHdlrPars pars;
1150 f_init();
1151
1152 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1153 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1154 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1155 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1156 vc_conn.done;
1157 }
1158 /* TODO: do the above in parallel, rather than sequentially? */
1159 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1160}
Harald Welte629cc6b2018-03-11 17:19:05 +01001161
1162
1163/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001164 * RACH Handling
1165 ***********************************************************************/
1166
Harald Welte8c24c2b2018-02-26 08:31:31 +01001167/* like L1SAP_IS_PACKET_RACH */
1168private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001169 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001170 return true;
1171 }
1172 return false;
1173}
1174
1175/* generate a random RACH for circuit-switched */
1176private function f_rnd_ra_cs() return OCT1 {
1177 var OCT1 ra;
1178 do {
1179 ra := f_rnd_octstring(1);
1180 } while (ra_is_ps(ra));
1181 return ra;
1182}
1183
Harald Welte883340c2018-02-28 18:59:29 +01001184/* generate a random RACH for packet-switched */
1185private function f_rnd_ra_ps() return OCT1 {
1186 var OCT1 ra;
1187 do {
1188 ra := f_rnd_octstring(1);
1189 } while (not ra_is_ps(ra));
1190 return ra;
1191}
1192
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001193/* generate a random 11-bit RA (packet-switched only) */
1194private function f_rnd_ra11_ps() return BIT11 {
1195 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1196 return int2bit(ra11, 11);
1197}
1198
Harald Welte8c24c2b2018-02-26 08:31:31 +01001199/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1200testcase TC_rach_content() runs on test_CT {
1201 f_init(testcasename());
1202 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001203 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001204
Harald Welte8c24c2b2018-02-26 08:31:31 +01001205 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001206 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001207 for (var integer i := 0; i < 1000; i := i+1) {
1208 var OCT1 ra := f_rnd_ra_cs();
1209 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1210 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001211 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001212 }
1213 fn_last := fn;
1214
1215 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001216 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001217 alt {
1218 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1219 T.stop;
1220 }
1221 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001222 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001223 }
1224 [] RSL_CCHAN.receive { repeat; }
1225 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001226 test_failed := true;
1227 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001228 }
1229 }
1230 }
Maxba06feb2019-03-05 10:52:46 +01001231 if (test_failed) {
1232 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001233 }
Maxba06feb2019-03-05 10:52:46 +01001234 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001235 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001236}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001237
1238/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1239testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001240 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001241 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001242 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001243 f_l1_tune(L1CTL);
1244
1245 var GsmFrameNumber fn_last := 0;
1246 for (var integer i := 0; i < 1000; i := i+1) {
1247 var OCT1 ra := f_rnd_ra_cs();
1248 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1249 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001250 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001251 }
1252 fn_last := fn;
1253 }
1254 var integer rsl_chrqd := 0;
1255 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001256 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001257 alt {
1258 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1259 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001260 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001261 repeat;
1262 }
1263 [] RSL_CCHAN.receive { repeat; }
1264 [] T.timeout { }
1265 }
1266 if (rsl_chrqd == 1000) {
1267 setverdict(pass);
1268 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001269 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001270 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001271 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001272}
1273
Harald Welte3453ab42019-05-24 21:19:58 +02001274private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1275 var charstring bts_str := "bts " & int2str(bts_nr);
1276 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1277}
1278
1279/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1280private template integer tr_rach_slots_per_interval := (90 .. 130);
1281
1282/* Expect 0 RACH load on an idle BTS that has just started up */
1283testcase TC_rach_load_idle_thresh0() runs on test_CT {
1284 var ASP_RSL_Unitdata rx_ud;
1285
1286 f_init_vty_bsc();
1287 /* send load indications even at 0% load */
1288 f_vty_load_ind_thresh(0);
1289 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1290 f_sleep(2.0);
1291
1292 f_init();
1293
1294 timer T := 5.0;
1295 T.start;
1296 alt {
1297 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
1298 setverdict(pass);
1299 repeat;
1300 }
1301 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1302 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1303 repeat;
1304 }
1305 [] RSL_CCHAN.receive {
1306 repeat;
1307 }
1308 [] T.timeout { }
1309 }
1310
1311 f_vty_load_ind_thresh(10);
1312 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1313}
1314
1315/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1316testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1317 var ASP_RSL_Unitdata rx_ud;
1318
1319 f_init_vty_bsc();
1320 f_init();
1321
1322 timer T := 5.0;
1323 T.start;
1324 alt {
1325 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1326 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1327 repeat;
1328 }
1329 [] RSL_CCHAN.receive {
1330 repeat;
1331 }
1332 [] T.timeout {
1333 setverdict(pass);
1334 }
1335 }
1336
1337 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1338}
1339
1340/* Expect 0 RACH load on an idle BTS that has just started up */
1341testcase TC_rach_load_count() runs on test_CT {
1342 var ASP_RSL_Unitdata rx_ud;
1343 var integer load_access_count := 0;
1344
1345 f_init_vty_bsc();
1346 /* send load indications even at 0% load */
1347 f_vty_load_ind_thresh(0);
1348 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1349 f_sleep(2.0);
1350 f_init();
1351
1352 f_init_l1ctl();
1353 f_sleep(1.0);
1354 f_l1_tune(L1CTL);
1355
1356 var GsmFrameNumber fn_last := 0;
1357 for (var integer i := 0; i < 1000; i := i+1) {
1358 var OCT1 ra := f_rnd_ra_cs();
1359 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1360 if (fn == fn_last) {
1361 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1362 }
1363 fn_last := fn;
1364 }
1365
1366 timer T := 5.0;
1367 T.start;
1368 alt {
1369 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
1370 -> value rx_ud {
1371 var RSL_IE_Body ie;
1372 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1373 load_access_count := load_access_count + ie.rach_load.access_count;
1374 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1375 setverdict(fail, "Access count cannot be < Busy count");
1376 }
1377 repeat;
1378 }
1379 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1380 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1381 repeat;
1382 }
1383 [] RSL_CCHAN.receive {
1384 repeat;
1385 }
1386 [] T.timeout { }
1387 }
1388 if (load_access_count == 1000) {
1389 setverdict(pass);
1390 } else {
1391 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1392 }
1393
1394 f_vty_load_ind_thresh(10);
1395 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1396}
1397
1398
1399
Harald Welte54a2a2d2018-02-26 09:14:05 +01001400private function f_main_trxc_connect() runs on test_CT {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001401 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001402 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001403 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Welted3a88a62018-03-01 16:04:52 +01001404 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001405 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001406 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +02001407 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001408 g_bts_trxc_conn_id := res.connId;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001409}
1410
1411private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001412 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001413 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001414 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001415 f_sleep(0.5);
1416
1417 /* Transmit RACH request + wait for confirmation */
1418 var OCT1 ra := f_rnd_ra_cs();
1419 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1420
1421 /* Check for expected result */
1422 timer T := 1.5;
1423 T.start;
1424 alt {
1425 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1426 setverdict(pass);
1427 }
1428 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001429 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001430 }
1431 [] RSL_CCHAN.receive { repeat; }
1432 [not expect_pass] T.timeout {
1433 setverdict(pass);
1434 }
1435 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001436 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001437 }
1438 }
1439}
1440
1441/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1442testcase TC_rach_max_ta() runs on test_CT {
1443 f_init(testcasename());
1444 f_init_l1ctl();
1445 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001446 f_sleep(1.0);
1447
1448 /* default max-ta is 63 (full range of GSM timing advance */
1449
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001450 /* We allow early arrival up to 2 symbols */
1451 f_rach_toffs(-1*256, true);
1452 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001453 f_rach_toffs(-10*256, false);
1454
1455 /* 0 / 32 / 63 bits is legal / permitted */
1456 f_rach_toffs(0, true);
1457 f_rach_toffs(32*256, true);
1458 f_rach_toffs(63*256, true);
1459
1460 /* more than 63 bits is not legal / permitted */
1461 f_rach_toffs(64*256, false);
1462 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001463 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001464}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001465
Harald Welte93640c62018-02-25 16:59:33 +01001466/***********************************************************************
1467 * Measurement Processing / Reporting
1468 ***********************************************************************/
1469
Harald Welte70767382018-02-21 12:16:40 +01001470template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1471 spare := '0'B,
1472 lpd := 0,
1473 sapi := sapi,
1474 c_r := c_r,
1475 ea := true
1476}
1477
Harald Welted879bd92018-03-12 15:01:23 +01001478template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001479 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001480 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001481 len := 0, /* overwritten */
1482 m := false,
1483 el := 1,
1484 payload := pl
1485}
1486
1487/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1488altstep as_l1_sacch() runs on ConnHdlr {
1489 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001490 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001491 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001492 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 +01001493 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001494 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001495
1496 var L1ctlDataReq data_req := {
1497 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1498 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1499 }
1500 log("Sending Measurement Report: ", data_req);
1501 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001502 repeat;
1503 }
1504}
1505
1506altstep as_l1_dcch() runs on ConnHdlr {
1507 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001508 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001509 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1510 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001511 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1512 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001513 repeat;
1514 }
1515}
1516
1517type record MeasElem {
1518 uint6_t rxlev,
1519 uint3_t rxqual
1520}
1521
1522type record MeasElemFS {
1523 MeasElem full,
1524 MeasElem sub
1525}
1526
1527type record ConnL1Pars {
1528 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001529 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001530 MeasElemFS meas_ul,
1531 int16_t timing_offset_256syms,
1532 uint5_t bs_power_level,
1533 uint5_t ms_power_level,
1534 uint8_t ms_actual_ta
1535}
1536
1537/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1538private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1539 return 63 + (toffs256s/256);
1540}
1541
Harald Welted5684392018-03-10 18:22:04 +01001542private function f_max(integer a, integer b) return integer {
1543 if (a > b) {
1544 return a;
1545 } else {
1546 return b;
1547 }
1548}
1549
1550private function f_min(integer a, integer b) return integer {
1551 if (a < b) {
1552 return a;
1553 } else {
1554 return b;
1555 }
1556}
1557
1558/* compute negative tolerance val-tolerance, ensure >= min */
1559private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1560 val := val - tolerance;
1561 return f_max(val, min);
1562}
1563
1564/* compute positive tolerance val+tolerance, ensure <= max */
1565private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1566 val := val + tolerance;
1567 return f_min(val, max);
1568}
1569
1570/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1571private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1572return template integer {
1573 var template integer ret;
1574 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1575 return ret;
1576}
1577
1578
Harald Welte70767382018-02-21 12:16:40 +01001579/* build a template for matching measurement results against */
1580private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1581 var ConnL1Pars l1p := g_pars.l1_pars;
1582 var template RSL_IE_UplinkMeas ul_meas := {
1583 len := 3,
1584 rfu := '0'B,
1585 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001586 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001587 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001588 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001589 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001590 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1591 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001592 supp_meas_info := omit
1593 };
Harald Welte685d5982018-02-27 20:42:05 +01001594 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001595 ul_meas.len := (3+8);
1596 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001597 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001598 toa256_min := ?,
1599 toa256_max := ?,
1600 toa256_std_dev := ?
1601 }
Harald Welte685d5982018-02-27 20:42:05 +01001602 }
Harald Welte70767382018-02-21 12:16:40 +01001603 var template RSL_IE_BS_Power bs_power := {
1604 reserved := 0,
1605 epc := false,
1606 fpc := false,
1607 power_level := l1p.bs_power_level
1608 };
1609 var template RSL_IE_L1Info l1_info := {
1610 ms_power_lvl := l1p.ms_power_level,
1611 fpc := false,
1612 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001613 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001614 };
1615 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001616 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001617 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1618 ?, t_toffs);
1619}
1620
1621/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001622altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001623 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001624 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001625 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1626 /* increment counter of next to-be-expected meas rep */
1627 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1628 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001629 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001630 repeat;
1631 }
1632 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001633 /* increment counter of next to-be-expected meas rep */
1634 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1635 if (g_first_meas_res) {
1636 g_first_meas_res := false;
1637 repeat;
1638 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001639 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001640 }
Harald Welte70767382018-02-21 12:16:40 +01001641 }
1642 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001643 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001644 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001645 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001646 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001647 }
1648}
1649
Harald Weltee613f962018-04-18 22:38:16 +02001650private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1651 select (rsl_alg_id) {
1652 case (RSL_ALG_ID_A5_0) { return 0; }
1653 case (RSL_ALG_ID_A5_1) { return 1; }
1654 case (RSL_ALG_ID_A5_2) { return 2; }
1655 case (RSL_ALG_ID_A5_3) { return 3; }
1656 case (RSL_ALG_ID_A5_4) { return 4; }
1657 case (RSL_ALG_ID_A5_5) { return 5; }
1658 case (RSL_ALG_ID_A5_6) { return 6; }
1659 case (RSL_ALG_ID_A5_7) { return 7; }
1660 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001661 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1662 /* Make compiler happy by calling mtc.stop here. It is already
1663 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001664 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001665 }
1666 }
1667}
1668
1669private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1670 select (rsl_alg_id) {
1671 case (RSL_ALG_ID_A5_1) { return '000'B; }
1672 case (RSL_ALG_ID_A5_2) { return '001'B; }
1673 case (RSL_ALG_ID_A5_3) { return '010'B; }
1674 case (RSL_ALG_ID_A5_4) { return '011'B; }
1675 case (RSL_ALG_ID_A5_5) { return '100'B; }
1676 case (RSL_ALG_ID_A5_6) { return '101'B; }
1677 case (RSL_ALG_ID_A5_7) { return '110'B; }
1678 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1680 /* Make compiler happy by calling mtc.stop here. It is already
1681 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001682 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001683 }
1684 }
1685}
1686
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001687/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1688private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1689 var GsmFrameNumber fn;
1690 timer T := 8.0;
1691
1692 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1693 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1694
1695 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1696 /* Send the actual RACH */
1697 fn := f_L1CTL_RACH(L1CTL, ra);
1698
1699 T.start;
1700 alt {
1701 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1702 [] T.timeout {
1703 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1704 }
1705 }
1706 T.stop
1707 return fn;
1708}
Harald Weltee613f962018-04-18 22:38:16 +02001709
Harald Welte70767382018-02-21 12:16:40 +01001710/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001711private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001712 var GsmFrameNumber fn;
1713 var ImmediateAssignment imm_ass;
1714 var integer ra := 23;
1715
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001716 /* Send RACH request and wait for ChanReq */
1717 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001718
1719 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001720 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001721
1722 /* Send IMM.ASS via CCHAN */
1723 var ChannelDescription ch_desc := {
1724 chan_nr := g_pars.chan_nr,
1725 tsc := 7,
1726 h := false,
1727 arfcn := mp_trx0_arfcn,
1728 maio_hsn := omit
1729 };
1730 var MobileAllocation ma := {
1731 len := 0,
1732 ma := ''B
1733 };
1734 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1735 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1736
1737 /* receive IMM.ASS on MS side */
1738 var ImmediateAssignment ia_um;
1739 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1740 /* enable dedicated mode */
1741 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001742 /* enable encryption, if requested */
1743 if (encr_enable) {
1744 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1745 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1746 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001747
1748 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001749}
1750
1751/* establish DChan, verify existance + contents of measurement reports */
1752function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001753 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001754 RSL.clear;
1755
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001756 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001757 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001758 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1759 }
Harald Welte70767382018-02-21 12:16:40 +01001760
1761 f_est_dchan();
1762
1763 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1764 * RSL measurement reports on Abis side */
1765 timer T := 8.0;
1766 T.start;
1767 alt {
1768 [] as_l1_sacch();
1769 [] as_meas_res();
1770 [] as_l1_dcch();
1771 [] L1CTL.receive { repeat; }
1772 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001773 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001774 * of any earlier errors, so if we reach this timeout, we're good */
1775 setverdict(pass);
1776 }
1777 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001778 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001779 }
1780 }
1781 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001782 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001783}
Harald Welte0472ab42018-03-12 15:02:26 +01001784
Harald Welte70767382018-02-21 12:16:40 +01001785testcase TC_meas_res_sign_tchf() runs on test_CT {
1786 var ConnHdlr vc_conn;
1787 var ConnHdlrPars pars;
1788 f_init(testcasename());
1789 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1790 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1791 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1792 vc_conn.done;
1793 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001794 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001795}
1796testcase TC_meas_res_sign_tchh() runs on test_CT {
1797 var ConnHdlr vc_conn;
1798 var ConnHdlrPars pars;
1799 f_init(testcasename());
1800 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1801 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1802 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1803 vc_conn.done;
1804 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001805 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001806}
1807testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1808 var ConnHdlr vc_conn;
1809 var ConnHdlrPars pars;
1810 f_init(testcasename());
1811 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1812 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1813 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1814 vc_conn.done;
1815 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001816 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001817}
1818testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1819 var ConnHdlr vc_conn;
1820 var ConnHdlrPars pars;
1821 f_init(testcasename());
1822 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1823 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1824 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1825 vc_conn.done;
1826 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001827 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001828}
Harald Welte685d5982018-02-27 20:42:05 +01001829testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1830 var ConnHdlr vc_conn;
1831 var ConnHdlrPars pars;
1832 f_init(testcasename());
1833 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1834 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1835 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1836 pars.l1_pars.toa256_enabled := true;
1837 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1838 vc_conn.done;
1839 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001840 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01001841}
1842
Philipp Maier4d1e9c92018-12-20 11:11:56 +01001843/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
1844 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
1845function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
1846 var L1ctlDlMessage l1_dl;
1847 var RSL_IE_MS_Power ms_power;
1848 var RSL_Message rsl;
1849 var uint5_t power_level := 0;
1850
1851 f_l1_tune(L1CTL);
1852 RSL.clear;
1853
1854 f_est_dchan();
1855
1856 ms_power.reserved := 0;
1857 ms_power.fpc_epc := false;
1858
1859 /* Send the first power control command. This will disable any BTS/TRX
1860 * internal power control and switch the MS (which is not in scope of
1861 * this test) to a constant power level. We start with a power level
1862 * of 0 */
1863 ms_power.power_level := power_level;
1864 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1865 RSL.send(rsl);
1866
1867 alt {
1868
1869 /* Pick all SACCH blocks for checking */
1870 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1871
1872 /* The first byte of the L1 header contains the power level.
1873 * The reserved bits and the fpc bit is set to 0, so we may
1874 * compare directly. */
1875 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
1876 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
1877 }
1878
1879 /* Signal a new power level via RSL for the next turn. */
1880 if (power_level < 31) {
1881 power_level := power_level + 1;
1882 ms_power.power_level := power_level;
1883 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1884 RSL.send(rsl);
1885 repeat;
1886 }
1887
1888 }
1889
1890 /* Ignore all other blocks */
1891 [] L1CTL.receive { repeat; }
1892
1893 }
1894
1895 f_rsl_chan_deact();
1896 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1897
1898 setverdict(pass);
1899}
1900
1901testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
1902 var ConnHdlr vc_conn;
1903 var ConnHdlrPars pars;
1904 f_init(testcasename());
1905
1906 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1907 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1908 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
1909 vc_conn.done;
1910 }
1911 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1912}
Harald Welte70767382018-02-21 12:16:40 +01001913
Eric Wild6833cc92019-05-23 19:34:44 +02001914/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
1915TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
1916function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
1917 var L1ctlDlMessage l1_dl;
1918 var uint5_t ta_to_test := 16;
1919
1920
1921 f_l1_tune(L1CTL);
1922 RSL.clear;
1923
1924 /* tell fake_trx to use a given timing offset for all bursts */
1925 f_trx_fake_toffs256(ta_to_test*256);
1926
1927 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
1928
1929
1930 alt {
1931
1932 /* Pick all SACCH blocks for checking */
1933 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1934
1935 /* The second byte of the L1 header contains the TA. */
1936 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
1937 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
1938 }
1939
1940 }
1941
1942 /* Ignore all other blocks */
1943 [] L1CTL.receive { repeat; }
1944
1945 }
1946
1947 f_rsl_chan_deact();
1948 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1949
1950 setverdict(pass);
1951}
1952
1953testcase TC_rsl_chan_initial_ta() runs on test_CT {
1954 var ConnHdlr vc_conn;
1955 var ConnHdlrPars pars;
1956 f_init(testcasename());
1957 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1958 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars);
1959 vc_conn.done;
1960 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1961}
1962
Harald Welte0472ab42018-03-12 15:02:26 +01001963/* 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 +01001964private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001965 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001966 RSL.clear;
1967
1968 f_est_dchan();
1969 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001970 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001971
1972 timer T := 40.0;
1973 T.start;
1974 alt {
1975 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1976 setverdict(pass)
1977 }
1978 [] RSL.receive { repeat };
1979 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001980 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01001981 }
1982 }
1983 f_rsl_chan_deact();
1984}
1985testcase TC_conn_fail_crit() runs on test_CT {
1986 var ConnHdlr vc_conn;
1987 var ConnHdlrPars pars;
1988 f_init(testcasename());
1989 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1990 pars.t_guard := 60.0;
1991 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1992 vc_conn.done;
1993}
1994
Harald Welte93640c62018-02-25 16:59:33 +01001995/***********************************************************************
1996 * Paging
1997 ***********************************************************************/
1998
Harald Welte68e495b2018-02-25 00:05:57 +01001999function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
2000 if (tmsi == 'FFFFFFFF'O) {
2001 return true;
2002 } else {
2003 return false;
2004 }
2005}
Harald Welte70767382018-02-21 12:16:40 +01002006
Philipp Maier82cb0b12018-08-31 14:41:39 +02002007type record allowedFn { integer frame_nr }
2008template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2009template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2010template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2011template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2012template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2013template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2014template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2015template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2016function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2017{
2018 var integer frame_nr_51;
2019 frame_nr_51 := frame_nr mod 51
2020
2021 var allowedFn fn_check;
2022 fn_check.frame_nr := frame_nr_51;
2023
2024 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002025 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002026 return;
2027 }
2028
2029 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2030 return;
2031 }
2032 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2033 return;
2034 }
2035 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2036 return;
2037 }
2038 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2039 return;
2040 }
2041 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2042 return;
2043 }
2044 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2045 return;
2046 }
2047 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2048 return;
2049 }
2050 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2051 return;
2052 }
2053
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002054 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002055 return;
2056}
2057
2058altstep 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 +01002059runs on test_CT {
2060 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002061 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002062 repeat;
2063 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002064 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002065 var octetstring without_plen :=
2066 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2067 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002068
2069 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2070
Harald Welte68e495b2018-02-25 00:05:57 +01002071 if (match(rr, tr_PAGING_REQ1)) {
2072 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2073 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2074 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
2075 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2076 }
2077 } else if (match(rr, tr_PAGING_REQ2)) {
2078 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2079 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2080 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2081 }
2082 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2083 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2084 }
2085 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
2086 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2087 }
2088 } else if (match(rr, tr_PAGING_REQ3)) {
2089 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2090 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2091 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2092 }
2093 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2094 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2095 }
2096 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2097 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2098 }
2099 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2100 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2101 }
2102 }
2103 repeat;
2104 }
2105}
2106
2107type record PagingTestCfg {
2108 boolean combined_ccch,
2109 integer bs_ag_blks_res,
2110 float load_factor,
2111 boolean exp_load_ind,
2112 boolean exp_overload,
2113 boolean use_tmsi
2114}
2115
2116type record PagingTestState {
2117 integer num_paging_sent,
2118 integer num_paging_rcv_msgs,
2119 integer num_paging_rcv_ids,
2120 integer num_overload
2121}
2122
2123/* receive + ignore RSL RF RES IND */
2124altstep as_rsl_res_ind() runs on test_CT {
2125 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
2126 repeat;
2127 }
2128}
2129
2130/* Helper function for paging related testing */
2131private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
2132 f_init(testcasename());
2133 f_init_l1ctl();
2134 f_l1_tune(L1CTL);
2135
2136 var PagingTestState st := {
2137 num_paging_sent := 0,
2138 num_paging_rcv_msgs := 0,
2139 num_paging_rcv_ids := 0,
2140 num_overload := 0
2141 };
2142
2143 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2144 var float max_pch_imsi_per_sec;
2145 if (cfg.use_tmsi) {
2146 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2147 } else {
2148 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2149 }
2150 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2151 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002152 var float time_total := 20.0;
2153 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2154 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002155
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002156 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2157 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002158
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002159 timer T_itv := 0.0;
2160 T_itv.start;
2161 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002162 alt {
2163 /* check for presence of CCCH LOAD IND (paging load) */
2164 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
2165 st.num_overload := st.num_overload + 1;
2166 repeat;
2167 }
2168 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002169 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01002170 }
2171 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
2172 log("Rx LOAD_IND");
2173 /* FIXME: analyze/verify interval + contents */
2174 repeat;
2175 }
2176 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02002177 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002178 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002179 [] T_itv.timeout {
2180 /* Send paging cmds based on elapsed time */
2181 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
2182 while (st.num_paging_sent < new_sent) {
2183 /* build mobile Identity */
2184 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2185 if (cfg.use_tmsi) {
2186 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2187 } else {
2188 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
2189 }
2190 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2191 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2192
2193 /* Send RSL PAGING COMMAND */
2194 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
2195
2196 st.num_paging_sent := st.num_paging_sent + 1;
2197 }
2198 if (st.num_paging_sent < pkt_total) {
2199 /* Wait for interval to next PAGING COMMAND */
2200 var float time_now := T_total.read;
2201 var float next_sched := int2float(st.num_paging_sent)*interval;
2202 if (next_sched > time_now) {
2203 T_itv.start(next_sched - time_now);
2204 } else {
2205 T_itv.start(0.0);
2206 }
2207 } else {
2208 /* We are done, no need to keep counting */
2209 T_total.stop;
2210 }
2211 }
2212 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01002213 [] as_rsl_res_ind();
2214 }
2215 }
2216
2217 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
2218 timer T_wait := 18.0;
2219 T_wait.start;
2220 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02002221 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002222 [] L1CTL.receive { repeat; }
2223 /* 65535 == empty paging queue, we can terminate*/
2224 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
2225 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
2226 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002227 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01002228 }
2229 [] as_rsl_res_ind();
2230 }
2231
2232 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
2233 " rcvd_ids=", st.num_paging_rcv_ids);
2234 return st;
2235}
2236
2237/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
2238 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2239 * - that CCCH LOAD IND (PCH) are being generated
2240 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2241testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002242 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002243 var PagingTestCfg cfg := {
2244 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002245 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002246 load_factor := 0.8,
2247 exp_load_ind := true,
2248 exp_overload := false,
2249 use_tmsi := false
2250 };
2251 var PagingTestState st := f_TC_paging(cfg);
2252 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002253 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2254 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002255 } else {
2256 setverdict(pass);
2257 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002258 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002259}
2260
2261/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
2262 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2263 * - that CCCH LOAD IND (PCH) are being generated
2264 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2265testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002266 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002267 var PagingTestCfg cfg := {
2268 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002269 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002270 load_factor := 0.8,
2271 exp_load_ind := true,
2272 exp_overload := false,
2273 use_tmsi := true
2274 };
2275 var PagingTestState st := f_TC_paging(cfg);
2276 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002277 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2278 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002279 } else {
2280 setverdict(pass);
2281 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002282 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002283}
2284
2285/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
2286 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2287 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2288 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2289testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002290 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002291 var PagingTestCfg cfg := {
2292 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002293 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002294 load_factor := 2.0,
2295 exp_load_ind := true,
2296 exp_overload := true,
2297 use_tmsi := false
2298 };
2299 var PagingTestState st := f_TC_paging(cfg);
2300 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
2301 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002302 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002303 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002304 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 +01002305 } else {
2306 setverdict(pass);
2307 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002308 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002309}
2310
2311/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
2312 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2313 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2314 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2315testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002316 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002317 var PagingTestCfg cfg := {
2318 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002319 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002320 load_factor := 2.0,
2321 exp_load_ind := true,
2322 exp_overload := true,
2323 use_tmsi := true
2324 };
2325 var PagingTestState st := f_TC_paging(cfg);
2326 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
2327 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002328 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002329 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002330 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 +01002331 } else {
2332 setverdict(pass);
2333 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002334 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002335}
2336
2337
Harald Welte93640c62018-02-25 16:59:33 +01002338/***********************************************************************
2339 * Immediate Assignment / AGCH
2340 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02002341const MobileAllocation c_MA_null := {
2342 len := 0,
2343 ma := ''B
2344}
Harald Welte93640c62018-02-25 16:59:33 +01002345
Harald Weltee8d750e2018-06-10 21:41:35 +02002346template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
2347 uint12_t arfcn := 871) := {
2348 chan_nr := chan_nr,
2349 tsc := tsc,
2350 h := false,
2351 arfcn := arfcn,
2352 maio_hsn := omit
2353}
2354
2355private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
2356 return int2str(num_tx) & " sent, "
2357 & int2str(num_rx) & " received, "
2358 & int2str(num_del) & " deleted";
2359}
2360
2361private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
2362 var L1ctlDlMessage l1_dl;
2363 timer T := 10.0;
2364 var integer num_tx := 0;
2365 var integer num_rx := 0;
2366 var integer num_del := 0;
2367 var charstring res_str;
2368 var float rx_ratio;
2369
Harald Welte68e495b2018-02-25 00:05:57 +01002370 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02002371 f_init_l1ctl();
2372 f_l1_tune(L1CTL);
2373
2374 for (var integer i := 0; i < num_total; i := i+1) {
2375 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
2376 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
2377 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01002378 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02002379 num_tx := num_tx+1;
2380 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01002381 }
2382 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02002383 T.start;
2384 alt {
2385 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
2386 num_del := num_del+1;
2387 repeat;
2388 }
2389 [] RSL_CCHAN.receive {
2390 repeat;
2391 }
2392 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
2393 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2394 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
2395 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
2396 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002397 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02002398 } else {
2399 num_rx := num_rx+1;
2400 }
2401 repeat;
2402 }
2403 [] L1CTL.receive { repeat; }
2404 [] T.timeout { }
2405 }
2406 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
2407 log("AGCH test: " & res_str);
2408 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002409 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002410 }
2411 rx_ratio := int2float(num_rx) / int2float(num_tx);
2412 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002413 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 +02002414 } else {
2415 setverdict(pass);
2416 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002417 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002418}
2419
Harald Weltee8d750e2018-06-10 21:41:35 +02002420/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
2421testcase TC_imm_ass_1000_20ms() runs on test_CT {
2422 f_TC_imm_ass(1000, 0.02, 0.25);
2423}
2424
2425/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
2426testcase TC_imm_ass_200_0ms() runs on test_CT {
2427 f_TC_imm_ass(200, 0.0, 0.05);
2428}
2429
2430/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
2431testcase TC_imm_ass_200_76ms() runs on test_CT {
2432 f_TC_imm_ass(150, 0.076, 1.00);
2433}
2434
2435
2436
Harald Welte48494ca2018-02-25 16:59:50 +01002437/***********************************************************************
2438 * BCCH
2439 ***********************************************************************/
2440
2441/* tuple of Frame Number + decoded SI */
2442type record SystemInformationFn {
2443 GsmFrameNumber frame_number,
2444 SystemInformation si
2445}
2446
2447/* an arbitrary-length vector of decoded SI + gsmtap header */
2448type record of SystemInformationFn SystemInformationVector;
2449
2450/* an array of SI-vectors indexed by TC value */
2451type SystemInformationVector SystemInformationVectorPerTc[8];
2452
2453/* determine if a given SI vector contains given SI type at least once */
2454function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2455 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2456 var integer fn_mod51 := arr[i].frame_number mod 51;
2457 if (not bcch_ext and fn_mod51 == 2 or
2458 bcch_ext and fn_mod51 == 6) {
2459 if (arr[i].si.header.message_type == key) {
2460 return true;
2461 }
2462 }
2463 }
2464 return false;
2465}
2466
2467/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2468function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2469 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002470 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002471 }
2472}
2473
2474/* check if a given SI vector contains given SI type at least once on any TC */
2475function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2476 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2477 if (f_si_vecslot_contains(arr[tc], key) or
2478 f_si_vecslot_contains(arr[tc], key, true)) {
2479 return true;
2480 }
2481 }
2482 return false;
2483}
2484
2485/* determine if a given SI vector contains given SI type at least N of M times */
2486function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2487 var integer count := 0;
2488 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01002490 }
2491 for (var integer i:= 0; i < m; i := i + 1) {
2492 var integer fn_mod51 := arr[i].frame_number mod 51;
2493 if (not bcch_ext and fn_mod51 == 2 or
2494 bcch_ext and fn_mod51 == 6) {
2495 if (arr[i].si.header.message_type == key) {
2496 count := count + 1;
2497 }
2498 }
2499 }
2500 if (count >= n) {
2501 return true;
2502 } else {
2503 return false;
2504 }
2505}
2506
2507/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2508function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2509 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002510 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002511 }
2512}
2513
2514/* determine if a given SI vector contains given SI type at least once */
2515function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2516 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2517 var integer fn_mod51 := arr[i].frame_number mod 51;
2518 if (not bcch_ext and fn_mod51 == 2 or
2519 bcch_ext and fn_mod51 == 6) {
2520 if (arr[i].si.header.message_type != key) {
2521 return false;
2522 }
2523 }
2524 }
2525 return true;
2526}
2527
2528/* ensure a given TC slot of the SI vector contains only given SI type */
2529function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2530 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002531 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002532 }
2533}
2534
2535/* SI configuration of cell, against which we validate actual SI messages */
2536type set SystemInformationConfig {
2537 boolean bcch_extended,
2538 boolean si1_present,
2539 boolean si2bis_present,
2540 boolean si2ter_present,
2541 boolean si2quater_present,
2542 boolean si7_present,
2543 boolean si8_present,
2544 boolean si9_present,
2545 boolean si13_present,
2546 boolean si13alt_present,
2547 boolean si15_present,
2548 boolean si16_present,
2549 boolean si17_present,
2550 boolean si2n_present,
2551 boolean si21_present,
2552 boolean si22_present
2553}
2554
2555/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2556function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2557 var integer i;
2558 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2559 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002560 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01002561 }
2562 }
2563 if (cfg.si1_present) {
2564 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2565 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2566 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2567 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2568 /* make sure *ALL* contain SI1 */
2569 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2570 }
2571 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2572 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2573 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2574 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2575 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2576 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2577
2578 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2579 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2580 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2581 * consecutive occurrences of TC = 4. */
2582 if (cfg.si2bis_present and not cfg.si2ter_present) {
2583 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2584 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2585 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2586 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2587 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2588 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2589 }
2590
2591 if (cfg.si7_present or cfg.si8_present) {
2592 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2593 * if System Information type 4 does not contain all information needed for cell
2594 * selection and reselection. */
2595 if (not cfg.bcch_extended) {
2596 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2597 }
2598 if (cfg.si7_present) {
2599 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2600 }
2601 if (cfg.si8_present) {
2602 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2603 }
2604 }
2605
2606 if (cfg.si2quater_present) {
2607 /* iii) System information type 2 quater is sent if needed, as determined by the system
2608 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2609 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2610 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2611 * within any of 4 consecutive occurrences of TC = 5. */
2612 if (not (cfg.bcch_extended)) {
2613 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2614 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2615 } else {
2616 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2617 }
2618 } else {
2619 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2620 }
2621 }
2622 if (cfg.si9_present) {
2623 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2624 * in system information type 3 as defined in 3GPP TS 44.018. */
2625 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2626 }
2627 if (cfg.si13_present) {
2628 /* vii) System Information type 13 is only related to the GPRS service. System Information
2629 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2630 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2631 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2632 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2633 * within any of 4 consecutive occurrences of TC=4. */
2634 if (not cfg.bcch_extended) {
2635 log("not-bccch-extended");
2636 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2637 } else {
2638 log("bccch-extended");
2639 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2640 }
2641 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002642 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002643 }
2644 }
2645 if (cfg.si16_present or cfg.si17_present) {
2646 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2647 * should not be sent in a cell where network sharing is used (see rule xv). */
2648 if (cfg.si22_present) {
2649 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2650 }
2651 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002652 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002653 }
2654 if (not cfg.bcch_extended) {
2655 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2656 }
2657 if (cfg.si16_present) {
2658 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2659 }
2660 if (cfg.si17_present) {
2661 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2662 }
2663 }
2664
2665 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2666 * broadcast information. The frequency with which they are sent is determined by the
2667 * system operator. System Information type 9 identifies the scheduling of System
2668 * Information type 18 and 20 messages. */
2669
2670 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2671 * Information Type 19 is present, then its scheduling shall be indicated in System
2672 * Information Type 9. */
2673
2674 if (cfg.si15_present) {
2675 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2676 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2677 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2678 * 4 consecutive occurrences of TC = 1. */
2679 if (not cfg.bcch_extended) {
2680 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2681 } else {
2682 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2683 }
2684 }
2685 if (cfg.si13alt_present) {
2686 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2687 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2688 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2689 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2690 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2691 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2692 * of TC = 4. */
2693 if (cfg.si13_present) {
2694 testcase.stop("Error: Cannot have SI13alt and SI13");
2695 }
2696 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002697 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002698 }
2699 if (not cfg.bcch_extended) {
2700 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2701 } else {
2702 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2703 }
2704 }
2705 if (cfg.si2n_present) {
2706 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2707 * as determined by the system operator. In the case that the message is sent on the
2708 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2709 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2710 * consecutive occurrences of TC = 4. */
2711 if (not cfg.bcch_extended) {
2712 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2713 } else {
2714 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2715 }
2716 }
2717 if (cfg.si21_present) {
2718 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2719 * determined by the system operator. If Extended Access Barring is in use in the cell
2720 * then this message is sent at least once within any of 4 consecutive occurrences of
2721 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2722 * cell then this message shall only be sent on BCCH Ext. */
2723 if (not cfg.bcch_extended) {
2724 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2725 } else {
2726 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2727 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002728 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01002729 }
2730 }
2731 }
2732 if (cfg.si22_present) {
2733 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2734 * should not be sent in a cell where SoLSA is used (see rule viii). System
2735 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2736 * =2 and TC=6. */
2737 if (cfg.si16_present or cfg.si17_present) {
2738 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2739 }
2740 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2741 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002742 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002743 }
2744 if (not cfg.bcch_extended) {
2745 testcase.stop("Error: SI22 requires BCCH Extd!");
2746 } else {
2747 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2748 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2749 }
2750 }
2751}
2752
2753/* sample Systme Information for specified duration via L1CTL */
2754function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2755 timer T := duration;
2756 var SystemInformationVectorPerTc si_per_tc;
2757 var L1ctlDlMessage l1_dl;
2758
2759 /* initialize all per-TC vectors empty */
2760 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2761 si_per_tc[i] := {};
2762 }
2763
2764 /* flush all previous L1 queued msgs */
2765 pt.clear;
2766
2767 T.start;
2768 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002769 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002770 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2771 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2772 log("Ignoring non-RR SI ", l1_dl);
2773 repeat;
2774 }
2775 var SystemInformationFn sig := {
2776 frame_number := l1_dl.dl_info.frame_nr,
2777 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2778 }
2779 var integer tc := f_gsm_compute_tc(sig.frame_number);
2780 log("SI received at TC=", tc, ": ", sig.si);
2781 /* append to the per-TC bucket */
2782 si_per_tc[tc] := si_per_tc[tc] & { sig };
2783 repeat;
2784 }
2785 [] pt.receive { repeat; }
2786 [] T.timeout { }
2787 }
2788
2789 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2790 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2791 }
2792 log("si_per_tc=", si_per_tc);
2793 return si_per_tc;
2794}
2795
2796/* helper function: Set given SI via RSL + validate scheduling.
2797 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2798function f_TC_si_sched() runs on test_CT {
2799 var SystemInformationVectorPerTc si_per_tc;
2800 f_init_l1ctl();
2801 f_l1_tune(L1CTL);
2802
2803 /* Sample + Validate Scheduling */
2804 si_per_tc := f_l1_sample_si(L1CTL);
2805 f_validate_si_scheduling(si_cfg, si_per_tc);
2806
2807 setverdict(pass);
2808}
2809
2810testcase TC_si_sched_default() runs on test_CT {
2811 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002812 /* 2+3+4 are mandatory and set in f_init() */
2813 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002814 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01002815}
2816
2817testcase TC_si_sched_1() runs on test_CT {
2818 f_init();
2819 si_cfg.si1_present := true;
2820 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002821 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002822 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002823}
2824
2825testcase TC_si_sched_2bis() runs on test_CT {
2826 f_init();
2827 si_cfg.si2bis_present := true;
2828 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2829 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002830 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002831}
2832
2833testcase TC_si_sched_2ter() runs on test_CT {
2834 f_init();
2835 si_cfg.si2ter_present := true;
2836 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2837 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002838 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002839}
2840
2841testcase TC_si_sched_2ter_2bis() runs on test_CT {
2842 f_init();
2843 si_cfg.si2bis_present := true;
2844 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2845 si_cfg.si2ter_present := true;
2846 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2847 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002848 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002849}
2850
2851testcase TC_si_sched_2quater() runs on test_CT {
2852 f_init();
2853 si_cfg.si2quater_present := true;
2854 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2855 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002856 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002857}
2858
2859testcase TC_si_sched_13() runs on test_CT {
2860 f_init();
2861 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002862 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002863 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002864 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002865}
2866
2867testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2868 f_init();
2869 si_cfg.si2bis_present := true;
2870 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2871 si_cfg.si2ter_present := true;
2872 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2873 si_cfg.si2quater_present := true;
2874 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2875 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002876 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002877 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002878 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002879}
2880
2881
Harald Welte68e495b2018-02-25 00:05:57 +01002882testcase TC_bcch_info() runs on test_CT {
2883 f_init(testcasename());
2884 /* FIXME: enable / disable individual BCCH info */
2885 //ts_RSL_BCCH_INFO(si_type, info);
2886 /* expect no ERROR REPORT after either of them *
2887 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002888 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002889}
2890
Harald Welte93640c62018-02-25 16:59:33 +01002891/***********************************************************************
2892 * Low-Level Protocol Errors / ERROR REPORT
2893 ***********************************************************************/
2894
Harald Welte01d982c2018-02-25 01:31:40 +01002895private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2896 timer T := 5.0;
2897 T.start;
2898 alt {
2899 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2900 setverdict(pass);
2901 }
2902 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002903 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002904 }
2905 [] RSL_CCHAN.receive {
2906 repeat;
2907 }
2908 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002909 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002910 }
2911 }
2912}
2913
2914/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2915testcase TC_rsl_protocol_error() runs on test_CT {
2916 f_init(testcasename());
2917 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2918 rsl.ies := omit;
2919 RSL_CCHAN.send(ts_RSL_UD(rsl));
2920
2921 f_exp_err_rep(RSL_ERR_PROTO);
2922}
2923
2924/* Provoke a mandatory IE error and match on ERROR REPORT */
2925testcase TC_rsl_mand_ie_error() runs on test_CT {
2926 f_init(testcasename());
2927
2928 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2929 rsl.ies := { rsl.ies[0] };
2930 RSL_CCHAN.send(ts_RSL_UD(rsl));
2931
2932 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2933}
2934
2935/* Provoke an IE content error and match on ERROR REPORT */
2936testcase TC_rsl_ie_content_error() runs on test_CT {
2937 f_init(testcasename());
2938 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2939 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2940 RSL_CCHAN.send(ts_RSL_UD(rsl));
2941
2942 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2943}
2944
Harald Welteee25aae2019-05-19 14:32:37 +02002945/* attempt to activate channel with wrong RSL Message Discriminator IE */
2946function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
2947 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
2948 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
2949 RSL.send(rsl);
2950 f_rslem_unregister(0, g_chan_nr);
2951}
2952testcase TC_err_rep_wrong_mdisc() runs on test_CT {
2953 var ConnHdlr vc_conn;
2954 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
2955
2956 f_init(testcasename());
2957
2958 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
2959 vc_conn.done;
2960 f_exp_err_rep(RSL_ERR_MSG_DISCR);
2961
2962 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2963}
2964
2965/* Send messages with wrong message type */
2966function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
2967 var template (value) RSL_Message rsl_tx;
2968 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
2969 rsl_tx.msg_type := RSL_MT_NOT_CMD;
2970 RSL.send(rsl_tx);
2971 f_rslem_unregister(0, g_chan_nr);
2972}
2973function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
2974 var template (value) RSL_Message rsl_tx;
2975 /* we first have to activate the dedicated channel */
2976 f_rsl_chan_act(g_pars.chan_mode);
2977 /* ... to then send an invalid RLL message */
2978 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
2979 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
2980 RSL.send(rsl_tx);
2981 f_rslem_unregister(0, g_chan_nr);
2982}
2983testcase TC_err_rep_wrong_msg_type() runs on test_CT {
2984 var ConnHdlr vc_conn;
2985 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
2986 var template (value) RSL_Message rsl_tx;
2987
2988 f_init(testcasename());
2989
2990 /* Common Channel with wrong message type */
2991 RSL_CCHAN.clear;
2992 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2993 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
2994 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
2995 f_exp_err_rep(RSL_ERR_MSG_TYPE);
2996
2997 /* TRX Management */
2998 RSL_CCHAN.clear;
2999 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
3000 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
3001 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3002 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3003
3004 /* Dedicated Channel */
3005 RSL_CCHAN.clear;
3006 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3007 vc_conn.done;
3008 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3009
3010 /* RLL */
3011 RSL_CCHAN.clear;
3012 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3013 vc_conn.done;
3014 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3015}
3016
3017/* Send messages in wrong sequence (RLL to an inactive lchan) */
3018function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3019 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3020 f_rslem_unregister(0, g_chan_nr);
3021}
3022testcase TC_err_rep_wrong_sequence() runs on test_CT {
3023 var ConnHdlr vc_conn;
3024 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3025
3026 f_init(testcasename());
3027
3028 RSL_CCHAN.clear;
3029 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3030 vc_conn.done;
3031 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3032}
3033
Harald Welte93640c62018-02-25 16:59:33 +01003034/***********************************************************************
3035 * IPA CRCX/MDCX/DLCS media stream handling
3036 ***********************************************************************/
3037
Harald Weltea871a382018-02-25 02:03:14 +01003038/* Send IPA DLCX to inactive lchan */
3039function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003040 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3041 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003042}
3043testcase TC_ipa_dlcx_not_active() runs on test_CT {
3044 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3045 f_init(testcasename());
3046 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3047 vc_conn.done;
3048}
Harald Welte68e495b2018-02-25 00:05:57 +01003049
Harald Weltea3f1df92018-02-25 12:49:55 +01003050/* Send IPA CRCX twice to inactive lchan */
3051function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3052 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3053 "IPA CRCX ACK");
3054 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3055 "IPA CRCX NACK");
3056}
3057testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3058 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3059 f_init(testcasename());
3060 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3061 vc_conn.done;
3062}
3063
3064/* Regular sequence of CRCX/MDCX/DLCX */
3065function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3066 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3067 "IPA CRCX ACK");
3068 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3069 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3070 var uint7_t rtp_pt2 := f_rnd_int(127);
3071 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3072 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3073 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3074 "IPA MDCX ACK");
3075 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3076 "IPA DLCX ACK");
3077}
3078testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3079 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3080 f_init(testcasename());
3081 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3082 vc_conn.done;
3083}
3084
Harald Welte3ae11da2018-02-25 13:36:06 +01003085/* Sequence of CRCX, 2x MDCX, DLCX */
3086function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3087 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3088 "IPA CRCX ACK");
3089 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3090 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3091 var uint7_t rtp_pt2 := f_rnd_int(127);
3092 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3093 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3094 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3095 "IPA MDCX ACK");
3096 /* Second MDCX */
3097 remote_ip := f_rnd_int(c_UINT32_MAX);
3098 remote_port := f_rnd_int(c_UINT16_MAX);
3099 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3100 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3101 "IPA MDCX ACK");
3102 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3103 "IPA DLCX ACK");
3104}
3105testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3106 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3107 f_init(testcasename());
3108 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3109 vc_conn.done;
3110}
3111
Harald Welte9912eb52018-02-25 13:30:15 +01003112/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3113function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3114 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3115 "IPA CRCX NACK");
3116}
3117testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3118 var ConnHdlrPars pars;
3119 var ConnHdlr vc_conn;
3120 f_init(testcasename());
3121
3122 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3123 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3124 vc_conn.done;
3125
3126 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3127 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3128 vc_conn.done;
3129}
3130
Harald Weltea3f1df92018-02-25 12:49:55 +01003131
Harald Welte883340c2018-02-28 18:59:29 +01003132/***********************************************************************
3133 * PCU Socket related tests
3134 ***********************************************************************/
3135
Harald Welte07bd2d22019-05-25 11:03:30 +02003136/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Welte883340c2018-02-28 18:59:29 +01003137private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
3138runs on test_CT {
3139 timer T := 3.0;
3140
3141 /* we don't expect any RTS.req before PDCH are active */
3142 T.start;
3143 alt {
3144 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003145 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003146 }
3147 [] PCU.receive { repeat; }
3148 [] T.timeout { }
3149 }
3150
3151 /* Send PDCH activate request for known PDCH timeslot */
3152 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3153
3154 /* we now expect RTS.req for this timeslot (only) */
3155 T.start;
3156 alt {
3157 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
3158 setverdict(pass);
3159 }
3160 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3161 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003162 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01003163 }
3164 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003165 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01003166 }
3167 [] PCU.receive { repeat; }
3168 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003169 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003170 }
3171 [not exp_success] T.timeout {
3172 setverdict(pass);
3173 }
3174 }
3175}
3176
Harald Welte07bd2d22019-05-25 11:03:30 +02003177/* verify no more RTS after DEACT_REQ */
Harald Welte883340c2018-02-28 18:59:29 +01003178private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
3179runs on test_CT {
3180 timer T := 3.0;
3181
3182 /* Send PDCH activate request for known PDCH timeslot */
3183 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
3184
3185 PCU.clear;
3186 /* we now expect no RTS.req for this timeslot */
3187 T.start;
3188 alt {
3189 [] 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 +02003190 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003191 }
3192 [] PCU.receive { repeat; }
3193 [] T.timeout {
3194 setverdict(pass);
3195 }
3196 }
3197}
3198
Max2c6f5632019-03-18 17:25:17 +01003199private function f_init_pcu_test() runs on test_CT {
3200 f_init();
3201 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
3202}
3203
Harald Welte883340c2018-02-28 18:59:29 +01003204/* PDCH activation via PCU socket; check for presence of RTS.req */
3205testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003206 f_init_pcu_test();
3207
Harald Welte883340c2018-02-28 18:59:29 +01003208 f_TC_pcu_act_req(0, 0, 7, true);
3209}
3210
3211/* PDCH activation via PCU socket on non-PDCU timeslot */
3212testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003213 f_init_pcu_test();
3214
Harald Welte883340c2018-02-28 18:59:29 +01003215 f_TC_pcu_act_req(0, 0, 1, false);
3216}
3217
3218/* PDCH activation via PCU socket on wrong BTS */
3219testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003220 f_init_pcu_test();
3221
Harald Welte883340c2018-02-28 18:59:29 +01003222 f_TC_pcu_act_req(23, 0, 7, false);
3223}
3224
3225/* PDCH activation via PCU socket on wrong TRX */
3226testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003227 f_init_pcu_test();
3228
Harald Welte883340c2018-02-28 18:59:29 +01003229 f_TC_pcu_act_req(0, 23, 7, false);
3230}
3231
3232/* PDCH deactivation via PCU socket; check for absence of RTS.req */
3233testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003234 f_init_pcu_test();
3235
Harald Welte883340c2018-02-28 18:59:29 +01003236 /* Activate PDCH */
3237 f_TC_pcu_act_req(0, 0, 7, true);
3238 f_sleep(1.0);
3239 /* and De-Activate again */
3240 f_TC_pcu_deact_req(0, 0, 7);
3241}
3242
3243/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
3244testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003245 f_init_pcu_test();
3246
Harald Welte883340c2018-02-28 18:59:29 +01003247 f_TC_pcu_deact_req(0, 0, 1);
3248}
3249
3250/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
3251testcase TC_pcu_ver_si13() runs on test_CT {
3252 const octetstring si13 := '00010203040506070909'O;
3253 var PCUIF_send_data sd;
3254 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01003255 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003256
3257 /* Set SI13 via RSL */
3258 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01003259
Harald Welte883340c2018-02-28 18:59:29 +01003260 T.start;
3261 alt {
3262 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
3263 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
3264 setverdict(pass);
3265 } else {
3266 repeat;
3267 }
3268 }
3269 [] PCU.receive { repeat; }
3270 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003271 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01003272 }
3273 }
3274}
3275
3276private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
3277
3278/* helper function to send a PCU DATA.req */
3279private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
3280 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
3281runs on test_CT
3282{
3283 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
3284 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
3285}
3286
3287/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
3288private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
3289 PCUIF_Sapi sapi, octetstring data)
3290runs on test_CT
3291{
3292 var PCUIF_send_data sd;
3293
3294 timer T := 3.0;
3295 T.start;
3296 alt {
3297 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3298 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
3299 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
3300 sd.data.u.rts_req.fn, sapi, data);
3301 }
3302 [] PCU.receive { repeat; }
3303 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003304 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01003305 }
3306 }
3307}
3308
3309/* Send DATA.req on invalid BTS */
3310testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003311 f_init_pcu_test();
3312
Harald Welte883340c2018-02-28 18:59:29 +01003313 f_TC_pcu_act_req(0, 0, 7, true);
3314 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3315 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3316 f_sleep(10.0);
3317}
3318
3319/* Send DATA.req on invalid TRX */
3320testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003321 f_init_pcu_test();
3322
Harald Welte883340c2018-02-28 18:59:29 +01003323 f_TC_pcu_act_req(0, 0, 7, true);
3324 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3325 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3326 f_sleep(10.0);
3327}
3328
3329/* Send DATA.req on invalid timeslot */
3330testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003331 f_init_pcu_test();
3332
Harald Welte883340c2018-02-28 18:59:29 +01003333 f_TC_pcu_act_req(0, 0, 7, true);
3334 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3335 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3336 f_sleep(10.0);
3337}
3338
3339/* Send DATA.req on timeslot that hasn't been activated */
3340testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003341 f_init_pcu_test();
3342
Harald Welte883340c2018-02-28 18:59:29 +01003343 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3344 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3345 f_sleep(2.0);
3346}
3347
3348testcase TC_pcu_data_req_pdtch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003349 f_init_pcu_test();
3350
Harald Welte883340c2018-02-28 18:59:29 +01003351 f_TC_pcu_act_req(0, 0, 7, true);
3352 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3353 /* FIXME: how to check this was actually sent */
3354 f_sleep(2.0);
3355}
3356
3357testcase TC_pcu_data_req_ptcch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003358 f_init_pcu_test();
3359
Harald Welte883340c2018-02-28 18:59:29 +01003360 f_TC_pcu_act_req(0, 0, 7, true);
3361 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
3362 /* FIXME: how to check this was actually sent */
3363 f_sleep(2.0);
3364}
3365
3366/* Send AGCH from PCU; check it appears on Um side */
3367testcase TC_pcu_data_req_agch() runs on test_CT {
3368 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01003369 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003370 f_init_l1ctl();
3371 f_l1_tune(L1CTL);
3372
3373 f_TC_pcu_act_req(0, 0, 7, true);
3374 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
3375
3376 T.start;
3377 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003378 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01003379 setverdict(pass);
3380 }
3381 [] L1CTL.receive { repeat; }
3382 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003383 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003384 }
3385 }
3386}
3387
3388/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
3389testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
3390 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01003391 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003392 f_init_l1ctl();
3393 f_l1_tune(L1CTL);
3394
3395 /* append 3 last imsi digits so BTS can compute pagng group */
3396 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
3397
3398 timer T := 0.5;
3399 T.start;
3400 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003401 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01003402 /* TODO: verify paging group */
3403 setverdict(pass);
3404 }
3405 [] L1CTL.receive { repeat; }
3406 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003407 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003408 }
3409 }
3410}
3411
3412/* Send RACH from Um side, expect it to show up on PCU socket */
3413testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003414 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003415 f_init_l1ctl();
3416 f_l1_tune(L1CTL);
3417
3418 var GsmFrameNumber fn_last := 0;
3419 for (var integer i := 0; i < 1000; i := i+1) {
3420 var OCT1 ra := f_rnd_ra_ps();
3421 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
3422 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003423 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01003424 }
3425 fn_last := fn;
3426
3427 timer T := 2.0;
3428 T.start;
3429 alt {
3430 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
3431 T.stop;
3432 }
3433 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003434 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003435 }
3436 [] PCU.receive { repeat; }
3437 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003438 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003439 }
3440 }
3441 }
3442 setverdict(pass);
3443}
3444
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07003445/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
3446 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
3447testcase TC_pcu_ext_rach_content() runs on test_CT {
3448 var template PCUIF_Message pcu_rach_ind;
3449 var GsmFrameNumber fn_last := 0;
3450 var L1ctlRachSynchSeq synch_seq;
3451 var PCUIF_BurstType pcu_bt;
3452 var GsmFrameNumber fn;
3453 var BIT11 ra11;
3454
3455 f_init_pcu_test();
3456 f_init_l1ctl();
3457 f_l1_tune(L1CTL);
3458
3459 for (var integer i := 0; i < 1000; i := i+1) {
3460 /* We need to test both TS1 & TS2 */
3461 if (i rem 2 == 0) {
3462 synch_seq := RACH_SYNCH_SEQ_TS1;
3463 pcu_bt := BURST_TYPE_1;
3464 } else {
3465 synch_seq := RACH_SYNCH_SEQ_TS2;
3466 pcu_bt := BURST_TYPE_2;
3467 }
3468
3469 ra11 := f_rnd_ra11_ps();
3470 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
3471 if (fn == fn_last) {
3472 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3473 "Two RACH in same FN?!?");
3474 }
3475 fn_last := fn;
3476
3477 /* Compose the expected message */
3478 pcu_rach_ind := tr_PCUIF_RACH_IND(
3479 bts_nr := 0,
3480 ra := bit2int(ra11),
3481 is_11bit := 1,
3482 burst_type := pcu_bt,
3483 fn := fn);
3484
3485 timer T := 2.0;
3486 T.start;
3487 alt {
3488 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
3489 T.stop;
3490 }
3491 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
3492 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
3493 }
3494 [] PCU.receive { repeat; }
3495 [] T.timeout {
3496 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
3497 }
3498 }
3499 }
3500 setverdict(pass);
3501}
3502
Harald Welte883340c2018-02-28 18:59:29 +01003503private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
3504 var integer strlen := lengthof(str);
3505 for (var integer i := 0; i < len-strlen; i := i+1) {
3506 str := str & pad;
3507 }
3508 return str;
3509}
3510
3511/* Send PAGING via RSL, expect it to shw up on PCU socket */
3512testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003513 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003514
3515 for (var integer i := 0; i < 100; i := i+1) {
3516 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
3517 timer T := 3.0;
3518 if (i < 50) {
3519 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
3520 } else {
3521 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
3522 }
3523 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
3524 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
3525 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
3526
3527 /* Send RSL PAGING COMMAND */
3528 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
3529 T.start;
3530 alt {
3531 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
3532 }
3533 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003534 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003535 }
3536 [] PCU.receive { repeat; }
3537 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003538 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003539 }
3540 }
3541 }
3542 setverdict(pass);
3543}
3544
Harald Welted66c9b82019-05-25 09:03:15 +02003545/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
3546testcase TC_pcu_time_ind() runs on test_CT {
3547 var PCUIF_send_data pcu_sd;
3548 var integer num_time_ind := 0;
3549 var integer first_fn, last_fn;
3550 var float test_duration := 5.0;
3551 timer T;
3552
3553 f_init_pcu_test();
3554 f_TC_pcu_act_req(0, 0, 7, true);
3555
3556 PCU.clear;
3557 T.start(test_duration);
3558 alt {
3559 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
3560 num_time_ind := num_time_ind + 1;
3561 if (not isbound(first_fn)) {
3562 first_fn := pcu_sd.data.u.time_ind.fn;
3563 }
3564 last_fn := pcu_sd.data.u.time_ind.fn;
3565 repeat;
3566 }
3567 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
3568 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
3569 repeat;
3570 }
3571 [] PCU.receive {
3572 repeat;
3573 }
3574 [] T.timeout {}
3575 }
3576 var integer fn_expired := last_fn - first_fn;
3577 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
3578
3579 /* verify the number of frames expired matches our expectation */
3580 const float c_GSM_FN_DURATION_MS := 4.61538;
3581 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
3582 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 10);
3583 if (not match(fn_expired, t_fn_expected)) {
3584 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
3585 }
3586
3587 /* There are three TIME.ind in every fn MOD 13 */
3588 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
3589 /* Add some tolerance */
3590 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
3591 if (not match(num_time_ind, t_time_ind_exp)) {
3592 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
3593 }
3594
3595 setverdict(pass);
3596}
3597
Harald Welte4832c862019-05-25 14:57:18 +02003598/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
3599testcase TC_pcu_rts_req() runs on test_CT {
3600 var PCUIF_send_data pcu_sd;
3601 var integer first_fn, last_fn;
3602 var integer num_rts_pdtch := 0;
3603 var integer num_rts_ptcch := 0;
3604 var float test_duration := 5.0;
3605 timer T;
3606
3607 f_init_pcu_test();
3608 f_TC_pcu_act_req(0, 0, 7, true);
3609
3610 PCU.clear;
3611 T.start(test_duration);
3612 alt {
3613 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
3614 -> value pcu_sd {
3615 num_rts_pdtch := num_rts_pdtch + 1;
3616 if (not isbound(first_fn)) {
3617 first_fn := pcu_sd.data.u.rts_req.fn;
3618 }
3619 last_fn := pcu_sd.data.u.rts_req.fn;
3620 repeat;
3621 }
3622 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
3623 -> value pcu_sd {
3624 num_rts_ptcch := num_rts_ptcch + 1;
3625 if (not isbound(first_fn)) {
3626 first_fn := pcu_sd.data.u.rts_req.fn;
3627 }
3628 last_fn := pcu_sd.data.u.rts_req.fn;
3629 repeat;
3630 }
3631 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
3632 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
3633 repeat;
3634 }
3635 [] PCU.receive {
3636 repeat;
3637 }
3638 [] T.timeout {}
3639 }
3640 var integer fn_expired := last_fn - first_fn;
3641 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
3642 ", num_rts_ptcch=", num_rts_ptcch);
3643
3644 /* verify the number of frames expired matches our expectation */
3645 const float c_GSM_FN_DURATION_MS := 4.61538;
3646 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
3647 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 10);
3648 if (not match(fn_expired, t_fn_expected)) {
3649 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
3650 }
3651
3652 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
3653 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
3654 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
3655 if (not match(num_rts_ptcch, t_ptcch_exp)) {
3656 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
3657 t_ptcch_exp);
3658 }
3659
3660 /* We have 12 PDTCH blocks every 52-multiframe */
3661 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
3662 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
3663 if (not match(num_rts_pdtch, t_pdtch_exp)) {
3664 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
3665 t_pdtch_exp);
3666 }
3667
3668 setverdict(pass);
3669}
3670
Harald Welte07bd2d22019-05-25 11:03:30 +02003671/* test for generating Abis side OML ALERT from the PCU */
3672testcase TC_pcu_oml_alert() runs on test_CT {
3673 var PCUIF_send_data pcu_sd;
3674 var integer num_time_ind := 0;
3675 var integer first_fn, last_fn;
3676 var float test_duration := 5.0;
3677 timer T;
3678
3679 f_init_pcu_test();
3680 f_TC_pcu_act_req(0, 0, 7, true);
3681
3682 /* re-connect CTRL port from BTS to BSC */
3683 f_ipa_ctrl_stop();
3684 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
3685
3686 /* Send that OML Alert */
3687 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
3688
3689 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
3690 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
3691 setverdict(pass);
3692}
3693
3694
Harald Welted66c9b82019-05-25 09:03:15 +02003695
Harald Welte3d04ae62018-04-04 20:29:05 +02003696/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02003697 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02003698 ***********************************************************************/
3699
3700private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3701runs on ConnHdlr {
3702 var PCUIF_send_data sd;
3703 /* Expect BTS to immediately acknowledge activation as PDCH */
3704 PCU.clear;
3705 f_rsl_chan_act(g_pars.chan_mode);
3706 /* expect INFO_IND on PCU interface listing TS as PDCH */
3707 alt {
3708 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3709 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003710 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003711 }
3712 }
3713 [] PCU.receive { repeat; }
3714 }
3715 /* try to activate this PDCH from the PCU point of view */
3716 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3717 /* FIXME: is there a response? */
3718}
3719
3720private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3721runs on ConnHdlr {
3722 var PCUIF_send_data sd;
3723 /* Send RSL CHAN REL (deactivate) */
3724 PCU.clear;
3725 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3726 /* expect BTS to ask PCU to deactivate the channel */
3727 alt {
3728 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3729 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003730 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003731 }
3732 }
3733 [] PCU.receive { repeat; }
3734 }
3735 /* Emulate PCU asking BTS to deactivate PDCH */
3736 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3737 alt {
3738 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
3739 setverdict(pass);
3740 }
3741 [] RSL.receive { repeat; }
3742 }
3743}
3744
3745/* Activate Osmocom-style dynamic PDCH from BSC side */
3746function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3747 var PCUIF_Message first_info;
3748 var integer ts_nr := g_chan_nr.tn;
3749 var integer trx_nr := 0;
3750 var integer bts_nr := 0;
3751 var integer pcu_conn_id := -1;
3752
3753 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3754
3755 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3756 f_sleep(3.0);
3757 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3758 setverdict(pass);
3759}
3760testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3761 var ConnHdlrPars pars;
3762 var ConnHdlr vc_conn;
3763 f_init(testcasename());
3764
3765 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3766 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3767 vc_conn.done;
3768}
3769
3770/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3771function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3772 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003773 var integer pcu_conn_id := -1;
3774
3775 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3776
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003777 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3778 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3779 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003780 setverdict(pass);
3781}
3782testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3783 var ConnHdlrPars pars;
3784 var ConnHdlr vc_conn;
3785 f_init(testcasename());
3786
3787 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3788 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3789 vc_conn.done;
3790}
3791
3792/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3793function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3794 var PCUIF_Message first_info;
3795 var integer ts_nr := g_chan_nr.tn;
3796 var integer trx_nr := 0;
3797 var integer bts_nr := 0;
3798 var integer pcu_conn_id := -1;
3799
3800 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3801
3802 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003803 /* Send a second Chan Activ and expect it to be NACKed */
3804 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3805 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003806 setverdict(pass);
3807}
3808testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3809 var ConnHdlrPars pars;
3810 var ConnHdlr vc_conn;
3811 f_init(testcasename());
3812
3813 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3814 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3815 vc_conn.done;
3816}
3817
3818/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3819function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3820 var PCUIF_Message first_info;
3821 var integer ts_nr := g_chan_nr.tn;
3822 var integer trx_nr := 0;
3823 var integer bts_nr := 0;
3824 var integer pcu_conn_id := -1;
3825 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3826
3827 /* register for the TCH/F channel number */
3828 f_rslem_register(0, chan_nr);
3829
3830 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3831
3832 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3833 "RSL CHAN ACT");
3834 setverdict(pass);
3835}
3836testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3837 var ConnHdlrPars pars;
3838 var ConnHdlr vc_conn;
3839 f_init(testcasename());
3840
3841 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3842 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3843 vc_conn.done;
3844}
3845
3846/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3847function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3848 var PCUIF_Message first_info;
3849 var integer ts_nr := g_chan_nr.tn;
3850 var integer trx_nr := 0;
3851 var integer bts_nr := 0;
3852 var integer pcu_conn_id := -1;
3853 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3854 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3855
3856 /* register for the TCH/H channel numbers */
3857 f_rslem_register(0, chan_nr[0]);
3858 f_rslem_register(0, chan_nr[1]);
3859
3860 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3861
3862 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3863 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3864 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3865 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3866 setverdict(pass);
3867}
3868testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3869 var ConnHdlrPars pars;
3870 var ConnHdlr vc_conn;
3871 f_init(testcasename());
3872
3873 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3874 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3875 vc_conn.done;
3876}
3877
Harald Welte9bbbfb52018-04-05 09:33:19 +02003878/***********************************************************************
3879 * IPA Style Dynamic Timeslot Support
3880 ***********************************************************************/
3881
3882private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3883runs on ConnHdlr {
3884 var PCUIF_send_data sd;
3885 /* Expect BTS to immediately acknowledge activation as PDCH */
3886 PCU.clear;
3887 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3888 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003889 timer T_wait := 2.0;
3890 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003891 alt {
3892 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3893 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 +01003894 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
3895 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3896 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003897 }
3898 }
3899 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003900 [] T_wait.timeout {
3901 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3902 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
3903 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003904 }
3905 /* try to activate this PDCH from the PCU point of view */
3906 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3907 /* FIXME: is there a response? */
3908
3909 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3910}
3911
3912private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3913runs on ConnHdlr {
3914 var PCUIF_send_data sd;
3915 /* Send RSL CHAN REL (deactivate) */
3916 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3917 PCU.clear;
3918 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003919 timer T_wait := 2.0;
3920 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003921 alt {
3922 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3923 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 +01003924 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
3925 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3926 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003927 }
3928 }
3929 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003930 [] T_wait.timeout {
3931 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3932 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
3933 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003934 }
3935 /* Emulate PCU asking BTS to deactivate PDCH */
3936 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3937 alt {
3938 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3939 setverdict(pass);
3940 }
3941 [] RSL.receive { repeat; }
3942 }
3943}
3944
3945/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3946function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3947 var PCUIF_Message first_info;
3948 var integer ts_nr := g_chan_nr.tn;
3949 var integer trx_nr := 0;
3950 var integer bts_nr := 0;
3951 var integer pcu_conn_id := -1;
3952
3953 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3954
3955 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3956 f_sleep(3.0);
3957 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3958
3959 setverdict(pass);
3960
3961}
3962testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3963 var ConnHdlrPars pars;
3964 var ConnHdlr vc_conn;
3965 f_init();
3966
3967 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3968 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3969 vc_conn.done;
3970}
3971
3972/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3973function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3974 var PCUIF_Message first_info;
3975 var integer ts_nr := g_chan_nr.tn;
3976 var integer trx_nr := 0;
3977 var integer bts_nr := 0;
3978 var integer pcu_conn_id := -1;
3979
3980 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3981
3982 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3983 "RSL CHAN ACT");
3984 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3985 "RF CHAN REL", true);
3986 setverdict(pass);
3987}
3988testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3989 var ConnHdlrPars pars;
3990 var ConnHdlr vc_conn;
3991 f_init(testcasename());
3992
3993 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3994 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3995 vc_conn.done;
3996}
3997
3998/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3999function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
4000 var PCUIF_Message first_info;
4001 var integer ts_nr := g_chan_nr.tn;
4002 var integer trx_nr := 0;
4003 var integer bts_nr := 0;
4004 var integer pcu_conn_id := -1;
4005
4006 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4007
4008 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
4009 "RSL CHAN ACT");
4010
4011 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
4012 alt {
4013 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
4014 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004015 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02004016 }
4017 [] RSL.receive { repeat; }
4018 }
4019
4020 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
4021 "RF CHAN REL", true);
4022 setverdict(pass);
4023}
4024testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
4025 var ConnHdlrPars pars;
4026 var ConnHdlr vc_conn;
4027 f_init(testcasename());
4028
4029 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4030 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
4031 vc_conn.done;
4032}
4033
4034/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
4035function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
4036 var PCUIF_Message first_info;
4037 var integer ts_nr := g_chan_nr.tn;
4038 var integer trx_nr := 0;
4039 var integer bts_nr := 0;
4040 var integer pcu_conn_id := -1;
4041
4042 /* register for the TCH/F channel number */
4043 f_rslem_register(0, g_chan_nr);
4044
4045 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4046
4047 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
4048
4049 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
4050 "RSL CHAN ACT");
4051
4052 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
4053
4054 setverdict(pass);
4055}
4056testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
4057 var ConnHdlrPars pars;
4058 var ConnHdlr vc_conn;
4059 f_init(testcasename());
4060
4061 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
4062 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
4063 vc_conn.done;
4064}
4065
4066
Harald Welte0472ab42018-03-12 15:02:26 +01004067/***********************************************************************
4068 * LAPDm / RLL related
4069 ***********************************************************************/
4070
4071private function f_tx_lapdm(template (value) LapdmFrame l,
4072 template (value) RslLinkId link_id) runs on ConnHdlr {
4073 var octetstring l2 := enc_LapdmFrame(valueof(l));
4074 if (valueof(link_id.c) == SACCH) {
4075 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02004076 var L1ctlDataReq l1hl2 := {
4077 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
4078 l2_payload := f_pad_oct(l2, 21, '2B'O)
4079 }
4080 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
4081 } else {
4082 /* If required, pad L2 frame with constant 0x2b filling */
4083 l2 := f_pad_oct(l2, 23, '2B'O);
4084
4085 log("encoding ", l, " to ", l2);
4086 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01004087 }
Harald Welte0472ab42018-03-12 15:02:26 +01004088}
4089
4090type record RllTestCase {
4091 uint3_t sapi,
4092 RslLinkId link_id,
4093 octetstring l3,
4094 boolean exp
4095}
4096type record of RllTestCase RllTestCases;
4097template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
4098 sapi := sapi,
4099 link_id := id,
4100 l3 := l3,
4101 exp := exp
4102}
4103
4104/* execute the same callback function with a set of different parameters (tcs) on a
4105 * variety of logical channels */
4106private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
4107 var ConnHdlrPars pars;
4108 var ConnHdlr vc_conn;
4109 f_init(testcasename());
4110
4111 /* test on each of the channels we have */
4112 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
4113 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
4114
4115 /* test each of the test cases on the current channel */
4116 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
4117 pars.spec.rll := tcs[j];
4118 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
4119 vc_conn := f_start_handler(fn, pars);
4120 vc_conn.done;
4121 }
4122 }
4123
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004124 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01004125}
4126
4127/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
4128private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
4129 var RllTestCase tc := g_pars.spec.rll;
4130 timer T := 3.0;
4131
4132 f_l1_tune(L1CTL);
4133 RSL.clear;
4134
4135 /* activate the logical channel */
4136 f_est_dchan();
4137 L1CTL.clear;
4138
4139 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
4140 T.start;
4141 alt {
4142 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
4143 if (tc.exp) {
4144 setverdict(pass);
4145 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004146 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004147 }
4148 }
4149 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
4150 if (tc.exp) {
4151 setverdict(pass);
4152 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004153 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004154 }
4155 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004156 /* We also expect to receive the measurements */
4157 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004158 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004159 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004160 }
4161 [not tc.exp] T.timeout {
4162 setverdict(pass);
4163 }
4164 }
4165
4166 f_rsl_chan_deact();
4167 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4168 f_rslem_unregister(0, g_chan_nr);
4169}
4170testcase TC_rll_est_ind() runs on test_CT {
4171 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02004172 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01004173 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02004174 /* normal SAPI0 establishment */
4175 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01004176 /* SAPI 3 doesn't support contention resolution */
4177 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
4178 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
4179 /* normal SAPI3 establishment on main DCCH */
4180 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4181 /* normal SAPI3 establishment on SACCH */
4182 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4183 };
4184 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
4185}
4186
4187/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
4188private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
4189 var RllTestCase tc := g_pars.spec.rll;
4190 var L1ctlDlMessage dl;
4191 timer T := 3.0;
4192
4193 f_l1_tune(L1CTL);
4194 RSL.clear;
4195
4196 /* activate the logical channel */
4197 f_est_dchan();
4198 L1CTL.clear;
4199
4200 /* Send a RSL EST REQ for SAPI3 on main DCCH */
4201 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
4202 T.start;
4203 alt {
4204 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4205 var LapdmFrame lapdm;
4206 var octetstring l2 := dl.payload.data_ind.payload;
4207 if (dl.dl_info.link_id.c == SACCH) {
4208 /* remove L1 header */
4209 l2 := substr(l2, 2, lengthof(l2)-2);
4210 }
4211 lapdm.ab := dec_LapdmFrameAB(l2);
4212 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
4213 setverdict(pass);
4214 } else {
4215 repeat;
4216 }
4217 }
4218 [] L1CTL.receive { repeat; }
4219 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004220 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01004221 }
4222 }
4223
4224 f_rsl_chan_deact();
4225 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4226 f_rslem_unregister(0, g_chan_nr);
4227}
4228testcase TC_rll_est_req_DCCH_3() runs on test_CT {
4229 var RllTestCases tcs := {
4230 /* normal SAPI3 establishment on main DCCH */
4231 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
4232 };
4233 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4234}
4235testcase TC_rll_est_req_ACCH_3() runs on test_CT {
4236 var RllTestCases tcs := {
4237 /* normal SAPI3 establishment on SACCH */
4238 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4239 }
4240 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4241}
4242
4243/* altstep to receive a LAPDm frame matching the given template */
4244private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
4245 var L1ctlDlMessage dl;
4246 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4247 var LapdmFrame lapdm;
4248 var octetstring l2 := dl.payload.data_ind.payload;
4249 if (dl.dl_info.link_id.c == SACCH) {
4250 /* remove L1 header */
4251 l2 := substr(l2, 2, lengthof(l2)-2);
4252 }
4253 if (ischosen(exp.ab)) {
4254 lapdm.ab := dec_LapdmFrameAB(l2);
4255 } else if (ischosen(exp.b4)) {
4256 lapdm.b4 := dec_LapdmFrameB4(l2);
4257 } else if (ischosen(exp.bbis)) {
4258 lapdm.bbis := dec_LapdmFrameBbis(l2);
4259 }
4260 log("Rx LAPDm ", lapdm);
4261 if (match(lapdm, exp)) {
4262 setverdict(pass);
4263 } else {
4264 repeat;
4265 }
4266 }
4267 [] L1CTL.receive { repeat; }
4268}
4269private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
4270 timer T := t;
4271 T.start;
4272 alt {
4273 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004274 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01004275 }
4276 [] as_l1_exp_lapdm(exp);
4277 }
4278}
4279
4280/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
4281private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4282 /* send SABM from MS -> BTS */
4283 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
4284 /* expect RLL EST IND on Abis */
4285 alt {
4286 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
4287 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
4288 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004289 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004290 }
4291 [] RSL.receive { repeat; }
4292 }
4293 /* expect UA from BTS -> MS */
4294 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
4295}
4296
4297/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
4298private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
4299 var RllTestCase tc := g_pars.spec.rll;
4300
4301 f_l1_tune(L1CTL);
4302 RSL.clear;
4303
4304 /* activate the logical channel */
4305 f_est_dchan();
4306 L1CTL.clear;
4307
4308 /* first establish the link-layer */
4309 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4310
4311 /* then send the DISC */
4312 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
4313 /* ... and expect the REL IND on the RSL side */
4314 alt {
4315 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
4316 setverdict(pass);
4317 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004318 /* We also expect to receive the measurements */
4319 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004320 }
4321
4322 /* release the channel */
4323 f_rsl_chan_deact();
4324 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4325 f_rslem_unregister(0, g_chan_nr);
4326}
4327testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
4328 var RllTestCases tcs := {
4329 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
4330 };
4331 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4332}
4333
4334testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
4335 var RllTestCases tcs := {
4336 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
4337 };
4338 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4339}
4340testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
4341 var RllTestCases tcs := {
4342 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
4343 };
4344 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4345}
4346testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
4347 var RllTestCases tcs := {
4348 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4349 };
4350 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4351}
4352
4353/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
4354private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
4355 var RllTestCase tc := g_pars.spec.rll;
4356 f_l1_tune(L1CTL);
4357 RSL.clear;
4358
4359 /* activate the logical channel */
4360 f_est_dchan();
4361 L1CTL.clear;
4362
4363 /* first establish the link-layer */
4364 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4365
4366 /* then send the REL REQ via RSL */
4367 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
4368 /* ... and expect the DISC on the Um side */
4369 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02004370 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01004371 /* FIXME: send a UA in resposne to the DISC */
4372 }
4373 }
4374
4375 /* release the channel */
4376 f_rsl_chan_deact();
4377 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4378 f_rslem_unregister(0, g_chan_nr);
4379}
4380testcase TC_rll_rel_req() runs on test_CT {
4381 var RllTestCases tcs := {
4382 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
4383 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
4384 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4385 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4386 };
4387 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
4388}
4389
4390/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
4391testcase TC_rll_data_req() runs on test_CT {
4392}
4393
4394/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
4395testcase TC_rll_data_ind() runs on test_CT {
4396}
4397
4398/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
4399private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
4400 var RllTestCase tc := g_pars.spec.rll;
4401
4402 f_l1_tune(L1CTL);
4403 RSL.clear;
4404
4405 f_est_dchan();
4406 L1CTL.clear;
4407
4408 /* Send UNITDATA REQ on RSL side */
4409 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
4410 /* Expect it to arrive on the other side */
4411 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02004412 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004413 } else {
Harald Weltee613f962018-04-18 22:38:16 +02004414 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004415 }
4416
4417 /* release the channel */
4418 f_rsl_chan_deact();
4419 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4420 f_rslem_unregister(0, g_chan_nr);
4421}
4422testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
4423 var octetstring l3 := f_rnd_octstring(15);
4424 var RllTestCases tcs := {
4425 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4426 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4427 };
4428 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4429}
4430testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
4431 var octetstring l3 := f_rnd_octstring(19);
4432 var RllTestCases tcs := {
4433 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4434 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4435 };
4436 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4437}
4438
4439/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
4440private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
4441 var RllTestCase tc := g_pars.spec.rll;
4442
4443 f_l1_tune(L1CTL);
4444 RSL.clear;
4445
4446 f_est_dchan();
4447 L1CTL.clear;
4448
4449 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02004450 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01004451 /* Expdct RLL UNITDATA IND on RSL side */
4452 alt {
4453 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
4454 setverdict(pass);
4455 }
4456 [] RSL.receive { repeat; }
4457 }
4458
4459 /* release the channel */
4460 f_rsl_chan_deact();
4461 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4462 f_rslem_unregister(0, g_chan_nr);
4463}
4464testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02004465 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01004466 var RllTestCases tcs := {
4467 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4468 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4469 };
4470 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4471}
4472testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
4473 var octetstring l3 := f_rnd_octstring(18);
4474 var RllTestCases tcs := {
4475 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4476 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4477 };
4478 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4479}
4480
Harald Weltee613f962018-04-18 22:38:16 +02004481/***********************************************************************
4482 * Encryption Related
4483 ***********************************************************************/
4484
4485/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4486function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4487 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
4488 if (link_id.c == SACCH) {
4489 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
4490 } else {
4491 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
4492 }
4493}
4494
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004495/* Expect (or not expect) other kinds of messages */
4496private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
4497 [exp_any] RSL.receive { repeat; }
4498 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004499 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004500 }
4501}
4502
Harald Weltee613f962018-04-18 22:38:16 +02004503/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07004504private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004505 RslLinkId link_id,
4506 octetstring l3,
4507 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004508 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004509) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02004510 timer T := 3.0;
4511 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
4512 T.start;
4513 /* Expect RLL UNITDATA IND on RSL side */
4514 alt {
4515 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
4516 setverdict(pass);
4517 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004518 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004519 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02004520 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004521 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02004522 }
Harald Weltee613f962018-04-18 22:38:16 +02004523 }
4524}
4525
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004526/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
4527private function f_data_mo(
4528 RslLinkId link_id,
4529 boolean p, uint3_t nr, uint3_t ns,
4530 octetstring l3,
4531 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004532 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004533) runs on ConnHdlr {
4534 timer T := 3.0;
4535 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
4536 T.start;
4537 /* Expect RLL DATA IND on RSL side */
4538 alt {
4539 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
4540 setverdict(pass);
4541 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004542 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004543 [] as_rsl_any_ind(exp_any);
4544 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004545 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004546 }
4547 }
4548}
4549
Harald Weltee613f962018-04-18 22:38:16 +02004550/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
4551function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
4552 f_l1_tune(L1CTL);
4553 f_est_dchan(true);
4554
4555 /* now we actually need to transmit some data both ways to check if the encryption works */
4556 var L1ctlDlMessage dl;
4557
Stefan Sperling603d98e2018-07-25 16:47:28 +02004558 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02004559 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4560
4561 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4562 f_unitdata_mt(link_id, l3);
4563
4564 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
4565 f_unitdata_mo(link_id, l3);
4566
4567 /* release the channel */
4568 f_rsl_chan_deact();
4569 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4570 f_rslem_unregister(0, g_chan_nr);
4571}
4572testcase TC_chan_act_a51() runs on test_CT {
4573 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4574 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4575 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4576}
4577testcase TC_chan_act_a52() runs on test_CT {
4578 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4579 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4580 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4581}
4582testcase TC_chan_act_a53() runs on test_CT {
4583 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4584 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4585 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4586}
4587
4588
4589/* Test unencrypted channel activation followed by explicit ENCR CMD later */
4590function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
4591 /* L3 payload doesn't matter, as it is passed transparently */
4592 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
4593 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
4594 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4595
4596 f_l1_tune(L1CTL);
4597
4598 /* first establish a dedicated channel in the clear */
4599 f_est_dchan(false);
4600
4601 /* Establish ABM */
4602 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4603
4604 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
4605 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
4606 /* expect the L3 to arrive still unencrypted on the MS side */
4607 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
4608
4609 /* configure L1 to apply ciphering */
4610 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
4611 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
4612
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004613 /* send first ciphered I-frame in response and expect it on RSL */
4614 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02004615
4616 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
4617 * and hence enable encryption also on the downlink */
4618
4619 /* expect bi-directional communication work in encrypted mode */
4620 f_unitdata_mo(link_id, f_rnd_octstring(15));
4621 f_unitdata_mt(link_id, f_rnd_octstring(15));
4622
4623 /* release the channel */
4624 f_rsl_chan_deact();
4625 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4626 f_rslem_unregister(0, g_chan_nr);
4627}
4628testcase TC_encr_cmd_a51() runs on test_CT {
4629 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4630 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4631 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4632}
4633testcase TC_encr_cmd_a52() runs on test_CT {
4634 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4635 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4636 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4637}
4638testcase TC_encr_cmd_a53() runs on test_CT {
4639 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4640 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4641 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4642}
4643
4644private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
4645 var LapdmFrame lf;
4646 var octetstring reenc;
4647
4648 /* decode the LAPDm frame */
4649 if (ischosen(exp_match.ab)) {
4650 lf.ab := dec_LapdmFrameAB(enc);
4651 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004652 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02004653 }
4654
4655 /* check if decoder result matches expectation */
4656 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004657 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004658 } else {
4659 log(name, ": matched");
4660 setverdict(pass);
4661 }
4662
4663 /* test if re-encoded frame equals original input */
4664 reenc := enc_LapdmFrame(lf);
4665 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004666 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004667 } else {
4668 setverdict(pass);
4669 }
4670}
4671
4672testcase TC_lapdm_selftest() runs on test_CT {
4673 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
4674 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
4675 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
4676 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
4677 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
4678 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
4679 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
4680}
4681
Stefan Sperling4880be42018-08-07 18:12:59 +02004682/***********************************************************************
4683 * DTX Related (see GSM 05.08, section 8.3)
4684 ***********************************************************************/
4685
4686/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
4687function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
4688 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
4689 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
4690 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
4691 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
4692}
4693function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
4694 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
4695 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
4696}
4697function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
4698 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
4699 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
4700 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
4701 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
4702}
4703function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
4704 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
4705 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
4706 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
4707 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
4708 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
4709 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
4710 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
4711 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
4712}
4713
4714function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
4715 var L1ctlDlMessage dl;
4716 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
4717 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
4718 var GsmFrameNumber first_fn;
4719 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004720 var integer nfill_frames_sacch := 0;
4721 var integer nfill_frames_nonsacch := 0;
4722 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02004723 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
4724 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004725 const integer frame_dtx_tchf_mod := 104;
4726 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
4727 * which operates in terms of blocks rather than frames. */
4728 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
4729 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02004730 timer T := 5.0;
4731
4732 f_l1_tune(L1CTL);
4733 RSL.clear;
4734 L1CTL.clear;
4735
4736 /* activate TCHF signalling channel */
4737 f_est_dchan(false);
4738
4739 T.start;
4740 alt {
4741 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4742 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4743 var octetstring l2 := dl.payload.data_ind.payload;
4744
4745 if (is_first_frame) {
4746 is_first_frame := false;
4747 first_fn := dl.dl_info.frame_nr;
4748 }
4749
4750 if (dl.dl_info.link_id.c == SACCH) {
4751 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4752 if (not match(l2_fill_frame_sacch, l2)) {
4753 repeat;
4754 }
4755 } else if (not match(l2_fill_frame, l2)) {
4756 repeat;
4757 }
4758
4759 if (dtxd) {
4760 if (not f_g_chan_is_tchf()) {
4761 T.stop;
4762 f_rsl_chan_deact();
4763 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004764 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 +02004765 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004766 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004767 T.stop;
4768 f_rsl_chan_deact();
4769 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004770
4771 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4772 * 2 SACCH, 1 TCH/F */
4773 expected_fill_frames := 3;
4774
4775 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4776 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4777 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004778 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004779 } else {
4780 setverdict(pass);
4781 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004782 } else {
4783 if (dl.dl_info.link_id.c == SACCH) {
4784 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004785 repeat;
4786 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004787 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4788 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4789 * we should only see the subset of frames numbers which correspond to a block boundary.
4790 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4791 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4792 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4793 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4794 repeat;
4795 }
4796 }
4797 log("Received DTX TCH fill frame with bad frame number: ", fn,
4798 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4799 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4800 f_rsl_chan_deact();
4801 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004802 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004803 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004804 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004805 if (dl.dl_info.link_id.c == SACCH) {
4806 nfill_frames_sacch := nfill_frames_sacch + 1;
4807 } else {
4808 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4809 }
4810 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004811 T.stop;
4812 if (f_g_chan_is_tchf()) {
4813 /* Without DTX we can expect 25 fill frames for every 104 frames.
4814 * (24 FACCH + 1 SACCH filling) */
4815 expected_fill_frames := 25;
4816 } else if (f_g_chan_is_tchh()) {
4817 /* We can expect 2 fill frames for every 104 frames. */
4818 expected_fill_frames := 2;
4819 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4820 /* We can expect 5 fill frames for every 104 frames. */
4821 expected_fill_frames := 5;
4822 } else {
4823 f_rsl_chan_deact();
4824 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004825 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02004826 }
4827
4828 f_rsl_chan_deact();
4829 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004830
4831 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004832 setverdict(pass);
4833 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004834 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4835 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004836 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004837 }
4838 } else {
4839 repeat;
4840 }
4841 }
4842 }
4843 [] L1CTL.receive { repeat; }
4844 [] T.timeout {
4845 f_rsl_chan_deact();
4846 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004847 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004848 }
4849 }
4850}
4851
4852function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4853 f_test_l2_fill_frames(false);
4854}
4855
4856function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4857 f_test_l2_fill_frames(true);
4858}
4859
4860function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4861 var ConnHdlr vc_conn;
4862 var ConnHdlrPars pars;
4863 pars.t_guard := 60.0;
4864 f_init(testcasename());
4865 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4866 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4867 if (dtxd) {
4868 if (i >= 4) { /* DTX is only allowed on TCH/F */
4869 break;
4870 }
4871 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4872 } else {
4873 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4874 }
4875 vc_conn.done;
4876 }
4877}
4878
4879/* Verify that L2 fill frames are sent on TCH in signaling mode if
4880 * there is nothing to transmit while DTX is disabled on downlink. */
4881testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4882 f_tch_sign_l2_fill_frame(false);
4883}
4884
4885/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4886 * there is nothing to transmit while DTX is enabled on downlink. */
4887testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4888 f_tch_sign_l2_fill_frame(true);
4889}
Harald Welte0472ab42018-03-12 15:02:26 +01004890
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004891testcase TC_chopped_ipa_ping() runs on test_CT {
4892 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4893}
4894
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004895testcase TC_chopped_ipa_payload() runs on test_CT {
4896 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4897}
4898
Harald Welte0472ab42018-03-12 15:02:26 +01004899/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4900/* protocol error as per 44.006 */
4901/* link layer failure (repetition of I-frame N200 times without ACK */
4902/* repetition of SABM or DISC N200 times without ACK */
4903/* receptiom of SABM in multi-frame established state */
4904
4905
Harald Welte68e495b2018-02-25 00:05:57 +01004906/* TODO Areas:
4907
4908* channel activation
4909** with BS_Power / MS_Power, bypassing power control loop
4910** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004911** with timing advance from initial activation on
4912* mode modify
4913** encryption
4914** multirate
4915* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004916** unsupported algorithm
4917* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01004918* BS Power Control
4919* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01004920* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004921* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01004922** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004923* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01004924** DATA_IND from BTS->PCU
4925** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004926
4927*/
Harald Welte70767382018-02-21 12:16:40 +01004928
4929control {
4930 execute( TC_chan_act_stress() );
4931 execute( TC_chan_act_react() );
4932 execute( TC_chan_deact_not_active() );
4933 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004934 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004935 execute( TC_sacch_filling() );
4936 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004937 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004938 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02004939 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02004940 execute( TC_sacch_chan_act_ho_async() );
4941 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004942 execute( TC_rach_content() );
4943 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004944 execute( TC_rach_max_ta() );
Harald Welte3453ab42019-05-24 21:19:58 +02004945 execute( TC_rach_load_idle_thresh0() );
4946 execute( TC_rach_load_idle_below_thresh() );
4947 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01004948 execute( TC_meas_res_sign_tchf() );
4949 execute( TC_meas_res_sign_tchh() );
4950 execute( TC_meas_res_sign_sdcch4() );
4951 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004952 execute( TC_meas_res_sign_tchh_toa256() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01004953 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild6833cc92019-05-23 19:34:44 +02004954 execute( TC_rsl_chan_initial_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004955 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004956 execute( TC_paging_imsi_80percent() );
4957 execute( TC_paging_tmsi_80percent() );
4958 execute( TC_paging_imsi_200percent() );
4959 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004960 execute( TC_rsl_protocol_error() );
4961 execute( TC_rsl_mand_ie_error() );
4962 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004963 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004964 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004965 execute( TC_si_sched_2bis() );
4966 execute( TC_si_sched_2ter() );
4967 execute( TC_si_sched_2ter_2bis() );
4968 execute( TC_si_sched_2quater() );
4969 execute( TC_si_sched_13() );
4970 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004971 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004972 execute( TC_ipa_crcx_twice_not_active() );
4973 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004974 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004975 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004976
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004977 if (mp_pcu_socket != "") {
4978 execute( TC_pcu_act_req() );
4979 execute( TC_pcu_act_req_wrong_ts() );
4980 execute( TC_pcu_act_req_wrong_bts() );
4981 execute( TC_pcu_act_req_wrong_trx() );
4982 execute( TC_pcu_deact_req() );
4983 execute( TC_pcu_deact_req_wrong_ts() );
4984 execute( TC_pcu_ver_si13() );
4985 execute( TC_pcu_data_req_wrong_bts() );
4986 execute( TC_pcu_data_req_wrong_trx() );
4987 execute( TC_pcu_data_req_wrong_ts() );
4988 execute( TC_pcu_data_req_ts_inactive() );
4989 execute( TC_pcu_data_req_pdtch() );
4990 execute( TC_pcu_data_req_ptcch() );
4991 execute( TC_pcu_data_req_agch() );
4992 execute( TC_pcu_data_req_imm_ass_pch() );
4993 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004994 execute( TC_pcu_ext_rach_content() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004995 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02004996 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02004997 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02004998 execute( TC_pcu_oml_alert() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004999 } else {
5000 log("PCU socket path not available, skipping PCU tests");
5001 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005002
5003 execute( TC_dyn_osmo_pdch_act_deact() );
5004 execute( TC_dyn_osmo_pdch_unsol_deact() );
5005 execute( TC_dyn_osmo_pdch_double_act() );
5006 execute( TC_dyn_osmo_pdch_tchf_act() );
5007 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02005008 execute( TC_dyn_ipa_pdch_act_deact() );
5009 execute( TC_dyn_ipa_pdch_tchf_act() );
5010 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
5011 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01005012
5013 execute( TC_rll_est_ind() );
5014 execute( TC_rll_est_req_DCCH_3() );
5015 execute( TC_rll_est_req_ACCH_3() );
5016 execute( TC_rll_rel_ind_DCCH_0() );
5017 execute( TC_rll_rel_ind_DCCH_3() );
5018 execute( TC_rll_rel_ind_ACCH_0() );
5019 execute( TC_rll_rel_ind_ACCH_3() );
5020 execute( TC_rll_rel_req() );
5021 execute( TC_rll_unit_data_req_DCCH() );
5022 execute( TC_rll_unit_data_req_ACCH() );
5023 execute( TC_rll_unit_data_ind_DCCH() );
5024 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02005025
5026 execute( TC_chan_act_a51() );
5027 execute( TC_chan_act_a52() );
5028 execute( TC_chan_act_a53() );
5029 execute( TC_encr_cmd_a51() );
5030 execute( TC_encr_cmd_a52() );
5031 execute( TC_encr_cmd_a53() );
5032
Harald Welteee25aae2019-05-19 14:32:37 +02005033 execute( TC_err_rep_wrong_mdisc() );
5034 execute( TC_err_rep_wrong_msg_type() );
5035 execute( TC_err_rep_wrong_sequence() );
5036
Harald Weltee613f962018-04-18 22:38:16 +02005037 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02005038
5039 execute( TC_tch_sign_l2_fill_frame() );
5040 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02005041
5042 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005043 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01005044}
5045
5046
5047}