blob: 68c85fb56b4e58927b1d40cf01d687763594a3fd [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 Welte70767382018-02-21 12:16:40 +010038/* The tests assume a BTS with the following timeslot configuration:
39 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020040 * TS1 : TCH/F
41 * TS2 : TCH/F
42 * TS3 : TCH/F_PDCH (IPA Style)
43 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010044 * TS5 : TCH/H
45 * TS6 : SDCCH/8
46 * TS7 : PDCH
47 */
48
49modulepar {
50 charstring mp_rsl_ip := "127.0.0.2";
51 integer mp_rsl_port := 3003;
52 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070053 charstring mp_bts_trxc_ip := "127.0.0.1";
54 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010055 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020056 charstring mp_ctrl_ip := "127.0.0.1";
57 integer mp_ctrl_port := 4238;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020058 integer mp_tolerance_rxqual := 1;
59 integer mp_tolerance_rxlev := 3;
60 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020061 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020062 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020063 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020064 integer mp_ms_actual_ta_exp := 0;
65 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +010066 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +020067 float mp_ipa_up_timeout := 15.0;
Harald Welte70767382018-02-21 12:16:40 +010068}
69
Harald Welte629cc6b2018-03-11 17:19:05 +010070type record of RslChannelNr ChannelNrs;
71
Harald Welte70767382018-02-21 12:16:40 +010072type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010073 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010074 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010075 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010076 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010077 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010078 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010079
80 /* L1CTL port (for classic tests) */
81 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010082
Harald Welte54a2a2d2018-02-26 09:14:05 +010083 /* TRXC port (for classic tests) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070084 port TRXC_CODEC_PT BTS_TRXC;
85 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +010086
Harald Weltef50e3ae2018-09-10 10:27:56 +020087 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010088 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020089 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010090
Harald Welte883340c2018-02-28 18:59:29 +010091 /* PCU Interface of BTS */
92 port PCUIF_CODEC_PT PCU;
93 var integer g_pcu_conn_id;
94 /* Last PCU INFO IND we received */
95 var PCUIF_Message g_pcu_last_info;
96
Harald Welte48494ca2018-02-25 16:59:50 +010097 /* SI configuration */
98 var SystemInformationConfig si_cfg := {
99 bcch_extended := false,
100 si1_present := false,
101 si2bis_present := false,
102 si2ter_present := false,
103 si2quater_present := false,
104 si7_present := false,
105 si8_present := false,
106 si9_present := false,
107 si13_present := false,
108 si13alt_present := false,
109 si15_present := false,
110 si16_present := false,
111 si17_present := false,
112 si2n_present := false,
113 si21_present := false,
114 si22_present := false
115 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100116
117 /* all logical channels available on the BTS */
118 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100119 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100120}
121
122/* an individual call / channel */
123type component ConnHdlr extends RSL_DchanHdlr {
124 port L1CTL_PT L1CTL;
125
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700126 port TRXC_CODEC_PT BTS_TRXC;
127 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100128
129 timer g_Tguard;
130 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
131
132 var ConnHdlrPars g_pars;
133 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100134 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200135
136 /* PCU Interface of BTS */
137 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100138}
139
140function f_init_rsl(charstring id) runs on test_CT {
141 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
142 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
143
144 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
145 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
146 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
147
148 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
149 vc_RSL.start(RSL_Emulation.main(false));
150}
151
152type record ConnHdlrPars {
153 RslChannelNr chan_nr,
154 RSL_IE_ChannelMode chan_mode,
155 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100156 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200157 TestSpecUnion spec optional,
158 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100159}
160
161/* Test-specific parameters */
162type union TestSpecUnion {
163 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100164}
165
Harald Welte82ccef72018-02-25 16:17:33 +0100166template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100167 max_retrans := RACH_MAX_RETRANS_7,
168 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100169 cell_barr_access := false,
170 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100171 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100172};
173
Harald Weltef10153f2018-02-25 16:34:05 +0100174template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100175 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200176 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100177 acs := '0'B,
178 neci := true,
179 rxlev_access_min := 0
180}
181
182template (value) LocationAreaIdentification ts_LAI_default := {
183 mcc_mnc := '262F42'H,
184 lac := 42
185}
186
Harald Welte7484fc42018-02-24 14:09:45 +0100187/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100188template (value) SystemInformation ts_SI3_default := {
189 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100190 payload := {
191 si3 := {
192 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100193 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100194 ctrl_chan_desc := {
195 msc_r99 := true,
196 att := true,
197 bs_ag_blks_res := 1,
198 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100199 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100200 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
201 spare := '00'B,
202 bs_pa_mfrms := 0, /* 2 multiframes */
203 t3212 := 1 /* 6 minutes */
204 },
Harald Welte82ccef72018-02-25 16:17:33 +0100205 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100206 dn_ind := false,
207 pwrc := false,
208 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100209 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100210 },
Harald Weltef10153f2018-02-25 16:34:05 +0100211 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100212 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100213 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100214 }
215 }
216}
Harald Welte70767382018-02-21 12:16:40 +0100217
Harald Weltef8df4cb2018-03-10 15:15:08 +0100218template (value) SystemInformation ts_SI2_default := {
219 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100220 payload := {
221 si2 := {
222 bcch_freq_list := '00000000000000000000000000000000'O,
223 ncc_permitted := '11111111'B,
224 rach_control := ts_RachCtrl_default
225 }
226 }
227}
228
Harald Weltef8df4cb2018-03-10 15:15:08 +0100229template (value) SystemInformation ts_SI4_default := {
230 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100231 payload := {
232 si4 := {
233 lai := ts_LAI_default,
234 cell_sel_par := ts_CellSelPar_default,
235 rach_control := ts_RachCtrl_default,
236 cbch_chan_desc := omit,
237 cbch_mobile_alloc := omit,
238 rest_octets := ''O
239 }
240 }
241}
242
243function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
244runs on test_CT {
245 log("Setting ", rsl_si_type, ": ", si_enc);
246 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
247}
248
249function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
250runs on test_CT {
251 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
252 log("Setting ", rsl_si_type, ": ", si_dec);
253 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
254}
255
Harald Welte8da48242018-02-27 20:41:32 +0100256private function f_init_vty(charstring id) runs on test_CT {
257 map(self:BTSVTY, system:BTSVTY);
258 f_vty_set_prompts(BTSVTY);
259 f_vty_transceive(BTSVTY, "enable");
260}
261
Harald Weltef50e3ae2018-09-10 10:27:56 +0200262private function f_init_vty_bsc() runs on test_CT {
263 map(self:BSCVTY, system:BSCVTY);
264 f_vty_set_prompts(BSCVTY, "OsmoBSC");
265 f_vty_transceive(BSCVTY, "enable");
266}
267
Harald Welte883340c2018-02-28 18:59:29 +0100268/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200269private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
270 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100271 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200272 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
273 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100274 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200275 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200276 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100277 }
278}
279
Harald Weltef26de0b2018-04-04 20:28:05 +0200280private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
281 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100282 timer T := 2.0;
283 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100284 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200285 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100286 return;
287 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200288 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100289
290 T.start;
291 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200292 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100293 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200294 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100295 }
296 }
297}
298
Harald Welte70767382018-02-21 12:16:40 +0100299/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100300function f_init(charstring id := "BTS-Test") runs on test_CT {
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100301 timer T := mp_ipa_up_timeout;
Harald Welte629cc6b2018-03-11 17:19:05 +0100302 g_AllChannels := {
303 /* TS 1..4: TCH/F */
304 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
305 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
306 /* TS 5: TCH/H */
307 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
308 /* TS 0: SDCCH/4 */
309 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
310 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
311 /* TS 6: SDCCH/8 */
312 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
313 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
314 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
315 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
316 };
317
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200318 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700319 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200320 g_AllChanTypes := {
321 /* TS 1..4: TCH/F */
322 valueof(ts_RslChanNr_Bm(1)),
323 /* TS 5: TCH/H */
324 valueof(ts_RslChanNr_Lm(5,1)),
325 /* TS 0: SDCCH/4 */
326 valueof(ts_RslChanNr_SDCCH4(0,2)),
327 /* TS 6: SDCCH/8 */
328 valueof(ts_RslChanNr_SDCCH8(6,4))
329 };
330 } else {
331 g_AllChanTypes := {
332 /* TS 1..4: TCH/F */
333 valueof(ts_RslChanNr_Bm(1)),
334 /* TS 0: SDCCH/4 */
335 valueof(ts_RslChanNr_SDCCH4(0,2)),
336 /* TS 6: SDCCH/8 */
337 valueof(ts_RslChanNr_SDCCH8(6,4))
338 };
339 }
Harald Welte70767382018-02-21 12:16:40 +0100340 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200341 T.start;
342 alt {
343 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
344 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200345 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Harald Welte83f6dbf2018-06-03 18:26:50 +0200346 }
347 }
Harald Welte2d142592018-02-25 13:19:44 +0100348 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100349 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200350 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100351
352 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100353 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
354 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
355 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
356 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100357
Harald Weltef26de0b2018-04-04 20:28:05 +0200358 map(self:PCU, system:PCU);
359 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100360
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700361 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100362 var TrxcMessage ret;
363 /* start with a default moderate timing offset equalling TA=2 */
364 f_main_trxc_connect();
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700365 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 +0100366 }
Harald Welte70767382018-02-21 12:16:40 +0100367}
368
Harald Welte68e495b2018-02-25 00:05:57 +0100369/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
370function f_init_l1ctl() runs on test_CT {
371 map(self:L1CTL, system:L1CTL);
372 f_connect_reset(L1CTL);
373}
374
Harald Welte70767382018-02-21 12:16:40 +0100375type function void_fn(charstring id) runs on ConnHdlr;
376
377/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200378function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100379runs on test_CT return ConnHdlr {
380 var charstring id := testcasename();
381 var ConnHdlr vc_conn;
382
383 vc_conn := ConnHdlr.create(id);
384 /* connect to RSL Emulation main component */
385 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
386 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200387 if (pcu_comp) {
388 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
389 * it from the test_CT and connect it to the component. This obviously only
390 * works for one component, i.e. no concurrency */
391 unmap(self:PCU, system:PCU);
392 map(vc_conn:PCU, system:PCU);
393 }
Harald Welte70767382018-02-21 12:16:40 +0100394
395 vc_conn.start(f_handler_init(fn, id, pars));
396 return vc_conn;
397}
398
Harald Welte7484fc42018-02-24 14:09:45 +0100399template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
400 streamId := sid,
401 rsl := rsl
402}
403
404template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
405 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
406 streamId := sid,
407 rsl := rsl
408}
409
Harald Welte70767382018-02-21 12:16:40 +0100410private altstep as_Tguard() runs on ConnHdlr {
411 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200412 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100413 }
414}
415
Harald Welte68e495b2018-02-25 00:05:57 +0100416private function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200417 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100418}
419
420private function f_trxc_connect() runs on ConnHdlr {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700421 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte70767382018-02-21 12:16:40 +0100422 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700423 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Weltea4d8f352018-03-01 15:47:20 +0100424 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200425 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200426 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 +0200427 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700428 g_bts_trxc_conn_id := res.connId;
Harald Welte70767382018-02-21 12:16:40 +0100429}
430
431private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100432 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700433 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100434}
435
436private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100437 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700438 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100439}
440
441/* first function started in ConnHdlr component */
442private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
443runs on ConnHdlr {
444 g_pars := pars;
445 g_chan_nr := pars.chan_nr;
446
447 map(self:L1CTL, system:L1CTL);
448 f_connect_reset(L1CTL);
449
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700450 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100451 f_trxc_connect();
452 }
Harald Welte70767382018-02-21 12:16:40 +0100453
454 g_Tguard.start(pars.t_guard);
455 activate(as_Tguard());
456
457 f_rslem_register(0, pars.chan_nr);
458
459 /* call the user-supplied test case function */
460 fn.apply(id);
461}
462
Harald Welteb1726c92018-03-30 11:56:38 +0200463function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
464 boolean ignore_other := false)
465runs on ConnHdlr return RSL_Message {
466 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100467 timer T := 3.0;
468 RSL.send(tx);
469 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100470 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200471 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100472 T.stop;
473 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100474 }
Harald Welte1eba3742018-02-25 12:48:14 +0100475 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200476 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100477 }
Harald Welte21240e62018-03-11 21:43:35 +0100478 [not ignore_other] as_l1_sacch();
479 [not ignore_other] as_meas_res();
480 [not ignore_other] as_l1_dcch();
481 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200482 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100483 }
Harald Welte21240e62018-03-11 21:43:35 +0100484 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100485 }
Harald Welteb1726c92018-03-30 11:56:38 +0200486 return rx;
487}
488
489function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
490 boolean ignore_other := false)
491runs on ConnHdlr {
492 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100493}
494
Harald Weltee613f962018-04-18 22:38:16 +0200495function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false)
496runs on ConnHdlr {
497 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode));
498 if (encr_enable) {
499 /* append encryption related IEs, if requested */
500 var RSL_IE_EncryptionInfo encr_info;
501 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
502 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
503encr_info})) };
504 }
505 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100506}
507
Harald Welte70767382018-02-21 12:16:40 +0100508function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100509 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 +0100510 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100511}
512
Harald Welte70767382018-02-21 12:16:40 +0100513private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
514 template RSL_IE_ChannelMode chan_mode,
515 float t_guard := 20.0) := {
516 chan_nr := valueof(chan_nr),
517 chan_mode := valueof(chan_mode),
518 t_guard := t_guard,
519 l1_pars := {
520 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100521 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100522 meas_ul := {
523 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200524 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100525 rxqual := 0
526 },
527 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200528 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100529 rxqual := 0
530 }
531 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200532 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100533 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200534 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200535 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100536 },
Harald Weltee613f962018-04-18 22:38:16 +0200537 spec := omit,
538 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100539}
540
Harald Welte93640c62018-02-25 16:59:33 +0100541/***********************************************************************
542 * Channel Activation / Deactivation
543 ***********************************************************************/
544
Harald Welte70767382018-02-21 12:16:40 +0100545/* Stress test: Do 500 channel activations/deactivations in rapid succession */
546function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
547 for (var integer i := 0; i < 500; i := i+1) {
548 f_rsl_chan_act(g_pars.chan_mode);
549 f_rsl_chan_deact();
550 }
551 setverdict(pass);
552}
553testcase TC_chan_act_stress() runs on test_CT {
554 var ConnHdlr vc_conn;
555 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
556 f_init(testcasename());
557 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
558 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200559 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100560}
561
562/* Test if re-activation of an already active channel fails as expected */
563function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
564 f_rsl_chan_act(g_pars.chan_mode);
565 /* attempt to activate the same lchan again -> expect reject */
566 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
567 alt {
568 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200569 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100570 }
571 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
572 setverdict(pass);
573 }
574 }
575 f_rsl_chan_deact();
576}
577testcase TC_chan_act_react() runs on test_CT {
578 var ConnHdlr vc_conn;
579 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100580 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100581 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
582 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200583 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100584}
585
586/* Attempt to de-activate a channel that's not active */
587function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
588 timer T := 3.0;
589 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
590 T.start;
591 alt {
592 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
593 setverdict(pass);
594 }
595 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200596 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100597 }
598 }
599}
600testcase TC_chan_deact_not_active() runs on test_CT {
601 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100602 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100603 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
604 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200605 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100606}
607
608/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
609function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
610 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
611 alt {
612 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200613 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100614 }
615 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
616 setverdict(pass);
617 }
618 }
619}
620private type record WrongChanNrCase {
621 RslChannelNr chan_nr,
622 charstring description
623}
624private type record of WrongChanNrCase WrongChanNrCases;
625private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
626 chan_nr := chan_nr,
627 description := desc
628}
629
630testcase TC_chan_act_wrong_nr() runs on test_CT {
631 var ConnHdlr vc_conn;
632 var ConnHdlrPars pars;
633
Harald Welte294b0a22018-03-10 23:26:48 +0100634 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100635
636 var WrongChanNrCases wrong := {
637 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
638 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
639 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
640 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
641 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
642 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
643 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
644 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
645 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
646 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
647 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
648 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
649 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
650 };
651
652 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
653 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
654 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
655 vc_conn.done;
656 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200657 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100658}
659
Harald Weltee613f962018-04-18 22:38:16 +0200660/* execute the same callback function on a variety of logical channels */
661private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
662 var ConnHdlr vc_conn;
663 f_init(testcasename());
664
665 /* test on each of the channels we have */
666 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
667 pars.chan_nr := valueof(g_AllChanTypes[i]);
668
669 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
670 vc_conn := f_start_handler(fn, pars);
671 vc_conn.done;
672 }
673
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200674 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200675}
676
Harald Welte93640c62018-02-25 16:59:33 +0100677/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100678 * SACCH handling
679 ***********************************************************************/
680
681private function f_exp_sacch(boolean exp) runs on ConnHdlr {
682 timer T_sacch := 3.0;
683 T_sacch.start;
684 alt {
685 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200686 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100687 }
688 [not exp] T_sacch.timeout {
689 setverdict(pass);
690 }
691 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
692 setverdict(pass);
693 }
694 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200695 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100696 }
697 [] L1CTL.receive { repeat; }
698 [] RSL.receive { repeat; }
699 }
700}
701
702/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
703private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
704 f_l1_tune(L1CTL);
705 RSL.clear;
706
707 /* activate the logical channel */
708 f_est_dchan();
709 L1CTL.clear;
710
711 /* check that SACCH actually are received as expected */
712 f_exp_sacch(true);
713
714 /* deactivate SACCH on the logical channel */
715 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
716 f_sleep(1.0);
717 L1CTL.clear;
718
719 /* check that no SACCH are received anymore */
720 f_exp_sacch(false);
721
722 /* release the channel */
723 f_rsl_chan_deact();
724 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
725}
726testcase TC_deact_sacch() runs on test_CT {
727 var ConnHdlr vc_conn;
728 var ConnHdlrPars pars;
729 f_init();
730 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
731 //for (var integer i := 0; i < 1; i := i+1) {
732 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
733 log(testcasename(), ": Starting for ", g_AllChannels[i]);
734 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
735 vc_conn.done;
736 }
737 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200738 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100739}
740
Harald Welte55700662018-03-12 13:15:43 +0100741/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100742private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
743 var L1ctlDlMessage dl;
744 /* check that the specified SI5 value is actually sent */
745 timer T_sacch := 3.0;
746 L1CTL.clear;
747 T_sacch.start;
748 alt {
749 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
750 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
751 if (match(l3, l3_exp)) {
752 setverdict(pass);
753 } else {
754 repeat;
755 }
756 }
757 [] L1CTL.receive { repeat; }
758 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200759 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100760 }
761 }
762}
763
Harald Welte55700662018-03-12 13:15:43 +0100764/* verify that given SACCH payload is not present */
765private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
766 var L1ctlDlMessage dl;
767 /* check that the specified SI5 value is actually sent */
768 timer T_sacch := 3.0;
769 L1CTL.clear;
770 T_sacch.start;
771 alt {
772 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
773 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
774 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200775 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100776 } else {
777 repeat;
778 }
779 }
780 [] L1CTL.receive { repeat; }
781 [] T_sacch.timeout {
782 setverdict(pass);
783 }
784 }
785}
786
Harald Welte629cc6b2018-03-11 17:19:05 +0100787/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100788private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
789 /* Set a known default SACCH filling for SI5 */
790 var octetstring si5 := f_rnd_octstring(19);
791 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
792
793 f_l1_tune(L1CTL);
794 RSL.clear;
795
796 /* activate the logical channel */
797 f_est_dchan();
798
799 /* check that the specified SI5 value is actually sent */
800 f_sacch_present(si5);
801
802 /* release the channel */
803 RSL.clear;
804 f_rsl_chan_deact();
805 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
806}
807testcase TC_sacch_filling() runs on test_CT {
808 var ConnHdlr vc_conn;
809 var ConnHdlrPars pars;
810 f_init();
811 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
812 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
813 log(testcasename(), ": Starting for ", g_AllChannels[i]);
814 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
815 vc_conn.done;
816 }
817 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200818 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100819}
820
Harald Welte629cc6b2018-03-11 17:19:05 +0100821/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100822private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
823 /* Set a known default SACCH filling for SI5 */
824 var octetstring si5 := f_rnd_octstring(19);
825 var octetstring si5_diff := f_rnd_octstring(19);
826 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
827
828 f_l1_tune(L1CTL);
829 RSL.clear;
830
831 log("Activating channel, expecting standard SI5");
832 /* activate the logical channel */
833 f_est_dchan();
834 /* check that the specified SI5 value is actually sent */
835 f_sacch_present(si5);
836
837 /* set channel-specific different SI5 */
838 log("Setting channel specific SACCH INFO, expecting it");
839 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
840 /* check that the specified lchan-specific value is now used */
841 f_sacch_present(si5_diff);
842
843 /* deactivate the channel and re-activate it, this should result in default SI5 */
844 log("De-activating and re-activating channel, expecting standard SI5");
845 f_rsl_chan_deact();
846 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
847 /* Verify that the TRX-wide default SACCH filling is present again */
848 f_sacch_present(si5);
849
850 /* release the channel */
851 RSL.clear;
852 f_rsl_chan_deact();
853 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
854}
855testcase TC_sacch_info_mod() runs on test_CT {
856 var ConnHdlr vc_conn;
857 var ConnHdlrPars pars;
858 f_init();
859 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
860 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
861 log(testcasename(), ": Starting for ", g_AllChannels[i]);
862 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
863 vc_conn.done;
864 }
865 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200866 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100867}
868
Harald Welte075d84c2018-03-12 13:07:24 +0100869/* Test SACCH scheduling of multiple different SI message types */
870private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
871 var octetstring si5 := f_rnd_octstring(19);
872 var octetstring si5bis := f_rnd_octstring(19);
873 var octetstring si5ter := f_rnd_octstring(19);
874 var octetstring si6 := f_rnd_octstring(19);
875
876 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
877 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
878 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
879 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
880
881 f_l1_tune(L1CTL);
882 RSL.clear;
883
884 /* activate the logical channel */
885 f_est_dchan();
886 L1CTL.clear;
887
888 /* check that SACCH actually are received as expected */
889 f_sacch_present(si5);
890 f_sacch_present(si5bis);
891 f_sacch_present(si5ter);
892 f_sacch_present(si6);
893
894 /* release the channel */
895 f_rsl_chan_deact();
896 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
897}
898testcase TC_sacch_multi() runs on test_CT {
899 var ConnHdlr vc_conn;
900 var ConnHdlrPars pars;
901 f_init();
902 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
903 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
904 log(testcasename(), ": Starting for ", g_AllChannels[i]);
905 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
906 vc_conn.done;
907 }
908 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200909 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100910}
911
Harald Welte55700662018-03-12 13:15:43 +0100912/* Test if SACH information is modified as expected */
913private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
914 var octetstring si5 := f_rnd_octstring(19);
915 var octetstring si6 := f_rnd_octstring(19);
916
917 /* First, configure both SI5 and SI6 to be transmitted */
918 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
919 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
920
921 f_l1_tune(L1CTL);
922 RSL.clear;
923
924 /* activate the logical channel */
925 f_est_dchan();
926 L1CTL.clear;
927
928 /* check that SACCH actually are received as expected */
929 f_sacch_present(si5);
930 f_sacch_present(si6);
931
932 /* disable SI6 */
933 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
934
935 /* check that SI5 is still transmitted */
936 f_sacch_present(si5);
937 /* check if SI6 is now gone */
938 f_sacch_missing(si6);
939
940 /* release the channel */
941 f_rsl_chan_deact();
942 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
943}
944testcase TC_sacch_multi_chg() runs on test_CT {
945 var ConnHdlr vc_conn;
946 var ConnHdlrPars pars;
947 f_init();
948 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
949 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
950 log(testcasename(), ": Starting for ", g_AllChannels[i]);
951 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
952 vc_conn.done;
953 }
954 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200955 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +0100956}
957
Harald Welte075d84c2018-03-12 13:07:24 +0100958/* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
959/* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
Harald Welte629cc6b2018-03-11 17:19:05 +0100960
961
962/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100963 * RACH Handling
964 ***********************************************************************/
965
Harald Welte8c24c2b2018-02-26 08:31:31 +0100966/* like L1SAP_IS_PACKET_RACH */
967private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100968 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100969 return true;
970 }
971 return false;
972}
973
974/* generate a random RACH for circuit-switched */
975private function f_rnd_ra_cs() return OCT1 {
976 var OCT1 ra;
977 do {
978 ra := f_rnd_octstring(1);
979 } while (ra_is_ps(ra));
980 return ra;
981}
982
Harald Welte883340c2018-02-28 18:59:29 +0100983/* generate a random RACH for packet-switched */
984private function f_rnd_ra_ps() return OCT1 {
985 var OCT1 ra;
986 do {
987 ra := f_rnd_octstring(1);
988 } while (not ra_is_ps(ra));
989 return ra;
990}
991
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +0700992/* generate a random 11-bit RA (packet-switched only) */
993private function f_rnd_ra11_ps() return BIT11 {
994 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
995 return int2bit(ra11, 11);
996}
997
Harald Welte8c24c2b2018-02-26 08:31:31 +0100998/* Send 1000 RACH requests and check their RA+FN on the RSL side */
999testcase TC_rach_content() runs on test_CT {
1000 f_init(testcasename());
1001 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001002 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001003
Harald Welte8c24c2b2018-02-26 08:31:31 +01001004 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001005 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001006 for (var integer i := 0; i < 1000; i := i+1) {
1007 var OCT1 ra := f_rnd_ra_cs();
1008 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1009 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001010 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001011 }
1012 fn_last := fn;
1013
1014 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001015 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001016 alt {
1017 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1018 T.stop;
1019 }
1020 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001021 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001022 }
1023 [] RSL_CCHAN.receive { repeat; }
1024 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001025 test_failed := true;
1026 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001027 }
1028 }
1029 }
Maxba06feb2019-03-05 10:52:46 +01001030 if (test_failed) {
1031 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001032 }
Maxba06feb2019-03-05 10:52:46 +01001033 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001034 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001035}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001036
1037/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1038testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001039 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001040 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001041 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001042 f_l1_tune(L1CTL);
1043
1044 var GsmFrameNumber fn_last := 0;
1045 for (var integer i := 0; i < 1000; i := i+1) {
1046 var OCT1 ra := f_rnd_ra_cs();
1047 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1048 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001049 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001050 }
1051 fn_last := fn;
1052 }
1053 var integer rsl_chrqd := 0;
1054 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001055 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001056 alt {
1057 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1058 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001059 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001060 repeat;
1061 }
1062 [] RSL_CCHAN.receive { repeat; }
1063 [] T.timeout { }
1064 }
1065 if (rsl_chrqd == 1000) {
1066 setverdict(pass);
1067 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001068 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001069 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001070 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001071}
1072
Harald Welte54a2a2d2018-02-26 09:14:05 +01001073private function f_main_trxc_connect() runs on test_CT {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001074 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001075 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001076 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Welted3a88a62018-03-01 16:04:52 +01001077 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001078 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001079 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 +02001080 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001081 g_bts_trxc_conn_id := res.connId;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001082}
1083
1084private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001085 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001086 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001087 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001088 f_sleep(0.5);
1089
1090 /* Transmit RACH request + wait for confirmation */
1091 var OCT1 ra := f_rnd_ra_cs();
1092 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1093
1094 /* Check for expected result */
1095 timer T := 1.5;
1096 T.start;
1097 alt {
1098 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1099 setverdict(pass);
1100 }
1101 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001102 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001103 }
1104 [] RSL_CCHAN.receive { repeat; }
1105 [not expect_pass] T.timeout {
1106 setverdict(pass);
1107 }
1108 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001109 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001110 }
1111 }
1112}
1113
1114/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1115testcase TC_rach_max_ta() runs on test_CT {
1116 f_init(testcasename());
1117 f_init_l1ctl();
1118 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001119 f_sleep(1.0);
1120
1121 /* default max-ta is 63 (full range of GSM timing advance */
1122
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001123 /* We allow early arrival up to 2 symbols */
1124 f_rach_toffs(-1*256, true);
1125 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001126 f_rach_toffs(-10*256, false);
1127
1128 /* 0 / 32 / 63 bits is legal / permitted */
1129 f_rach_toffs(0, true);
1130 f_rach_toffs(32*256, true);
1131 f_rach_toffs(63*256, true);
1132
1133 /* more than 63 bits is not legal / permitted */
1134 f_rach_toffs(64*256, false);
1135 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001136 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001137}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001138
Harald Welte93640c62018-02-25 16:59:33 +01001139/***********************************************************************
1140 * Measurement Processing / Reporting
1141 ***********************************************************************/
1142
Harald Welte70767382018-02-21 12:16:40 +01001143template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1144 spare := '0'B,
1145 lpd := 0,
1146 sapi := sapi,
1147 c_r := c_r,
1148 ea := true
1149}
1150
Harald Welted879bd92018-03-12 15:01:23 +01001151template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001152 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001153 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001154 len := 0, /* overwritten */
1155 m := false,
1156 el := 1,
1157 payload := pl
1158}
1159
1160/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1161altstep as_l1_sacch() runs on ConnHdlr {
1162 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001163 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001164 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001165 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 +01001166 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001167 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001168
1169 var L1ctlDataReq data_req := {
1170 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1171 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1172 }
1173 log("Sending Measurement Report: ", data_req);
1174 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001175 repeat;
1176 }
1177}
1178
1179altstep as_l1_dcch() runs on ConnHdlr {
1180 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001181 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001182 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1183 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001184 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1185 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001186 repeat;
1187 }
1188}
1189
1190type record MeasElem {
1191 uint6_t rxlev,
1192 uint3_t rxqual
1193}
1194
1195type record MeasElemFS {
1196 MeasElem full,
1197 MeasElem sub
1198}
1199
1200type record ConnL1Pars {
1201 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001202 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001203 MeasElemFS meas_ul,
1204 int16_t timing_offset_256syms,
1205 uint5_t bs_power_level,
1206 uint5_t ms_power_level,
1207 uint8_t ms_actual_ta
1208}
1209
1210/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1211private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1212 return 63 + (toffs256s/256);
1213}
1214
Harald Welted5684392018-03-10 18:22:04 +01001215private function f_max(integer a, integer b) return integer {
1216 if (a > b) {
1217 return a;
1218 } else {
1219 return b;
1220 }
1221}
1222
1223private function f_min(integer a, integer b) return integer {
1224 if (a < b) {
1225 return a;
1226 } else {
1227 return b;
1228 }
1229}
1230
1231/* compute negative tolerance val-tolerance, ensure >= min */
1232private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1233 val := val - tolerance;
1234 return f_max(val, min);
1235}
1236
1237/* compute positive tolerance val+tolerance, ensure <= max */
1238private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1239 val := val + tolerance;
1240 return f_min(val, max);
1241}
1242
1243/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1244private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1245return template integer {
1246 var template integer ret;
1247 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1248 return ret;
1249}
1250
1251
Harald Welte70767382018-02-21 12:16:40 +01001252/* build a template for matching measurement results against */
1253private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1254 var ConnL1Pars l1p := g_pars.l1_pars;
1255 var template RSL_IE_UplinkMeas ul_meas := {
1256 len := 3,
1257 rfu := '0'B,
1258 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001259 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001260 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001261 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001262 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001263 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1264 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001265 supp_meas_info := omit
1266 };
Harald Welte685d5982018-02-27 20:42:05 +01001267 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001268 ul_meas.len := (3+8);
1269 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001270 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001271 toa256_min := ?,
1272 toa256_max := ?,
1273 toa256_std_dev := ?
1274 }
Harald Welte685d5982018-02-27 20:42:05 +01001275 }
Harald Welte70767382018-02-21 12:16:40 +01001276 var template RSL_IE_BS_Power bs_power := {
1277 reserved := 0,
1278 epc := false,
1279 fpc := false,
1280 power_level := l1p.bs_power_level
1281 };
1282 var template RSL_IE_L1Info l1_info := {
1283 ms_power_lvl := l1p.ms_power_level,
1284 fpc := false,
1285 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001286 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001287 };
1288 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001289 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001290 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1291 ?, t_toffs);
1292}
1293
1294/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001295altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001296 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001297 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001298 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1299 /* increment counter of next to-be-expected meas rep */
1300 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1301 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001302 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001303 repeat;
1304 }
1305 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001306 /* increment counter of next to-be-expected meas rep */
1307 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1308 if (g_first_meas_res) {
1309 g_first_meas_res := false;
1310 repeat;
1311 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001312 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001313 }
Harald Welte70767382018-02-21 12:16:40 +01001314 }
1315 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001316 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001317 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001318 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001319 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001320 }
1321}
1322
Harald Weltee613f962018-04-18 22:38:16 +02001323private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1324 select (rsl_alg_id) {
1325 case (RSL_ALG_ID_A5_0) { return 0; }
1326 case (RSL_ALG_ID_A5_1) { return 1; }
1327 case (RSL_ALG_ID_A5_2) { return 2; }
1328 case (RSL_ALG_ID_A5_3) { return 3; }
1329 case (RSL_ALG_ID_A5_4) { return 4; }
1330 case (RSL_ALG_ID_A5_5) { return 5; }
1331 case (RSL_ALG_ID_A5_6) { return 6; }
1332 case (RSL_ALG_ID_A5_7) { return 7; }
1333 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001334 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1335 /* Make compiler happy by calling mtc.stop here. It is already
1336 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001337 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001338 }
1339 }
1340}
1341
1342private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1343 select (rsl_alg_id) {
1344 case (RSL_ALG_ID_A5_1) { return '000'B; }
1345 case (RSL_ALG_ID_A5_2) { return '001'B; }
1346 case (RSL_ALG_ID_A5_3) { return '010'B; }
1347 case (RSL_ALG_ID_A5_4) { return '011'B; }
1348 case (RSL_ALG_ID_A5_5) { return '100'B; }
1349 case (RSL_ALG_ID_A5_6) { return '101'B; }
1350 case (RSL_ALG_ID_A5_7) { return '110'B; }
1351 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001352 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1353 /* Make compiler happy by calling mtc.stop here. It is already
1354 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001355 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001356 }
1357 }
1358}
1359
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001360/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1361private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1362 var GsmFrameNumber fn;
1363 timer T := 8.0;
1364
1365 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1366 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1367
1368 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1369 /* Send the actual RACH */
1370 fn := f_L1CTL_RACH(L1CTL, ra);
1371
1372 T.start;
1373 alt {
1374 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1375 [] T.timeout {
1376 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1377 }
1378 }
1379 T.stop
1380 return fn;
1381}
Harald Weltee613f962018-04-18 22:38:16 +02001382
Harald Welte70767382018-02-21 12:16:40 +01001383/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltee613f962018-04-18 22:38:16 +02001384private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001385 var GsmFrameNumber fn;
1386 var ImmediateAssignment imm_ass;
1387 var integer ra := 23;
1388
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001389 /* Send RACH request and wait for ChanReq */
1390 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001391
1392 /* Activate channel on BTS side */
Harald Weltee613f962018-04-18 22:38:16 +02001393 f_rsl_chan_act(g_pars.chan_mode, encr_enable);
Harald Welte70767382018-02-21 12:16:40 +01001394
1395 /* Send IMM.ASS via CCHAN */
1396 var ChannelDescription ch_desc := {
1397 chan_nr := g_pars.chan_nr,
1398 tsc := 7,
1399 h := false,
1400 arfcn := mp_trx0_arfcn,
1401 maio_hsn := omit
1402 };
1403 var MobileAllocation ma := {
1404 len := 0,
1405 ma := ''B
1406 };
1407 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1408 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1409
1410 /* receive IMM.ASS on MS side */
1411 var ImmediateAssignment ia_um;
1412 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1413 /* enable dedicated mode */
1414 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001415 /* enable encryption, if requested */
1416 if (encr_enable) {
1417 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1418 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1419 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001420
1421 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001422}
1423
1424/* establish DChan, verify existance + contents of measurement reports */
1425function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001426 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001427 RSL.clear;
1428
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001429 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001430 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001431 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1432 }
Harald Welte70767382018-02-21 12:16:40 +01001433
1434 f_est_dchan();
1435
1436 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1437 * RSL measurement reports on Abis side */
1438 timer T := 8.0;
1439 T.start;
1440 alt {
1441 [] as_l1_sacch();
1442 [] as_meas_res();
1443 [] as_l1_dcch();
1444 [] L1CTL.receive { repeat; }
1445 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001446 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001447 * of any earlier errors, so if we reach this timeout, we're good */
1448 setverdict(pass);
1449 }
1450 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001451 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001452 }
1453 }
1454 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001455 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001456}
Harald Welte0472ab42018-03-12 15:02:26 +01001457
Harald Welte70767382018-02-21 12:16:40 +01001458testcase TC_meas_res_sign_tchf() runs on test_CT {
1459 var ConnHdlr vc_conn;
1460 var ConnHdlrPars pars;
1461 f_init(testcasename());
1462 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1463 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1464 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1465 vc_conn.done;
1466 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001467 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001468}
1469testcase TC_meas_res_sign_tchh() runs on test_CT {
1470 var ConnHdlr vc_conn;
1471 var ConnHdlrPars pars;
1472 f_init(testcasename());
1473 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1474 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1475 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1476 vc_conn.done;
1477 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001478 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001479}
1480testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1481 var ConnHdlr vc_conn;
1482 var ConnHdlrPars pars;
1483 f_init(testcasename());
1484 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1485 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1486 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1487 vc_conn.done;
1488 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001490}
1491testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1492 var ConnHdlr vc_conn;
1493 var ConnHdlrPars pars;
1494 f_init(testcasename());
1495 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1496 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1497 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1498 vc_conn.done;
1499 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001500 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001501}
Harald Welte685d5982018-02-27 20:42:05 +01001502testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1503 var ConnHdlr vc_conn;
1504 var ConnHdlrPars pars;
1505 f_init(testcasename());
1506 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1507 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1508 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1509 pars.l1_pars.toa256_enabled := true;
1510 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1511 vc_conn.done;
1512 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001513 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01001514}
1515
Philipp Maier4d1e9c92018-12-20 11:11:56 +01001516/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
1517 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
1518function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
1519 var L1ctlDlMessage l1_dl;
1520 var RSL_IE_MS_Power ms_power;
1521 var RSL_Message rsl;
1522 var uint5_t power_level := 0;
1523
1524 f_l1_tune(L1CTL);
1525 RSL.clear;
1526
1527 f_est_dchan();
1528
1529 ms_power.reserved := 0;
1530 ms_power.fpc_epc := false;
1531
1532 /* Send the first power control command. This will disable any BTS/TRX
1533 * internal power control and switch the MS (which is not in scope of
1534 * this test) to a constant power level. We start with a power level
1535 * of 0 */
1536 ms_power.power_level := power_level;
1537 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1538 RSL.send(rsl);
1539
1540 alt {
1541
1542 /* Pick all SACCH blocks for checking */
1543 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1544
1545 /* The first byte of the L1 header contains the power level.
1546 * The reserved bits and the fpc bit is set to 0, so we may
1547 * compare directly. */
1548 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
1549 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
1550 }
1551
1552 /* Signal a new power level via RSL for the next turn. */
1553 if (power_level < 31) {
1554 power_level := power_level + 1;
1555 ms_power.power_level := power_level;
1556 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1557 RSL.send(rsl);
1558 repeat;
1559 }
1560
1561 }
1562
1563 /* Ignore all other blocks */
1564 [] L1CTL.receive { repeat; }
1565
1566 }
1567
1568 f_rsl_chan_deact();
1569 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1570
1571 setverdict(pass);
1572}
1573
1574testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
1575 var ConnHdlr vc_conn;
1576 var ConnHdlrPars pars;
1577 f_init(testcasename());
1578
1579 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1580 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1581 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
1582 vc_conn.done;
1583 }
1584 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1585}
Harald Welte70767382018-02-21 12:16:40 +01001586
Harald Welte0472ab42018-03-12 15:02:26 +01001587/* 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 +01001588private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001589 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001590 RSL.clear;
1591
1592 f_est_dchan();
1593 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001594 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001595
1596 timer T := 40.0;
1597 T.start;
1598 alt {
1599 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1600 setverdict(pass)
1601 }
1602 [] RSL.receive { repeat };
1603 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001604 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01001605 }
1606 }
1607 f_rsl_chan_deact();
1608}
1609testcase TC_conn_fail_crit() runs on test_CT {
1610 var ConnHdlr vc_conn;
1611 var ConnHdlrPars pars;
1612 f_init(testcasename());
1613 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1614 pars.t_guard := 60.0;
1615 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1616 vc_conn.done;
1617}
1618
Harald Welte93640c62018-02-25 16:59:33 +01001619/***********************************************************************
1620 * Paging
1621 ***********************************************************************/
1622
Harald Welte68e495b2018-02-25 00:05:57 +01001623function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1624 if (tmsi == 'FFFFFFFF'O) {
1625 return true;
1626 } else {
1627 return false;
1628 }
1629}
Harald Welte70767382018-02-21 12:16:40 +01001630
Philipp Maier82cb0b12018-08-31 14:41:39 +02001631type record allowedFn { integer frame_nr }
1632template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
1633template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
1634template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
1635template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
1636template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
1637template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
1638template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
1639template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
1640function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
1641{
1642 var integer frame_nr_51;
1643 frame_nr_51 := frame_nr mod 51
1644
1645 var allowedFn fn_check;
1646 fn_check.frame_nr := frame_nr_51;
1647
1648 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001649 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02001650 return;
1651 }
1652
1653 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
1654 return;
1655 }
1656 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
1657 return;
1658 }
1659 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
1660 return;
1661 }
1662 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
1663 return;
1664 }
1665 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
1666 return;
1667 }
1668 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
1669 return;
1670 }
1671 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
1672 return;
1673 }
1674 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
1675 return;
1676 }
1677
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001678 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02001679 return;
1680}
1681
1682altstep 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 +01001683runs on test_CT {
1684 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001685 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001686 repeat;
1687 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001688 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001689 var octetstring without_plen :=
1690 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1691 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02001692
1693 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
1694
Harald Welte68e495b2018-02-25 00:05:57 +01001695 if (match(rr, tr_PAGING_REQ1)) {
1696 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1697 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1698 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1699 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1700 }
1701 } else if (match(rr, tr_PAGING_REQ2)) {
1702 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1703 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1704 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1705 }
1706 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1707 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1708 }
1709 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1710 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1711 }
1712 } else if (match(rr, tr_PAGING_REQ3)) {
1713 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1714 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1715 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1716 }
1717 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1718 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1719 }
1720 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1721 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1722 }
1723 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1724 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1725 }
1726 }
1727 repeat;
1728 }
1729}
1730
1731type record PagingTestCfg {
1732 boolean combined_ccch,
1733 integer bs_ag_blks_res,
1734 float load_factor,
1735 boolean exp_load_ind,
1736 boolean exp_overload,
1737 boolean use_tmsi
1738}
1739
1740type record PagingTestState {
1741 integer num_paging_sent,
1742 integer num_paging_rcv_msgs,
1743 integer num_paging_rcv_ids,
1744 integer num_overload
1745}
1746
1747/* receive + ignore RSL RF RES IND */
1748altstep as_rsl_res_ind() runs on test_CT {
1749 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1750 repeat;
1751 }
1752}
1753
1754/* Helper function for paging related testing */
1755private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1756 f_init(testcasename());
1757 f_init_l1ctl();
1758 f_l1_tune(L1CTL);
1759
1760 var PagingTestState st := {
1761 num_paging_sent := 0,
1762 num_paging_rcv_msgs := 0,
1763 num_paging_rcv_ids := 0,
1764 num_overload := 0
1765 };
1766
1767 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1768 var float max_pch_imsi_per_sec;
1769 if (cfg.use_tmsi) {
1770 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1771 } else {
1772 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1773 }
1774 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1775 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001776 var float time_total := 20.0;
1777 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
1778 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01001779
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001780 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
1781 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01001782
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001783 timer T_itv := 0.0;
1784 T_itv.start;
1785 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01001786 alt {
1787 /* check for presence of CCCH LOAD IND (paging load) */
1788 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1789 st.num_overload := st.num_overload + 1;
1790 repeat;
1791 }
1792 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001793 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01001794 }
1795 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1796 log("Rx LOAD_IND");
1797 /* FIXME: analyze/verify interval + contents */
1798 repeat;
1799 }
1800 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02001801 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001802 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001803 [] T_itv.timeout {
1804 /* Send paging cmds based on elapsed time */
1805 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
1806 while (st.num_paging_sent < new_sent) {
1807 /* build mobile Identity */
1808 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1809 if (cfg.use_tmsi) {
1810 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1811 } else {
1812 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
1813 }
1814 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1815 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1816
1817 /* Send RSL PAGING COMMAND */
1818 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
1819
1820 st.num_paging_sent := st.num_paging_sent + 1;
1821 }
1822 if (st.num_paging_sent < pkt_total) {
1823 /* Wait for interval to next PAGING COMMAND */
1824 var float time_now := T_total.read;
1825 var float next_sched := int2float(st.num_paging_sent)*interval;
1826 if (next_sched > time_now) {
1827 T_itv.start(next_sched - time_now);
1828 } else {
1829 T_itv.start(0.0);
1830 }
1831 } else {
1832 /* We are done, no need to keep counting */
1833 T_total.stop;
1834 }
1835 }
1836 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01001837 [] as_rsl_res_ind();
1838 }
1839 }
1840
1841 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1842 timer T_wait := 18.0;
1843 T_wait.start;
1844 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02001845 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001846 [] L1CTL.receive { repeat; }
1847 /* 65535 == empty paging queue, we can terminate*/
1848 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1849 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1850 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001851 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01001852 }
1853 [] as_rsl_res_ind();
1854 }
1855
1856 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1857 " rcvd_ids=", st.num_paging_rcv_ids);
1858 return st;
1859}
1860
1861/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1862 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1863 * - that CCCH LOAD IND (PCH) are being generated
1864 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1865testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001866 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001867 var PagingTestCfg cfg := {
1868 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001869 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001870 load_factor := 0.8,
1871 exp_load_ind := true,
1872 exp_overload := false,
1873 use_tmsi := false
1874 };
1875 var PagingTestState st := f_TC_paging(cfg);
1876 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001877 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
1878 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01001879 } else {
1880 setverdict(pass);
1881 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001882 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001883}
1884
1885/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1886 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1887 * - that CCCH LOAD IND (PCH) are being generated
1888 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1889testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001890 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001891 var PagingTestCfg cfg := {
1892 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001893 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001894 load_factor := 0.8,
1895 exp_load_ind := true,
1896 exp_overload := false,
1897 use_tmsi := true
1898 };
1899 var PagingTestState st := f_TC_paging(cfg);
1900 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001901 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
1902 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01001903 } else {
1904 setverdict(pass);
1905 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001907}
1908
1909/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1910 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1911 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1912 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1913testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001914 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001915 var PagingTestCfg cfg := {
1916 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001917 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001918 load_factor := 2.0,
1919 exp_load_ind := true,
1920 exp_overload := true,
1921 use_tmsi := false
1922 };
1923 var PagingTestState st := f_TC_paging(cfg);
1924 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1925 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001926 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001927 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001928 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 +01001929 } else {
1930 setverdict(pass);
1931 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001932 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001933}
1934
1935/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1936 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1937 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1938 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1939testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001940 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001941 var PagingTestCfg cfg := {
1942 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001943 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001944 load_factor := 2.0,
1945 exp_load_ind := true,
1946 exp_overload := true,
1947 use_tmsi := true
1948 };
1949 var PagingTestState st := f_TC_paging(cfg);
1950 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1951 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001952 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001953 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001954 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 +01001955 } else {
1956 setverdict(pass);
1957 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001958 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001959}
1960
1961
Harald Welte93640c62018-02-25 16:59:33 +01001962/***********************************************************************
1963 * Immediate Assignment / AGCH
1964 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02001965const MobileAllocation c_MA_null := {
1966 len := 0,
1967 ma := ''B
1968}
Harald Welte93640c62018-02-25 16:59:33 +01001969
Harald Weltee8d750e2018-06-10 21:41:35 +02001970template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
1971 uint12_t arfcn := 871) := {
1972 chan_nr := chan_nr,
1973 tsc := tsc,
1974 h := false,
1975 arfcn := arfcn,
1976 maio_hsn := omit
1977}
1978
1979private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
1980 return int2str(num_tx) & " sent, "
1981 & int2str(num_rx) & " received, "
1982 & int2str(num_del) & " deleted";
1983}
1984
1985private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
1986 var L1ctlDlMessage l1_dl;
1987 timer T := 10.0;
1988 var integer num_tx := 0;
1989 var integer num_rx := 0;
1990 var integer num_del := 0;
1991 var charstring res_str;
1992 var float rx_ratio;
1993
Harald Welte68e495b2018-02-25 00:05:57 +01001994 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02001995 f_init_l1ctl();
1996 f_l1_tune(L1CTL);
1997
1998 for (var integer i := 0; i < num_total; i := i+1) {
1999 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
2000 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
2001 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01002002 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02002003 num_tx := num_tx+1;
2004 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01002005 }
2006 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02002007 T.start;
2008 alt {
2009 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
2010 num_del := num_del+1;
2011 repeat;
2012 }
2013 [] RSL_CCHAN.receive {
2014 repeat;
2015 }
2016 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
2017 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2018 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
2019 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
2020 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002021 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02002022 } else {
2023 num_rx := num_rx+1;
2024 }
2025 repeat;
2026 }
2027 [] L1CTL.receive { repeat; }
2028 [] T.timeout { }
2029 }
2030 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
2031 log("AGCH test: " & res_str);
2032 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002033 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002034 }
2035 rx_ratio := int2float(num_rx) / int2float(num_tx);
2036 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002037 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 +02002038 } else {
2039 setverdict(pass);
2040 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002041 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002042}
2043
Harald Weltee8d750e2018-06-10 21:41:35 +02002044/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
2045testcase TC_imm_ass_1000_20ms() runs on test_CT {
2046 f_TC_imm_ass(1000, 0.02, 0.25);
2047}
2048
2049/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
2050testcase TC_imm_ass_200_0ms() runs on test_CT {
2051 f_TC_imm_ass(200, 0.0, 0.05);
2052}
2053
2054/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
2055testcase TC_imm_ass_200_76ms() runs on test_CT {
2056 f_TC_imm_ass(150, 0.076, 1.00);
2057}
2058
2059
2060
Harald Welte48494ca2018-02-25 16:59:50 +01002061/***********************************************************************
2062 * BCCH
2063 ***********************************************************************/
2064
2065/* tuple of Frame Number + decoded SI */
2066type record SystemInformationFn {
2067 GsmFrameNumber frame_number,
2068 SystemInformation si
2069}
2070
2071/* an arbitrary-length vector of decoded SI + gsmtap header */
2072type record of SystemInformationFn SystemInformationVector;
2073
2074/* an array of SI-vectors indexed by TC value */
2075type SystemInformationVector SystemInformationVectorPerTc[8];
2076
2077/* determine if a given SI vector contains given SI type at least once */
2078function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2079 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2080 var integer fn_mod51 := arr[i].frame_number mod 51;
2081 if (not bcch_ext and fn_mod51 == 2 or
2082 bcch_ext and fn_mod51 == 6) {
2083 if (arr[i].si.header.message_type == key) {
2084 return true;
2085 }
2086 }
2087 }
2088 return false;
2089}
2090
2091/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2092function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2093 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002094 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002095 }
2096}
2097
2098/* check if a given SI vector contains given SI type at least once on any TC */
2099function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2100 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2101 if (f_si_vecslot_contains(arr[tc], key) or
2102 f_si_vecslot_contains(arr[tc], key, true)) {
2103 return true;
2104 }
2105 }
2106 return false;
2107}
2108
2109/* determine if a given SI vector contains given SI type at least N of M times */
2110function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2111 var integer count := 0;
2112 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002113 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01002114 }
2115 for (var integer i:= 0; i < m; i := i + 1) {
2116 var integer fn_mod51 := arr[i].frame_number mod 51;
2117 if (not bcch_ext and fn_mod51 == 2 or
2118 bcch_ext and fn_mod51 == 6) {
2119 if (arr[i].si.header.message_type == key) {
2120 count := count + 1;
2121 }
2122 }
2123 }
2124 if (count >= n) {
2125 return true;
2126 } else {
2127 return false;
2128 }
2129}
2130
2131/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2132function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2133 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002134 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002135 }
2136}
2137
2138/* determine if a given SI vector contains given SI type at least once */
2139function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2140 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2141 var integer fn_mod51 := arr[i].frame_number mod 51;
2142 if (not bcch_ext and fn_mod51 == 2 or
2143 bcch_ext and fn_mod51 == 6) {
2144 if (arr[i].si.header.message_type != key) {
2145 return false;
2146 }
2147 }
2148 }
2149 return true;
2150}
2151
2152/* ensure a given TC slot of the SI vector contains only given SI type */
2153function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2154 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002155 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002156 }
2157}
2158
2159/* SI configuration of cell, against which we validate actual SI messages */
2160type set SystemInformationConfig {
2161 boolean bcch_extended,
2162 boolean si1_present,
2163 boolean si2bis_present,
2164 boolean si2ter_present,
2165 boolean si2quater_present,
2166 boolean si7_present,
2167 boolean si8_present,
2168 boolean si9_present,
2169 boolean si13_present,
2170 boolean si13alt_present,
2171 boolean si15_present,
2172 boolean si16_present,
2173 boolean si17_present,
2174 boolean si2n_present,
2175 boolean si21_present,
2176 boolean si22_present
2177}
2178
2179/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2180function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2181 var integer i;
2182 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2183 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002184 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01002185 }
2186 }
2187 if (cfg.si1_present) {
2188 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2189 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2190 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2191 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2192 /* make sure *ALL* contain SI1 */
2193 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2194 }
2195 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2196 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2197 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2198 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2199 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2200 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2201
2202 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2203 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2204 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2205 * consecutive occurrences of TC = 4. */
2206 if (cfg.si2bis_present and not cfg.si2ter_present) {
2207 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2208 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2209 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2210 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2211 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2212 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2213 }
2214
2215 if (cfg.si7_present or cfg.si8_present) {
2216 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2217 * if System Information type 4 does not contain all information needed for cell
2218 * selection and reselection. */
2219 if (not cfg.bcch_extended) {
2220 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2221 }
2222 if (cfg.si7_present) {
2223 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2224 }
2225 if (cfg.si8_present) {
2226 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2227 }
2228 }
2229
2230 if (cfg.si2quater_present) {
2231 /* iii) System information type 2 quater is sent if needed, as determined by the system
2232 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2233 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2234 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2235 * within any of 4 consecutive occurrences of TC = 5. */
2236 if (not (cfg.bcch_extended)) {
2237 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2238 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2239 } else {
2240 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2241 }
2242 } else {
2243 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2244 }
2245 }
2246 if (cfg.si9_present) {
2247 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2248 * in system information type 3 as defined in 3GPP TS 44.018. */
2249 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2250 }
2251 if (cfg.si13_present) {
2252 /* vii) System Information type 13 is only related to the GPRS service. System Information
2253 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2254 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2255 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2256 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2257 * within any of 4 consecutive occurrences of TC=4. */
2258 if (not cfg.bcch_extended) {
2259 log("not-bccch-extended");
2260 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2261 } else {
2262 log("bccch-extended");
2263 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2264 }
2265 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002266 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002267 }
2268 }
2269 if (cfg.si16_present or cfg.si17_present) {
2270 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2271 * should not be sent in a cell where network sharing is used (see rule xv). */
2272 if (cfg.si22_present) {
2273 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2274 }
2275 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002276 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002277 }
2278 if (not cfg.bcch_extended) {
2279 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2280 }
2281 if (cfg.si16_present) {
2282 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2283 }
2284 if (cfg.si17_present) {
2285 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2286 }
2287 }
2288
2289 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2290 * broadcast information. The frequency with which they are sent is determined by the
2291 * system operator. System Information type 9 identifies the scheduling of System
2292 * Information type 18 and 20 messages. */
2293
2294 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2295 * Information Type 19 is present, then its scheduling shall be indicated in System
2296 * Information Type 9. */
2297
2298 if (cfg.si15_present) {
2299 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2300 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2301 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2302 * 4 consecutive occurrences of TC = 1. */
2303 if (not cfg.bcch_extended) {
2304 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2305 } else {
2306 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2307 }
2308 }
2309 if (cfg.si13alt_present) {
2310 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2311 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2312 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2313 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2314 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2315 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2316 * of TC = 4. */
2317 if (cfg.si13_present) {
2318 testcase.stop("Error: Cannot have SI13alt and SI13");
2319 }
2320 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002321 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002322 }
2323 if (not cfg.bcch_extended) {
2324 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2325 } else {
2326 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2327 }
2328 }
2329 if (cfg.si2n_present) {
2330 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2331 * as determined by the system operator. In the case that the message is sent on the
2332 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2333 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2334 * consecutive occurrences of TC = 4. */
2335 if (not cfg.bcch_extended) {
2336 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2337 } else {
2338 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2339 }
2340 }
2341 if (cfg.si21_present) {
2342 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2343 * determined by the system operator. If Extended Access Barring is in use in the cell
2344 * then this message is sent at least once within any of 4 consecutive occurrences of
2345 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2346 * cell then this message shall only be sent on BCCH Ext. */
2347 if (not cfg.bcch_extended) {
2348 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2349 } else {
2350 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2351 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002352 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01002353 }
2354 }
2355 }
2356 if (cfg.si22_present) {
2357 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2358 * should not be sent in a cell where SoLSA is used (see rule viii). System
2359 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2360 * =2 and TC=6. */
2361 if (cfg.si16_present or cfg.si17_present) {
2362 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2363 }
2364 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2365 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002366 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002367 }
2368 if (not cfg.bcch_extended) {
2369 testcase.stop("Error: SI22 requires BCCH Extd!");
2370 } else {
2371 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2372 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2373 }
2374 }
2375}
2376
2377/* sample Systme Information for specified duration via L1CTL */
2378function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2379 timer T := duration;
2380 var SystemInformationVectorPerTc si_per_tc;
2381 var L1ctlDlMessage l1_dl;
2382
2383 /* initialize all per-TC vectors empty */
2384 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2385 si_per_tc[i] := {};
2386 }
2387
2388 /* flush all previous L1 queued msgs */
2389 pt.clear;
2390
2391 T.start;
2392 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002393 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002394 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2395 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2396 log("Ignoring non-RR SI ", l1_dl);
2397 repeat;
2398 }
2399 var SystemInformationFn sig := {
2400 frame_number := l1_dl.dl_info.frame_nr,
2401 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2402 }
2403 var integer tc := f_gsm_compute_tc(sig.frame_number);
2404 log("SI received at TC=", tc, ": ", sig.si);
2405 /* append to the per-TC bucket */
2406 si_per_tc[tc] := si_per_tc[tc] & { sig };
2407 repeat;
2408 }
2409 [] pt.receive { repeat; }
2410 [] T.timeout { }
2411 }
2412
2413 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2414 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2415 }
2416 log("si_per_tc=", si_per_tc);
2417 return si_per_tc;
2418}
2419
2420/* helper function: Set given SI via RSL + validate scheduling.
2421 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2422function f_TC_si_sched() runs on test_CT {
2423 var SystemInformationVectorPerTc si_per_tc;
2424 f_init_l1ctl();
2425 f_l1_tune(L1CTL);
2426
2427 /* Sample + Validate Scheduling */
2428 si_per_tc := f_l1_sample_si(L1CTL);
2429 f_validate_si_scheduling(si_cfg, si_per_tc);
2430
2431 setverdict(pass);
2432}
2433
2434testcase TC_si_sched_default() runs on test_CT {
2435 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002436 /* 2+3+4 are mandatory and set in f_init() */
2437 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002438 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01002439}
2440
2441testcase TC_si_sched_1() runs on test_CT {
2442 f_init();
2443 si_cfg.si1_present := true;
2444 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002445 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002446 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002447}
2448
2449testcase TC_si_sched_2bis() runs on test_CT {
2450 f_init();
2451 si_cfg.si2bis_present := true;
2452 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2453 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002454 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002455}
2456
2457testcase TC_si_sched_2ter() runs on test_CT {
2458 f_init();
2459 si_cfg.si2ter_present := true;
2460 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2461 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002462 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002463}
2464
2465testcase TC_si_sched_2ter_2bis() runs on test_CT {
2466 f_init();
2467 si_cfg.si2bis_present := true;
2468 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2469 si_cfg.si2ter_present := true;
2470 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2471 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002472 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002473}
2474
2475testcase TC_si_sched_2quater() runs on test_CT {
2476 f_init();
2477 si_cfg.si2quater_present := true;
2478 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2479 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002480 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002481}
2482
2483testcase TC_si_sched_13() runs on test_CT {
2484 f_init();
2485 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002486 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002487 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002488 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002489}
2490
2491testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2492 f_init();
2493 si_cfg.si2bis_present := true;
2494 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2495 si_cfg.si2ter_present := true;
2496 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2497 si_cfg.si2quater_present := true;
2498 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2499 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002500 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002501 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002502 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002503}
2504
2505
Harald Welte68e495b2018-02-25 00:05:57 +01002506testcase TC_bcch_info() runs on test_CT {
2507 f_init(testcasename());
2508 /* FIXME: enable / disable individual BCCH info */
2509 //ts_RSL_BCCH_INFO(si_type, info);
2510 /* expect no ERROR REPORT after either of them *
2511 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002512 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002513}
2514
Harald Welte93640c62018-02-25 16:59:33 +01002515/***********************************************************************
2516 * Low-Level Protocol Errors / ERROR REPORT
2517 ***********************************************************************/
2518
Harald Welte01d982c2018-02-25 01:31:40 +01002519private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2520 timer T := 5.0;
2521 T.start;
2522 alt {
2523 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2524 setverdict(pass);
2525 }
2526 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002527 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002528 }
2529 [] RSL_CCHAN.receive {
2530 repeat;
2531 }
2532 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002533 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002534 }
2535 }
2536}
2537
2538/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2539testcase TC_rsl_protocol_error() runs on test_CT {
2540 f_init(testcasename());
2541 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2542 rsl.ies := omit;
2543 RSL_CCHAN.send(ts_RSL_UD(rsl));
2544
2545 f_exp_err_rep(RSL_ERR_PROTO);
2546}
2547
2548/* Provoke a mandatory IE error and match on ERROR REPORT */
2549testcase TC_rsl_mand_ie_error() runs on test_CT {
2550 f_init(testcasename());
2551
2552 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2553 rsl.ies := { rsl.ies[0] };
2554 RSL_CCHAN.send(ts_RSL_UD(rsl));
2555
2556 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2557}
2558
2559/* Provoke an IE content error and match on ERROR REPORT */
2560testcase TC_rsl_ie_content_error() runs on test_CT {
2561 f_init(testcasename());
2562 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2563 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2564 RSL_CCHAN.send(ts_RSL_UD(rsl));
2565
2566 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2567}
2568
Harald Welte93640c62018-02-25 16:59:33 +01002569/***********************************************************************
2570 * IPA CRCX/MDCX/DLCS media stream handling
2571 ***********************************************************************/
2572
Harald Weltea871a382018-02-25 02:03:14 +01002573/* Send IPA DLCX to inactive lchan */
2574function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01002575 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2576 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01002577}
2578testcase TC_ipa_dlcx_not_active() runs on test_CT {
2579 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2580 f_init(testcasename());
2581 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
2582 vc_conn.done;
2583}
Harald Welte68e495b2018-02-25 00:05:57 +01002584
Harald Weltea3f1df92018-02-25 12:49:55 +01002585/* Send IPA CRCX twice to inactive lchan */
2586function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
2587 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2588 "IPA CRCX ACK");
2589 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
2590 "IPA CRCX NACK");
2591}
2592testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
2593 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2594 f_init(testcasename());
2595 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
2596 vc_conn.done;
2597}
2598
2599/* Regular sequence of CRCX/MDCX/DLCX */
2600function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2601 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2602 "IPA CRCX ACK");
2603 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2604 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2605 var uint7_t rtp_pt2 := f_rnd_int(127);
2606 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2607 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2608 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2609 "IPA MDCX ACK");
2610 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2611 "IPA DLCX ACK");
2612}
2613testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
2614 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2615 f_init(testcasename());
2616 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
2617 vc_conn.done;
2618}
2619
Harald Welte3ae11da2018-02-25 13:36:06 +01002620/* Sequence of CRCX, 2x MDCX, DLCX */
2621function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2622 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2623 "IPA CRCX ACK");
2624 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2625 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2626 var uint7_t rtp_pt2 := f_rnd_int(127);
2627 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2628 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2629 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2630 "IPA MDCX ACK");
2631 /* Second MDCX */
2632 remote_ip := f_rnd_int(c_UINT32_MAX);
2633 remote_port := f_rnd_int(c_UINT16_MAX);
2634 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2635 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2636 "IPA MDCX ACK");
2637 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2638 "IPA DLCX ACK");
2639}
2640testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2641 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2642 f_init(testcasename());
2643 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2644 vc_conn.done;
2645}
2646
Harald Welte9912eb52018-02-25 13:30:15 +01002647/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2648function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2649 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2650 "IPA CRCX NACK");
2651}
2652testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2653 var ConnHdlrPars pars;
2654 var ConnHdlr vc_conn;
2655 f_init(testcasename());
2656
2657 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2658 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2659 vc_conn.done;
2660
2661 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2662 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2663 vc_conn.done;
2664}
2665
Harald Weltea3f1df92018-02-25 12:49:55 +01002666
Harald Welte883340c2018-02-28 18:59:29 +01002667/***********************************************************************
2668 * PCU Socket related tests
2669 ***********************************************************************/
2670
2671private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2672runs on test_CT {
2673 timer T := 3.0;
2674
2675 /* we don't expect any RTS.req before PDCH are active */
2676 T.start;
2677 alt {
2678 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01002680 }
2681 [] PCU.receive { repeat; }
2682 [] T.timeout { }
2683 }
2684
2685 /* Send PDCH activate request for known PDCH timeslot */
2686 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2687
2688 /* we now expect RTS.req for this timeslot (only) */
2689 T.start;
2690 alt {
2691 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2692 setverdict(pass);
2693 }
2694 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2695 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002696 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01002697 }
2698 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002699 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01002700 }
2701 [] PCU.receive { repeat; }
2702 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002703 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01002704 }
2705 [not exp_success] T.timeout {
2706 setverdict(pass);
2707 }
2708 }
2709}
2710
2711private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2712runs on test_CT {
2713 timer T := 3.0;
2714
2715 /* Send PDCH activate request for known PDCH timeslot */
2716 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2717
2718 PCU.clear;
2719 /* we now expect no RTS.req for this timeslot */
2720 T.start;
2721 alt {
2722 [] 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 +02002723 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01002724 }
2725 [] PCU.receive { repeat; }
2726 [] T.timeout {
2727 setverdict(pass);
2728 }
2729 }
2730}
2731
Max2c6f5632019-03-18 17:25:17 +01002732private function f_init_pcu_test() runs on test_CT {
2733 f_init();
2734 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
2735}
2736
Harald Welte883340c2018-02-28 18:59:29 +01002737/* PDCH activation via PCU socket; check for presence of RTS.req */
2738testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002739 f_init_pcu_test();
2740
Harald Welte883340c2018-02-28 18:59:29 +01002741 f_TC_pcu_act_req(0, 0, 7, true);
2742}
2743
2744/* PDCH activation via PCU socket on non-PDCU timeslot */
2745testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002746 f_init_pcu_test();
2747
Harald Welte883340c2018-02-28 18:59:29 +01002748 f_TC_pcu_act_req(0, 0, 1, false);
2749}
2750
2751/* PDCH activation via PCU socket on wrong BTS */
2752testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002753 f_init_pcu_test();
2754
Harald Welte883340c2018-02-28 18:59:29 +01002755 f_TC_pcu_act_req(23, 0, 7, false);
2756}
2757
2758/* PDCH activation via PCU socket on wrong TRX */
2759testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002760 f_init_pcu_test();
2761
Harald Welte883340c2018-02-28 18:59:29 +01002762 f_TC_pcu_act_req(0, 23, 7, false);
2763}
2764
2765/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2766testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002767 f_init_pcu_test();
2768
Harald Welte883340c2018-02-28 18:59:29 +01002769 /* Activate PDCH */
2770 f_TC_pcu_act_req(0, 0, 7, true);
2771 f_sleep(1.0);
2772 /* and De-Activate again */
2773 f_TC_pcu_deact_req(0, 0, 7);
2774}
2775
2776/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2777testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002778 f_init_pcu_test();
2779
Harald Welte883340c2018-02-28 18:59:29 +01002780 f_TC_pcu_deact_req(0, 0, 1);
2781}
2782
2783/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2784testcase TC_pcu_ver_si13() runs on test_CT {
2785 const octetstring si13 := '00010203040506070909'O;
2786 var PCUIF_send_data sd;
2787 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01002788 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002789
2790 /* Set SI13 via RSL */
2791 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01002792
Harald Welte883340c2018-02-28 18:59:29 +01002793 T.start;
2794 alt {
2795 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2796 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2797 setverdict(pass);
2798 } else {
2799 repeat;
2800 }
2801 }
2802 [] PCU.receive { repeat; }
2803 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002804 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01002805 }
2806 }
2807}
2808
2809private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2810
2811/* helper function to send a PCU DATA.req */
2812private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2813 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2814runs on test_CT
2815{
2816 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2817 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2818}
2819
2820/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2821private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2822 PCUIF_Sapi sapi, octetstring data)
2823runs on test_CT
2824{
2825 var PCUIF_send_data sd;
2826
2827 timer T := 3.0;
2828 T.start;
2829 alt {
2830 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2831 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2832 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2833 sd.data.u.rts_req.fn, sapi, data);
2834 }
2835 [] PCU.receive { repeat; }
2836 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002837 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01002838 }
2839 }
2840}
2841
2842/* Send DATA.req on invalid BTS */
2843testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002844 f_init_pcu_test();
2845
Harald Welte883340c2018-02-28 18:59:29 +01002846 f_TC_pcu_act_req(0, 0, 7, true);
2847 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2848 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2849 f_sleep(10.0);
2850}
2851
2852/* Send DATA.req on invalid TRX */
2853testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002854 f_init_pcu_test();
2855
Harald Welte883340c2018-02-28 18:59:29 +01002856 f_TC_pcu_act_req(0, 0, 7, true);
2857 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2858 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2859 f_sleep(10.0);
2860}
2861
2862/* Send DATA.req on invalid timeslot */
2863testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002864 f_init_pcu_test();
2865
Harald Welte883340c2018-02-28 18:59:29 +01002866 f_TC_pcu_act_req(0, 0, 7, true);
2867 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2868 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2869 f_sleep(10.0);
2870}
2871
2872/* Send DATA.req on timeslot that hasn't been activated */
2873testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002874 f_init_pcu_test();
2875
Harald Welte883340c2018-02-28 18:59:29 +01002876 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2877 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2878 f_sleep(2.0);
2879}
2880
2881testcase TC_pcu_data_req_pdtch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002882 f_init_pcu_test();
2883
Harald Welte883340c2018-02-28 18:59:29 +01002884 f_TC_pcu_act_req(0, 0, 7, true);
2885 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2886 /* FIXME: how to check this was actually sent */
2887 f_sleep(2.0);
2888}
2889
2890testcase TC_pcu_data_req_ptcch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002891 f_init_pcu_test();
2892
Harald Welte883340c2018-02-28 18:59:29 +01002893 f_TC_pcu_act_req(0, 0, 7, true);
2894 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2895 /* FIXME: how to check this was actually sent */
2896 f_sleep(2.0);
2897}
2898
2899/* Send AGCH from PCU; check it appears on Um side */
2900testcase TC_pcu_data_req_agch() runs on test_CT {
2901 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01002902 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002903 f_init_l1ctl();
2904 f_l1_tune(L1CTL);
2905
2906 f_TC_pcu_act_req(0, 0, 7, true);
2907 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2908
2909 T.start;
2910 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002911 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002912 setverdict(pass);
2913 }
2914 [] L1CTL.receive { repeat; }
2915 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002916 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01002917 }
2918 }
2919}
2920
2921/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2922testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2923 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01002924 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002925 f_init_l1ctl();
2926 f_l1_tune(L1CTL);
2927
2928 /* append 3 last imsi digits so BTS can compute pagng group */
2929 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2930
2931 timer T := 0.5;
2932 T.start;
2933 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002934 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002935 /* TODO: verify paging group */
2936 setverdict(pass);
2937 }
2938 [] L1CTL.receive { repeat; }
2939 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002940 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01002941 }
2942 }
2943}
2944
2945/* Send RACH from Um side, expect it to show up on PCU socket */
2946testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002947 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002948 f_init_l1ctl();
2949 f_l1_tune(L1CTL);
2950
2951 var GsmFrameNumber fn_last := 0;
2952 for (var integer i := 0; i < 1000; i := i+1) {
2953 var OCT1 ra := f_rnd_ra_ps();
2954 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2955 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002956 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01002957 }
2958 fn_last := fn;
2959
2960 timer T := 2.0;
2961 T.start;
2962 alt {
2963 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2964 T.stop;
2965 }
2966 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002967 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01002968 }
2969 [] PCU.receive { repeat; }
2970 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002971 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01002972 }
2973 }
2974 }
2975 setverdict(pass);
2976}
2977
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07002978/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
2979 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
2980testcase TC_pcu_ext_rach_content() runs on test_CT {
2981 var template PCUIF_Message pcu_rach_ind;
2982 var GsmFrameNumber fn_last := 0;
2983 var L1ctlRachSynchSeq synch_seq;
2984 var PCUIF_BurstType pcu_bt;
2985 var GsmFrameNumber fn;
2986 var BIT11 ra11;
2987
2988 f_init_pcu_test();
2989 f_init_l1ctl();
2990 f_l1_tune(L1CTL);
2991
2992 for (var integer i := 0; i < 1000; i := i+1) {
2993 /* We need to test both TS1 & TS2 */
2994 if (i rem 2 == 0) {
2995 synch_seq := RACH_SYNCH_SEQ_TS1;
2996 pcu_bt := BURST_TYPE_1;
2997 } else {
2998 synch_seq := RACH_SYNCH_SEQ_TS2;
2999 pcu_bt := BURST_TYPE_2;
3000 }
3001
3002 ra11 := f_rnd_ra11_ps();
3003 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
3004 if (fn == fn_last) {
3005 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3006 "Two RACH in same FN?!?");
3007 }
3008 fn_last := fn;
3009
3010 /* Compose the expected message */
3011 pcu_rach_ind := tr_PCUIF_RACH_IND(
3012 bts_nr := 0,
3013 ra := bit2int(ra11),
3014 is_11bit := 1,
3015 burst_type := pcu_bt,
3016 fn := fn);
3017
3018 timer T := 2.0;
3019 T.start;
3020 alt {
3021 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
3022 T.stop;
3023 }
3024 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
3025 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
3026 }
3027 [] PCU.receive { repeat; }
3028 [] T.timeout {
3029 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
3030 }
3031 }
3032 }
3033 setverdict(pass);
3034}
3035
Harald Welte883340c2018-02-28 18:59:29 +01003036private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
3037 var integer strlen := lengthof(str);
3038 for (var integer i := 0; i < len-strlen; i := i+1) {
3039 str := str & pad;
3040 }
3041 return str;
3042}
3043
3044/* Send PAGING via RSL, expect it to shw up on PCU socket */
3045testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003046 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003047
3048 for (var integer i := 0; i < 100; i := i+1) {
3049 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
3050 timer T := 3.0;
3051 if (i < 50) {
3052 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
3053 } else {
3054 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
3055 }
3056 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
3057 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
3058 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
3059
3060 /* Send RSL PAGING COMMAND */
3061 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
3062 T.start;
3063 alt {
3064 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
3065 }
3066 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003067 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003068 }
3069 [] PCU.receive { repeat; }
3070 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003071 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003072 }
3073 }
3074 }
3075 setverdict(pass);
3076}
3077
Harald Welte3d04ae62018-04-04 20:29:05 +02003078/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02003079 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02003080 ***********************************************************************/
3081
3082private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3083runs on ConnHdlr {
3084 var PCUIF_send_data sd;
3085 /* Expect BTS to immediately acknowledge activation as PDCH */
3086 PCU.clear;
3087 f_rsl_chan_act(g_pars.chan_mode);
3088 /* expect INFO_IND on PCU interface listing TS as PDCH */
3089 alt {
3090 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3091 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 +02003092 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003093 }
3094 }
3095 [] PCU.receive { repeat; }
3096 }
3097 /* try to activate this PDCH from the PCU point of view */
3098 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3099 /* FIXME: is there a response? */
3100}
3101
3102private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3103runs on ConnHdlr {
3104 var PCUIF_send_data sd;
3105 /* Send RSL CHAN REL (deactivate) */
3106 PCU.clear;
3107 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3108 /* expect BTS to ask PCU to deactivate the channel */
3109 alt {
3110 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3111 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 +02003112 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003113 }
3114 }
3115 [] PCU.receive { repeat; }
3116 }
3117 /* Emulate PCU asking BTS to deactivate PDCH */
3118 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3119 alt {
3120 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
3121 setverdict(pass);
3122 }
3123 [] RSL.receive { repeat; }
3124 }
3125}
3126
3127/* Activate Osmocom-style dynamic PDCH from BSC side */
3128function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3129 var PCUIF_Message first_info;
3130 var integer ts_nr := g_chan_nr.tn;
3131 var integer trx_nr := 0;
3132 var integer bts_nr := 0;
3133 var integer pcu_conn_id := -1;
3134
3135 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3136
3137 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3138 f_sleep(3.0);
3139 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3140 setverdict(pass);
3141}
3142testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3143 var ConnHdlrPars pars;
3144 var ConnHdlr vc_conn;
3145 f_init(testcasename());
3146
3147 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3148 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3149 vc_conn.done;
3150}
3151
3152/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3153function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3154 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003155 var integer pcu_conn_id := -1;
3156
3157 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3158
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003159 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3160 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3161 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003162 setverdict(pass);
3163}
3164testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3165 var ConnHdlrPars pars;
3166 var ConnHdlr vc_conn;
3167 f_init(testcasename());
3168
3169 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3170 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3171 vc_conn.done;
3172}
3173
3174/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3175function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3176 var PCUIF_Message first_info;
3177 var integer ts_nr := g_chan_nr.tn;
3178 var integer trx_nr := 0;
3179 var integer bts_nr := 0;
3180 var integer pcu_conn_id := -1;
3181
3182 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3183
3184 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003185 /* Send a second Chan Activ and expect it to be NACKed */
3186 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3187 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003188 setverdict(pass);
3189}
3190testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3191 var ConnHdlrPars pars;
3192 var ConnHdlr vc_conn;
3193 f_init(testcasename());
3194
3195 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3196 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3197 vc_conn.done;
3198}
3199
3200/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3201function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3202 var PCUIF_Message first_info;
3203 var integer ts_nr := g_chan_nr.tn;
3204 var integer trx_nr := 0;
3205 var integer bts_nr := 0;
3206 var integer pcu_conn_id := -1;
3207 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3208
3209 /* register for the TCH/F channel number */
3210 f_rslem_register(0, chan_nr);
3211
3212 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3213
3214 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3215 "RSL CHAN ACT");
3216 setverdict(pass);
3217}
3218testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3219 var ConnHdlrPars pars;
3220 var ConnHdlr vc_conn;
3221 f_init(testcasename());
3222
3223 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3224 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3225 vc_conn.done;
3226}
3227
3228/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3229function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3230 var PCUIF_Message first_info;
3231 var integer ts_nr := g_chan_nr.tn;
3232 var integer trx_nr := 0;
3233 var integer bts_nr := 0;
3234 var integer pcu_conn_id := -1;
3235 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3236 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3237
3238 /* register for the TCH/H channel numbers */
3239 f_rslem_register(0, chan_nr[0]);
3240 f_rslem_register(0, chan_nr[1]);
3241
3242 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3243
3244 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3245 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3246 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3247 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3248 setverdict(pass);
3249}
3250testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3251 var ConnHdlrPars pars;
3252 var ConnHdlr vc_conn;
3253 f_init(testcasename());
3254
3255 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3256 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3257 vc_conn.done;
3258}
3259
Harald Welte9bbbfb52018-04-05 09:33:19 +02003260/***********************************************************************
3261 * IPA Style Dynamic Timeslot Support
3262 ***********************************************************************/
3263
3264private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3265runs on ConnHdlr {
3266 var PCUIF_send_data sd;
3267 /* Expect BTS to immediately acknowledge activation as PDCH */
3268 PCU.clear;
3269 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3270 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003271 timer T_wait := 2.0;
3272 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003273 alt {
3274 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3275 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 +01003276 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
3277 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3278 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003279 }
3280 }
3281 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003282 [] T_wait.timeout {
3283 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3284 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
3285 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003286 }
3287 /* try to activate this PDCH from the PCU point of view */
3288 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3289 /* FIXME: is there a response? */
3290
3291 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3292}
3293
3294private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3295runs on ConnHdlr {
3296 var PCUIF_send_data sd;
3297 /* Send RSL CHAN REL (deactivate) */
3298 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3299 PCU.clear;
3300 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003301 timer T_wait := 2.0;
3302 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003303 alt {
3304 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3305 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 +01003306 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
3307 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3308 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003309 }
3310 }
3311 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003312 [] T_wait.timeout {
3313 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3314 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
3315 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003316 }
3317 /* Emulate PCU asking BTS to deactivate PDCH */
3318 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3319 alt {
3320 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3321 setverdict(pass);
3322 }
3323 [] RSL.receive { repeat; }
3324 }
3325}
3326
3327/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3328function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3329 var PCUIF_Message first_info;
3330 var integer ts_nr := g_chan_nr.tn;
3331 var integer trx_nr := 0;
3332 var integer bts_nr := 0;
3333 var integer pcu_conn_id := -1;
3334
3335 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3336
3337 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3338 f_sleep(3.0);
3339 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3340
3341 setverdict(pass);
3342
3343}
3344testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3345 var ConnHdlrPars pars;
3346 var ConnHdlr vc_conn;
3347 f_init();
3348
3349 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3350 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3351 vc_conn.done;
3352}
3353
3354/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3355function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3356 var PCUIF_Message first_info;
3357 var integer ts_nr := g_chan_nr.tn;
3358 var integer trx_nr := 0;
3359 var integer bts_nr := 0;
3360 var integer pcu_conn_id := -1;
3361
3362 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3363
3364 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3365 "RSL CHAN ACT");
3366 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3367 "RF CHAN REL", true);
3368 setverdict(pass);
3369}
3370testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3371 var ConnHdlrPars pars;
3372 var ConnHdlr vc_conn;
3373 f_init(testcasename());
3374
3375 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3376 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3377 vc_conn.done;
3378}
3379
3380/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3381function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3382 var PCUIF_Message first_info;
3383 var integer ts_nr := g_chan_nr.tn;
3384 var integer trx_nr := 0;
3385 var integer bts_nr := 0;
3386 var integer pcu_conn_id := -1;
3387
3388 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3389
3390 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3391 "RSL CHAN ACT");
3392
3393 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3394 alt {
3395 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3396 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003397 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02003398 }
3399 [] RSL.receive { repeat; }
3400 }
3401
3402 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3403 "RF CHAN REL", true);
3404 setverdict(pass);
3405}
3406testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3407 var ConnHdlrPars pars;
3408 var ConnHdlr vc_conn;
3409 f_init(testcasename());
3410
3411 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3412 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3413 vc_conn.done;
3414}
3415
3416/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3417function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3418 var PCUIF_Message first_info;
3419 var integer ts_nr := g_chan_nr.tn;
3420 var integer trx_nr := 0;
3421 var integer bts_nr := 0;
3422 var integer pcu_conn_id := -1;
3423
3424 /* register for the TCH/F channel number */
3425 f_rslem_register(0, g_chan_nr);
3426
3427 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3428
3429 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3430
3431 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3432 "RSL CHAN ACT");
3433
3434 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3435
3436 setverdict(pass);
3437}
3438testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3439 var ConnHdlrPars pars;
3440 var ConnHdlr vc_conn;
3441 f_init(testcasename());
3442
3443 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3444 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3445 vc_conn.done;
3446}
3447
3448
Harald Welte0472ab42018-03-12 15:02:26 +01003449/***********************************************************************
3450 * LAPDm / RLL related
3451 ***********************************************************************/
3452
3453private function f_tx_lapdm(template (value) LapdmFrame l,
3454 template (value) RslLinkId link_id) runs on ConnHdlr {
3455 var octetstring l2 := enc_LapdmFrame(valueof(l));
3456 if (valueof(link_id.c) == SACCH) {
3457 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02003458 var L1ctlDataReq l1hl2 := {
3459 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
3460 l2_payload := f_pad_oct(l2, 21, '2B'O)
3461 }
3462 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
3463 } else {
3464 /* If required, pad L2 frame with constant 0x2b filling */
3465 l2 := f_pad_oct(l2, 23, '2B'O);
3466
3467 log("encoding ", l, " to ", l2);
3468 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01003469 }
Harald Welte0472ab42018-03-12 15:02:26 +01003470}
3471
3472type record RllTestCase {
3473 uint3_t sapi,
3474 RslLinkId link_id,
3475 octetstring l3,
3476 boolean exp
3477}
3478type record of RllTestCase RllTestCases;
3479template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3480 sapi := sapi,
3481 link_id := id,
3482 l3 := l3,
3483 exp := exp
3484}
3485
3486/* execute the same callback function with a set of different parameters (tcs) on a
3487 * variety of logical channels */
3488private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
3489 var ConnHdlrPars pars;
3490 var ConnHdlr vc_conn;
3491 f_init(testcasename());
3492
3493 /* test on each of the channels we have */
3494 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
3495 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
3496
3497 /* test each of the test cases on the current channel */
3498 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
3499 pars.spec.rll := tcs[j];
3500 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
3501 vc_conn := f_start_handler(fn, pars);
3502 vc_conn.done;
3503 }
3504 }
3505
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003506 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01003507}
3508
3509/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
3510private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
3511 var RllTestCase tc := g_pars.spec.rll;
3512 timer T := 3.0;
3513
3514 f_l1_tune(L1CTL);
3515 RSL.clear;
3516
3517 /* activate the logical channel */
3518 f_est_dchan();
3519 L1CTL.clear;
3520
3521 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
3522 T.start;
3523 alt {
3524 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
3525 if (tc.exp) {
3526 setverdict(pass);
3527 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003528 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01003529 }
3530 }
3531 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
3532 if (tc.exp) {
3533 setverdict(pass);
3534 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003535 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01003536 }
3537 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003538 /* We also expect to receive the measurements */
3539 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003540 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003541 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01003542 }
3543 [not tc.exp] T.timeout {
3544 setverdict(pass);
3545 }
3546 }
3547
3548 f_rsl_chan_deact();
3549 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3550 f_rslem_unregister(0, g_chan_nr);
3551}
3552testcase TC_rll_est_ind() runs on test_CT {
3553 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02003554 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01003555 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02003556 /* normal SAPI0 establishment */
3557 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01003558 /* SAPI 3 doesn't support contention resolution */
3559 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
3560 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
3561 /* normal SAPI3 establishment on main DCCH */
3562 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3563 /* normal SAPI3 establishment on SACCH */
3564 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3565 };
3566 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
3567}
3568
3569/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
3570private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
3571 var RllTestCase tc := g_pars.spec.rll;
3572 var L1ctlDlMessage dl;
3573 timer T := 3.0;
3574
3575 f_l1_tune(L1CTL);
3576 RSL.clear;
3577
3578 /* activate the logical channel */
3579 f_est_dchan();
3580 L1CTL.clear;
3581
3582 /* Send a RSL EST REQ for SAPI3 on main DCCH */
3583 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
3584 T.start;
3585 alt {
3586 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3587 var LapdmFrame lapdm;
3588 var octetstring l2 := dl.payload.data_ind.payload;
3589 if (dl.dl_info.link_id.c == SACCH) {
3590 /* remove L1 header */
3591 l2 := substr(l2, 2, lengthof(l2)-2);
3592 }
3593 lapdm.ab := dec_LapdmFrameAB(l2);
3594 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
3595 setverdict(pass);
3596 } else {
3597 repeat;
3598 }
3599 }
3600 [] L1CTL.receive { repeat; }
3601 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003602 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01003603 }
3604 }
3605
3606 f_rsl_chan_deact();
3607 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3608 f_rslem_unregister(0, g_chan_nr);
3609}
3610testcase TC_rll_est_req_DCCH_3() runs on test_CT {
3611 var RllTestCases tcs := {
3612 /* normal SAPI3 establishment on main DCCH */
3613 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
3614 };
3615 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3616}
3617testcase TC_rll_est_req_ACCH_3() runs on test_CT {
3618 var RllTestCases tcs := {
3619 /* normal SAPI3 establishment on SACCH */
3620 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3621 }
3622 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3623}
3624
3625/* altstep to receive a LAPDm frame matching the given template */
3626private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
3627 var L1ctlDlMessage dl;
3628 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3629 var LapdmFrame lapdm;
3630 var octetstring l2 := dl.payload.data_ind.payload;
3631 if (dl.dl_info.link_id.c == SACCH) {
3632 /* remove L1 header */
3633 l2 := substr(l2, 2, lengthof(l2)-2);
3634 }
3635 if (ischosen(exp.ab)) {
3636 lapdm.ab := dec_LapdmFrameAB(l2);
3637 } else if (ischosen(exp.b4)) {
3638 lapdm.b4 := dec_LapdmFrameB4(l2);
3639 } else if (ischosen(exp.bbis)) {
3640 lapdm.bbis := dec_LapdmFrameBbis(l2);
3641 }
3642 log("Rx LAPDm ", lapdm);
3643 if (match(lapdm, exp)) {
3644 setverdict(pass);
3645 } else {
3646 repeat;
3647 }
3648 }
3649 [] L1CTL.receive { repeat; }
3650}
3651private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
3652 timer T := t;
3653 T.start;
3654 alt {
3655 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003656 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01003657 }
3658 [] as_l1_exp_lapdm(exp);
3659 }
3660}
3661
3662/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
3663private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3664 /* send SABM from MS -> BTS */
3665 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
3666 /* expect RLL EST IND on Abis */
3667 alt {
3668 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
3669 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
3670 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003671 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01003672 }
3673 [] RSL.receive { repeat; }
3674 }
3675 /* expect UA from BTS -> MS */
3676 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
3677}
3678
3679/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
3680private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
3681 var RllTestCase tc := g_pars.spec.rll;
3682
3683 f_l1_tune(L1CTL);
3684 RSL.clear;
3685
3686 /* activate the logical channel */
3687 f_est_dchan();
3688 L1CTL.clear;
3689
3690 /* first establish the link-layer */
3691 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3692
3693 /* then send the DISC */
3694 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
3695 /* ... and expect the REL IND on the RSL side */
3696 alt {
3697 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
3698 setverdict(pass);
3699 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003700 /* We also expect to receive the measurements */
3701 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003702 }
3703
3704 /* release the channel */
3705 f_rsl_chan_deact();
3706 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3707 f_rslem_unregister(0, g_chan_nr);
3708}
3709testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
3710 var RllTestCases tcs := {
3711 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
3712 };
3713 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3714}
3715
3716testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
3717 var RllTestCases tcs := {
3718 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
3719 };
3720 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3721}
3722testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
3723 var RllTestCases tcs := {
3724 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
3725 };
3726 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3727}
3728testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
3729 var RllTestCases tcs := {
3730 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3731 };
3732 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3733}
3734
3735/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
3736private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
3737 var RllTestCase tc := g_pars.spec.rll;
3738 f_l1_tune(L1CTL);
3739 RSL.clear;
3740
3741 /* activate the logical channel */
3742 f_est_dchan();
3743 L1CTL.clear;
3744
3745 /* first establish the link-layer */
3746 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3747
3748 /* then send the REL REQ via RSL */
3749 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
3750 /* ... and expect the DISC on the Um side */
3751 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02003752 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01003753 /* FIXME: send a UA in resposne to the DISC */
3754 }
3755 }
3756
3757 /* release the channel */
3758 f_rsl_chan_deact();
3759 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3760 f_rslem_unregister(0, g_chan_nr);
3761}
3762testcase TC_rll_rel_req() runs on test_CT {
3763 var RllTestCases tcs := {
3764 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
3765 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
3766 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3767 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3768 };
3769 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
3770}
3771
3772/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
3773testcase TC_rll_data_req() runs on test_CT {
3774}
3775
3776/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
3777testcase TC_rll_data_ind() runs on test_CT {
3778}
3779
3780/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
3781private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
3782 var RllTestCase tc := g_pars.spec.rll;
3783
3784 f_l1_tune(L1CTL);
3785 RSL.clear;
3786
3787 f_est_dchan();
3788 L1CTL.clear;
3789
3790 /* Send UNITDATA REQ on RSL side */
3791 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
3792 /* Expect it to arrive on the other side */
3793 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02003794 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003795 } else {
Harald Weltee613f962018-04-18 22:38:16 +02003796 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003797 }
3798
3799 /* release the channel */
3800 f_rsl_chan_deact();
3801 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3802 f_rslem_unregister(0, g_chan_nr);
3803}
3804testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
3805 var octetstring l3 := f_rnd_octstring(15);
3806 var RllTestCases tcs := {
3807 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3808 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3809 };
3810 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3811}
3812testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
3813 var octetstring l3 := f_rnd_octstring(19);
3814 var RllTestCases tcs := {
3815 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3816 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3817 };
3818 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3819}
3820
3821/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
3822private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
3823 var RllTestCase tc := g_pars.spec.rll;
3824
3825 f_l1_tune(L1CTL);
3826 RSL.clear;
3827
3828 f_est_dchan();
3829 L1CTL.clear;
3830
3831 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02003832 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01003833 /* Expdct RLL UNITDATA IND on RSL side */
3834 alt {
3835 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
3836 setverdict(pass);
3837 }
3838 [] RSL.receive { repeat; }
3839 }
3840
3841 /* release the channel */
3842 f_rsl_chan_deact();
3843 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3844 f_rslem_unregister(0, g_chan_nr);
3845}
3846testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02003847 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01003848 var RllTestCases tcs := {
3849 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3850 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3851 };
3852 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3853}
3854testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
3855 var octetstring l3 := f_rnd_octstring(18);
3856 var RllTestCases tcs := {
3857 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3858 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3859 };
3860 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3861}
3862
Harald Weltee613f962018-04-18 22:38:16 +02003863/***********************************************************************
3864 * Encryption Related
3865 ***********************************************************************/
3866
3867/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3868function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3869 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
3870 if (link_id.c == SACCH) {
3871 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
3872 } else {
3873 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
3874 }
3875}
3876
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003877/* Expect (or not expect) other kinds of messages */
3878private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
3879 [exp_any] RSL.receive { repeat; }
3880 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003881 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003882 }
3883}
3884
Harald Weltee613f962018-04-18 22:38:16 +02003885/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07003886private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003887 RslLinkId link_id,
3888 octetstring l3,
3889 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003890 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003891) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02003892 timer T := 3.0;
3893 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
3894 T.start;
3895 /* Expect RLL UNITDATA IND on RSL side */
3896 alt {
3897 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
3898 setverdict(pass);
3899 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003900 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003901 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02003902 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003903 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02003904 }
Harald Weltee613f962018-04-18 22:38:16 +02003905 }
3906}
3907
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003908/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
3909private function f_data_mo(
3910 RslLinkId link_id,
3911 boolean p, uint3_t nr, uint3_t ns,
3912 octetstring l3,
3913 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003914 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003915) runs on ConnHdlr {
3916 timer T := 3.0;
3917 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
3918 T.start;
3919 /* Expect RLL DATA IND on RSL side */
3920 alt {
3921 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
3922 setverdict(pass);
3923 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003924 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003925 [] as_rsl_any_ind(exp_any);
3926 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003927 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003928 }
3929 }
3930}
3931
Harald Weltee613f962018-04-18 22:38:16 +02003932/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
3933function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
3934 f_l1_tune(L1CTL);
3935 f_est_dchan(true);
3936
3937 /* now we actually need to transmit some data both ways to check if the encryption works */
3938 var L1ctlDlMessage dl;
3939
Stefan Sperling603d98e2018-07-25 16:47:28 +02003940 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02003941 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3942
3943 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3944 f_unitdata_mt(link_id, l3);
3945
3946 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
3947 f_unitdata_mo(link_id, l3);
3948
3949 /* release the channel */
3950 f_rsl_chan_deact();
3951 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3952 f_rslem_unregister(0, g_chan_nr);
3953}
3954testcase TC_chan_act_a51() runs on test_CT {
3955 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3956 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3957 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3958}
3959testcase TC_chan_act_a52() runs on test_CT {
3960 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3961 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3962 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3963}
3964testcase TC_chan_act_a53() runs on test_CT {
3965 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3966 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3967 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3968}
3969
3970
3971/* Test unencrypted channel activation followed by explicit ENCR CMD later */
3972function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
3973 /* L3 payload doesn't matter, as it is passed transparently */
3974 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
3975 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
3976 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3977
3978 f_l1_tune(L1CTL);
3979
3980 /* first establish a dedicated channel in the clear */
3981 f_est_dchan(false);
3982
3983 /* Establish ABM */
3984 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3985
3986 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
3987 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
3988 /* expect the L3 to arrive still unencrypted on the MS side */
3989 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
3990
3991 /* configure L1 to apply ciphering */
3992 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
3993 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
3994
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003995 /* send first ciphered I-frame in response and expect it on RSL */
3996 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02003997
3998 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
3999 * and hence enable encryption also on the downlink */
4000
4001 /* expect bi-directional communication work in encrypted mode */
4002 f_unitdata_mo(link_id, f_rnd_octstring(15));
4003 f_unitdata_mt(link_id, f_rnd_octstring(15));
4004
4005 /* release the channel */
4006 f_rsl_chan_deact();
4007 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4008 f_rslem_unregister(0, g_chan_nr);
4009}
4010testcase TC_encr_cmd_a51() runs on test_CT {
4011 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4012 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4013 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4014}
4015testcase TC_encr_cmd_a52() runs on test_CT {
4016 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4017 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4018 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4019}
4020testcase TC_encr_cmd_a53() runs on test_CT {
4021 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4022 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4023 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4024}
4025
4026private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
4027 var LapdmFrame lf;
4028 var octetstring reenc;
4029
4030 /* decode the LAPDm frame */
4031 if (ischosen(exp_match.ab)) {
4032 lf.ab := dec_LapdmFrameAB(enc);
4033 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004034 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02004035 }
4036
4037 /* check if decoder result matches expectation */
4038 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004039 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004040 } else {
4041 log(name, ": matched");
4042 setverdict(pass);
4043 }
4044
4045 /* test if re-encoded frame equals original input */
4046 reenc := enc_LapdmFrame(lf);
4047 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004048 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004049 } else {
4050 setverdict(pass);
4051 }
4052}
4053
4054testcase TC_lapdm_selftest() runs on test_CT {
4055 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
4056 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
4057 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
4058 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
4059 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
4060 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
4061 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
4062}
4063
Stefan Sperling4880be42018-08-07 18:12:59 +02004064/***********************************************************************
4065 * DTX Related (see GSM 05.08, section 8.3)
4066 ***********************************************************************/
4067
4068/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
4069function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
4070 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
4071 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
4072 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
4073 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
4074}
4075function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
4076 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
4077 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
4078}
4079function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
4080 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
4081 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
4082 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
4083 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
4084}
4085function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
4086 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
4087 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
4088 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
4089 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
4090 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
4091 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
4092 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
4093 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
4094}
4095
4096function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
4097 var L1ctlDlMessage dl;
4098 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
4099 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
4100 var GsmFrameNumber first_fn;
4101 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004102 var integer nfill_frames_sacch := 0;
4103 var integer nfill_frames_nonsacch := 0;
4104 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02004105 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
4106 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004107 const integer frame_dtx_tchf_mod := 104;
4108 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
4109 * which operates in terms of blocks rather than frames. */
4110 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
4111 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02004112 timer T := 5.0;
4113
4114 f_l1_tune(L1CTL);
4115 RSL.clear;
4116 L1CTL.clear;
4117
4118 /* activate TCHF signalling channel */
4119 f_est_dchan(false);
4120
4121 T.start;
4122 alt {
4123 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4124 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4125 var octetstring l2 := dl.payload.data_ind.payload;
4126
4127 if (is_first_frame) {
4128 is_first_frame := false;
4129 first_fn := dl.dl_info.frame_nr;
4130 }
4131
4132 if (dl.dl_info.link_id.c == SACCH) {
4133 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4134 if (not match(l2_fill_frame_sacch, l2)) {
4135 repeat;
4136 }
4137 } else if (not match(l2_fill_frame, l2)) {
4138 repeat;
4139 }
4140
4141 if (dtxd) {
4142 if (not f_g_chan_is_tchf()) {
4143 T.stop;
4144 f_rsl_chan_deact();
4145 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004146 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 +02004147 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004148 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004149 T.stop;
4150 f_rsl_chan_deact();
4151 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004152
4153 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4154 * 2 SACCH, 1 TCH/F */
4155 expected_fill_frames := 3;
4156
4157 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4158 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4159 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004160 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004161 } else {
4162 setverdict(pass);
4163 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004164 } else {
4165 if (dl.dl_info.link_id.c == SACCH) {
4166 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004167 repeat;
4168 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004169 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4170 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4171 * we should only see the subset of frames numbers which correspond to a block boundary.
4172 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4173 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4174 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4175 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4176 repeat;
4177 }
4178 }
4179 log("Received DTX TCH fill frame with bad frame number: ", fn,
4180 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4181 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4182 f_rsl_chan_deact();
4183 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004184 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004185 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004186 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004187 if (dl.dl_info.link_id.c == SACCH) {
4188 nfill_frames_sacch := nfill_frames_sacch + 1;
4189 } else {
4190 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4191 }
4192 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004193 T.stop;
4194 if (f_g_chan_is_tchf()) {
4195 /* Without DTX we can expect 25 fill frames for every 104 frames.
4196 * (24 FACCH + 1 SACCH filling) */
4197 expected_fill_frames := 25;
4198 } else if (f_g_chan_is_tchh()) {
4199 /* We can expect 2 fill frames for every 104 frames. */
4200 expected_fill_frames := 2;
4201 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4202 /* We can expect 5 fill frames for every 104 frames. */
4203 expected_fill_frames := 5;
4204 } else {
4205 f_rsl_chan_deact();
4206 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004207 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02004208 }
4209
4210 f_rsl_chan_deact();
4211 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004212
4213 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004214 setverdict(pass);
4215 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004216 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4217 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004218 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004219 }
4220 } else {
4221 repeat;
4222 }
4223 }
4224 }
4225 [] L1CTL.receive { repeat; }
4226 [] T.timeout {
4227 f_rsl_chan_deact();
4228 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004229 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004230 }
4231 }
4232}
4233
4234function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4235 f_test_l2_fill_frames(false);
4236}
4237
4238function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4239 f_test_l2_fill_frames(true);
4240}
4241
4242function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4243 var ConnHdlr vc_conn;
4244 var ConnHdlrPars pars;
4245 pars.t_guard := 60.0;
4246 f_init(testcasename());
4247 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4248 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4249 if (dtxd) {
4250 if (i >= 4) { /* DTX is only allowed on TCH/F */
4251 break;
4252 }
4253 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4254 } else {
4255 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4256 }
4257 vc_conn.done;
4258 }
4259}
4260
4261/* Verify that L2 fill frames are sent on TCH in signaling mode if
4262 * there is nothing to transmit while DTX is disabled on downlink. */
4263testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4264 f_tch_sign_l2_fill_frame(false);
4265}
4266
4267/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4268 * there is nothing to transmit while DTX is enabled on downlink. */
4269testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4270 f_tch_sign_l2_fill_frame(true);
4271}
Harald Welte0472ab42018-03-12 15:02:26 +01004272
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004273testcase TC_chopped_ipa_ping() runs on test_CT {
4274 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4275}
4276
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004277testcase TC_chopped_ipa_payload() runs on test_CT {
4278 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4279}
4280
Harald Welte0472ab42018-03-12 15:02:26 +01004281/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4282/* protocol error as per 44.006 */
4283/* link layer failure (repetition of I-frame N200 times without ACK */
4284/* repetition of SABM or DISC N200 times without ACK */
4285/* receptiom of SABM in multi-frame established state */
4286
4287
4288
4289
Harald Welte883340c2018-02-28 18:59:29 +01004290
Harald Welte68e495b2018-02-25 00:05:57 +01004291/* TODO Areas:
4292
4293* channel activation
4294** with BS_Power / MS_Power, bypassing power control loop
4295** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004296** with timing advance from initial activation on
4297* mode modify
4298** encryption
4299** multirate
4300* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004301** unsupported algorithm
4302* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01004303* BS Power Control
4304* Physical Context
Harald Welte43c54642018-09-15 17:47:04 +03004305* CCCH Load Indication for RACH
Harald Welte68e495b2018-02-25 00:05:57 +01004306* SMS Broadcast Req / Cmd / CBCH LOad Ind
4307* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004308* error handling
Harald Welte43c54642018-09-15 17:47:04 +03004309** discriminator error
Harald Welte68e495b2018-02-25 00:05:57 +01004310** type error
4311** sequence error
4312** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004313* PCU interface
4314** TIME_IND from BTS->PCU
4315** DATA_IND from BTS->PCU
4316** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004317
4318*/
Harald Welte70767382018-02-21 12:16:40 +01004319
4320control {
4321 execute( TC_chan_act_stress() );
4322 execute( TC_chan_act_react() );
4323 execute( TC_chan_deact_not_active() );
4324 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004325 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004326 execute( TC_sacch_filling() );
4327 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004328 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004329 execute( TC_sacch_multi_chg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004330 execute( TC_rach_content() );
4331 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004332 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004333 execute( TC_meas_res_sign_tchf() );
4334 execute( TC_meas_res_sign_tchh() );
4335 execute( TC_meas_res_sign_sdcch4() );
4336 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004337 execute( TC_meas_res_sign_tchh_toa256() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01004338 execute( TC_rsl_ms_pwr_ctrl() );
Harald Welte70767382018-02-21 12:16:40 +01004339 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004340 execute( TC_paging_imsi_80percent() );
4341 execute( TC_paging_tmsi_80percent() );
4342 execute( TC_paging_imsi_200percent() );
4343 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004344 execute( TC_rsl_protocol_error() );
4345 execute( TC_rsl_mand_ie_error() );
4346 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004347 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004348 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004349 execute( TC_si_sched_2bis() );
4350 execute( TC_si_sched_2ter() );
4351 execute( TC_si_sched_2ter_2bis() );
4352 execute( TC_si_sched_2quater() );
4353 execute( TC_si_sched_13() );
4354 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004355 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004356 execute( TC_ipa_crcx_twice_not_active() );
4357 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004358 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004359 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004360
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004361 if (mp_pcu_socket != "") {
4362 execute( TC_pcu_act_req() );
4363 execute( TC_pcu_act_req_wrong_ts() );
4364 execute( TC_pcu_act_req_wrong_bts() );
4365 execute( TC_pcu_act_req_wrong_trx() );
4366 execute( TC_pcu_deact_req() );
4367 execute( TC_pcu_deact_req_wrong_ts() );
4368 execute( TC_pcu_ver_si13() );
4369 execute( TC_pcu_data_req_wrong_bts() );
4370 execute( TC_pcu_data_req_wrong_trx() );
4371 execute( TC_pcu_data_req_wrong_ts() );
4372 execute( TC_pcu_data_req_ts_inactive() );
4373 execute( TC_pcu_data_req_pdtch() );
4374 execute( TC_pcu_data_req_ptcch() );
4375 execute( TC_pcu_data_req_agch() );
4376 execute( TC_pcu_data_req_imm_ass_pch() );
4377 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004378 execute( TC_pcu_ext_rach_content() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004379 execute( TC_pcu_paging_from_rsl() );
4380 } else {
4381 log("PCU socket path not available, skipping PCU tests");
4382 }
Harald Welte3d04ae62018-04-04 20:29:05 +02004383
4384 execute( TC_dyn_osmo_pdch_act_deact() );
4385 execute( TC_dyn_osmo_pdch_unsol_deact() );
4386 execute( TC_dyn_osmo_pdch_double_act() );
4387 execute( TC_dyn_osmo_pdch_tchf_act() );
4388 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004389 execute( TC_dyn_ipa_pdch_act_deact() );
4390 execute( TC_dyn_ipa_pdch_tchf_act() );
4391 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4392 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004393
4394 execute( TC_rll_est_ind() );
4395 execute( TC_rll_est_req_DCCH_3() );
4396 execute( TC_rll_est_req_ACCH_3() );
4397 execute( TC_rll_rel_ind_DCCH_0() );
4398 execute( TC_rll_rel_ind_DCCH_3() );
4399 execute( TC_rll_rel_ind_ACCH_0() );
4400 execute( TC_rll_rel_ind_ACCH_3() );
4401 execute( TC_rll_rel_req() );
4402 execute( TC_rll_unit_data_req_DCCH() );
4403 execute( TC_rll_unit_data_req_ACCH() );
4404 execute( TC_rll_unit_data_ind_DCCH() );
4405 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004406
4407 execute( TC_chan_act_a51() );
4408 execute( TC_chan_act_a52() );
4409 execute( TC_chan_act_a53() );
4410 execute( TC_encr_cmd_a51() );
4411 execute( TC_encr_cmd_a52() );
4412 execute( TC_encr_cmd_a53() );
4413
4414 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004415
4416 execute( TC_tch_sign_l2_fill_frame() );
4417 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004418
4419 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004420 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01004421}
4422
4423
4424}