blob: e1c64d6a1e01b33d9b66a89960aa34344b04443e [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;
Philipp Maiere63229e2019-04-26 12:21:37 +020068 float mp_ipa_up_delay := 0.0;
Harald Welte70767382018-02-21 12:16:40 +010069}
70
Harald Welte629cc6b2018-03-11 17:19:05 +010071type record of RslChannelNr ChannelNrs;
72
Harald Welte70767382018-02-21 12:16:40 +010073type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010074 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010075 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010076 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010077 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010078 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010079 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010080
81 /* L1CTL port (for classic tests) */
82 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010083
Harald Welte54a2a2d2018-02-26 09:14:05 +010084 /* TRXC port (for classic tests) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070085 port TRXC_CODEC_PT BTS_TRXC;
86 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +010087
Harald Weltef50e3ae2018-09-10 10:27:56 +020088 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010089 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020090 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010091
Harald Welte883340c2018-02-28 18:59:29 +010092 /* PCU Interface of BTS */
93 port PCUIF_CODEC_PT PCU;
94 var integer g_pcu_conn_id;
95 /* Last PCU INFO IND we received */
96 var PCUIF_Message g_pcu_last_info;
97
Harald Welte48494ca2018-02-25 16:59:50 +010098 /* SI configuration */
99 var SystemInformationConfig si_cfg := {
100 bcch_extended := false,
101 si1_present := false,
102 si2bis_present := false,
103 si2ter_present := false,
104 si2quater_present := false,
105 si7_present := false,
106 si8_present := false,
107 si9_present := false,
108 si13_present := false,
109 si13alt_present := false,
110 si15_present := false,
111 si16_present := false,
112 si17_present := false,
113 si2n_present := false,
114 si21_present := false,
115 si22_present := false
116 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100117
118 /* all logical channels available on the BTS */
119 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100120 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100121}
122
123/* an individual call / channel */
124type component ConnHdlr extends RSL_DchanHdlr {
125 port L1CTL_PT L1CTL;
126
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700127 port TRXC_CODEC_PT BTS_TRXC;
128 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100129
130 timer g_Tguard;
131 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
132
133 var ConnHdlrPars g_pars;
134 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100135 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200136
137 /* PCU Interface of BTS */
138 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100139}
140
141function f_init_rsl(charstring id) runs on test_CT {
142 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
143 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
144
145 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
146 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
147 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
148
149 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
150 vc_RSL.start(RSL_Emulation.main(false));
151}
152
153type record ConnHdlrPars {
154 RslChannelNr chan_nr,
155 RSL_IE_ChannelMode chan_mode,
156 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100157 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200158 TestSpecUnion spec optional,
159 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100160}
161
162/* Test-specific parameters */
163type union TestSpecUnion {
164 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100165}
166
Harald Welte82ccef72018-02-25 16:17:33 +0100167template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100168 max_retrans := RACH_MAX_RETRANS_7,
169 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100170 cell_barr_access := false,
171 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100172 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100173};
174
Harald Weltef10153f2018-02-25 16:34:05 +0100175template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100176 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200177 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100178 acs := '0'B,
179 neci := true,
180 rxlev_access_min := 0
181}
182
183template (value) LocationAreaIdentification ts_LAI_default := {
184 mcc_mnc := '262F42'H,
185 lac := 42
186}
187
Harald Welte7484fc42018-02-24 14:09:45 +0100188/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100189template (value) SystemInformation ts_SI3_default := {
190 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100191 payload := {
192 si3 := {
193 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100194 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100195 ctrl_chan_desc := {
196 msc_r99 := true,
197 att := true,
198 bs_ag_blks_res := 1,
199 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100200 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100201 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
202 spare := '00'B,
203 bs_pa_mfrms := 0, /* 2 multiframes */
204 t3212 := 1 /* 6 minutes */
205 },
Harald Welte82ccef72018-02-25 16:17:33 +0100206 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100207 dn_ind := false,
208 pwrc := false,
209 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100210 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100211 },
Harald Weltef10153f2018-02-25 16:34:05 +0100212 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100213 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100214 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100215 }
216 }
217}
Harald Welte70767382018-02-21 12:16:40 +0100218
Harald Weltef8df4cb2018-03-10 15:15:08 +0100219template (value) SystemInformation ts_SI2_default := {
220 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100221 payload := {
222 si2 := {
223 bcch_freq_list := '00000000000000000000000000000000'O,
224 ncc_permitted := '11111111'B,
225 rach_control := ts_RachCtrl_default
226 }
227 }
228}
229
Harald Weltef8df4cb2018-03-10 15:15:08 +0100230template (value) SystemInformation ts_SI4_default := {
231 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100232 payload := {
233 si4 := {
234 lai := ts_LAI_default,
235 cell_sel_par := ts_CellSelPar_default,
236 rach_control := ts_RachCtrl_default,
237 cbch_chan_desc := omit,
238 cbch_mobile_alloc := omit,
239 rest_octets := ''O
240 }
241 }
242}
243
244function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
245runs on test_CT {
246 log("Setting ", rsl_si_type, ": ", si_enc);
247 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
248}
249
250function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
251runs on test_CT {
252 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
253 log("Setting ", rsl_si_type, ": ", si_dec);
254 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
255}
256
Harald Welte8da48242018-02-27 20:41:32 +0100257private function f_init_vty(charstring id) runs on test_CT {
258 map(self:BTSVTY, system:BTSVTY);
259 f_vty_set_prompts(BTSVTY);
260 f_vty_transceive(BTSVTY, "enable");
261}
262
Harald Weltef50e3ae2018-09-10 10:27:56 +0200263private function f_init_vty_bsc() runs on test_CT {
264 map(self:BSCVTY, system:BSCVTY);
265 f_vty_set_prompts(BSCVTY, "OsmoBSC");
266 f_vty_transceive(BSCVTY, "enable");
267}
268
Harald Welte883340c2018-02-28 18:59:29 +0100269/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200270private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
271 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100272 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200273 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
274 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100275 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200276 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200277 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100278 }
279}
280
Harald Weltef26de0b2018-04-04 20:28:05 +0200281private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
282 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100283 timer T := 2.0;
284 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100285 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200286 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100287 return;
288 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200289 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100290
291 T.start;
292 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200293 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100294 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200295 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100296 }
297 }
298}
299
Harald Welte70767382018-02-21 12:16:40 +0100300/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100301function f_init(charstring id := "BTS-Test") runs on test_CT {
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100302 timer T := mp_ipa_up_timeout;
Harald Welte629cc6b2018-03-11 17:19:05 +0100303 g_AllChannels := {
304 /* TS 1..4: TCH/F */
305 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
306 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
307 /* TS 5: TCH/H */
308 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
309 /* TS 0: SDCCH/4 */
310 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
311 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
312 /* TS 6: SDCCH/8 */
313 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
314 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
315 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
316 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
317 };
318
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200319 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700320 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200321 g_AllChanTypes := {
322 /* TS 1..4: TCH/F */
323 valueof(ts_RslChanNr_Bm(1)),
324 /* TS 5: TCH/H */
325 valueof(ts_RslChanNr_Lm(5,1)),
326 /* TS 0: SDCCH/4 */
327 valueof(ts_RslChanNr_SDCCH4(0,2)),
328 /* TS 6: SDCCH/8 */
329 valueof(ts_RslChanNr_SDCCH8(6,4))
330 };
331 } else {
332 g_AllChanTypes := {
333 /* TS 1..4: TCH/F */
334 valueof(ts_RslChanNr_Bm(1)),
335 /* TS 0: SDCCH/4 */
336 valueof(ts_RslChanNr_SDCCH4(0,2)),
337 /* TS 6: SDCCH/8 */
338 valueof(ts_RslChanNr_SDCCH8(6,4))
339 };
340 }
Harald Welte70767382018-02-21 12:16:40 +0100341 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200342 T.start;
343 alt {
344 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
345 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200346 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Harald Welte83f6dbf2018-06-03 18:26:50 +0200347 }
348 }
Harald Welte2d142592018-02-25 13:19:44 +0100349 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100350 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200351 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100352
353 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100354 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
355 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
356 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
357 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100358
Harald Weltef26de0b2018-04-04 20:28:05 +0200359 map(self:PCU, system:PCU);
360 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100361
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700362 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100363 var TrxcMessage ret;
364 /* start with a default moderate timing offset equalling TA=2 */
365 f_main_trxc_connect();
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700366 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 +0100367 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200368
369 /* Wait some extra time to make sure the BTS emits a stable carrier.
370 * (this is only relevant when running the tests with a physical BTS.) */
371 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100372}
373
Harald Welte68e495b2018-02-25 00:05:57 +0100374/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
375function f_init_l1ctl() runs on test_CT {
376 map(self:L1CTL, system:L1CTL);
377 f_connect_reset(L1CTL);
378}
379
Harald Welte70767382018-02-21 12:16:40 +0100380type function void_fn(charstring id) runs on ConnHdlr;
381
382/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200383function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100384runs on test_CT return ConnHdlr {
385 var charstring id := testcasename();
386 var ConnHdlr vc_conn;
387
388 vc_conn := ConnHdlr.create(id);
389 /* connect to RSL Emulation main component */
390 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
391 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200392 if (pcu_comp) {
393 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
394 * it from the test_CT and connect it to the component. This obviously only
395 * works for one component, i.e. no concurrency */
396 unmap(self:PCU, system:PCU);
397 map(vc_conn:PCU, system:PCU);
398 }
Harald Welte70767382018-02-21 12:16:40 +0100399
400 vc_conn.start(f_handler_init(fn, id, pars));
401 return vc_conn;
402}
403
Harald Welte7484fc42018-02-24 14:09:45 +0100404template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
405 streamId := sid,
406 rsl := rsl
407}
408
409template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
410 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
411 streamId := sid,
412 rsl := rsl
413}
414
Harald Welte70767382018-02-21 12:16:40 +0100415private altstep as_Tguard() runs on ConnHdlr {
416 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200417 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100418 }
419}
420
Harald Welte68e495b2018-02-25 00:05:57 +0100421private function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200422 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100423}
424
425private function f_trxc_connect() runs on ConnHdlr {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700426 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte70767382018-02-21 12:16:40 +0100427 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700428 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Weltea4d8f352018-03-01 15:47:20 +0100429 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200430 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200431 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 +0200432 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700433 g_bts_trxc_conn_id := res.connId;
Harald Welte70767382018-02-21 12:16:40 +0100434}
435
436private function f_trxc_fake_rssi(uint8_t rssi) 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_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100439}
440
441private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100442 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700443 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100444}
445
446/* first function started in ConnHdlr component */
447private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
448runs on ConnHdlr {
449 g_pars := pars;
450 g_chan_nr := pars.chan_nr;
451
452 map(self:L1CTL, system:L1CTL);
453 f_connect_reset(L1CTL);
454
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700455 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100456 f_trxc_connect();
457 }
Harald Welte70767382018-02-21 12:16:40 +0100458
459 g_Tguard.start(pars.t_guard);
460 activate(as_Tguard());
461
462 f_rslem_register(0, pars.chan_nr);
463
464 /* call the user-supplied test case function */
465 fn.apply(id);
466}
467
Harald Welteb1726c92018-03-30 11:56:38 +0200468function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
469 boolean ignore_other := false)
470runs on ConnHdlr return RSL_Message {
471 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100472 timer T := 3.0;
473 RSL.send(tx);
474 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100475 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200476 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100477 T.stop;
478 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100479 }
Harald Welte1eba3742018-02-25 12:48:14 +0100480 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200481 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100482 }
Harald Welte21240e62018-03-11 21:43:35 +0100483 [not ignore_other] as_l1_sacch();
484 [not ignore_other] as_meas_res();
485 [not ignore_other] as_l1_dcch();
486 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200487 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100488 }
Harald Welte21240e62018-03-11 21:43:35 +0100489 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100490 }
Harald Welteb1726c92018-03-30 11:56:38 +0200491 return rx;
492}
493
494function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
495 boolean ignore_other := false)
496runs on ConnHdlr {
497 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100498}
499
Harald Weltee613f962018-04-18 22:38:16 +0200500function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false)
501runs on ConnHdlr {
502 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode));
503 if (encr_enable) {
504 /* append encryption related IEs, if requested */
505 var RSL_IE_EncryptionInfo encr_info;
506 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
507 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
508encr_info})) };
509 }
510 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100511}
512
Harald Welte70767382018-02-21 12:16:40 +0100513function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100514 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 +0100515 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100516}
517
Harald Welte70767382018-02-21 12:16:40 +0100518private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
519 template RSL_IE_ChannelMode chan_mode,
520 float t_guard := 20.0) := {
521 chan_nr := valueof(chan_nr),
522 chan_mode := valueof(chan_mode),
523 t_guard := t_guard,
524 l1_pars := {
525 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100526 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100527 meas_ul := {
528 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200529 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100530 rxqual := 0
531 },
532 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200533 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100534 rxqual := 0
535 }
536 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200537 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100538 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200539 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200540 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100541 },
Harald Weltee613f962018-04-18 22:38:16 +0200542 spec := omit,
543 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100544}
545
Harald Welte93640c62018-02-25 16:59:33 +0100546/***********************************************************************
547 * Channel Activation / Deactivation
548 ***********************************************************************/
549
Harald Welte70767382018-02-21 12:16:40 +0100550/* Stress test: Do 500 channel activations/deactivations in rapid succession */
551function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
552 for (var integer i := 0; i < 500; i := i+1) {
553 f_rsl_chan_act(g_pars.chan_mode);
554 f_rsl_chan_deact();
555 }
556 setverdict(pass);
557}
558testcase TC_chan_act_stress() runs on test_CT {
559 var ConnHdlr vc_conn;
560 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
561 f_init(testcasename());
562 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
563 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200564 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100565}
566
567/* Test if re-activation of an already active channel fails as expected */
568function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
569 f_rsl_chan_act(g_pars.chan_mode);
570 /* attempt to activate the same lchan again -> expect reject */
571 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
572 alt {
573 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200574 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100575 }
576 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
577 setverdict(pass);
578 }
579 }
580 f_rsl_chan_deact();
581}
582testcase TC_chan_act_react() runs on test_CT {
583 var ConnHdlr vc_conn;
584 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100585 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100586 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
587 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200588 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100589}
590
591/* Attempt to de-activate a channel that's not active */
592function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
593 timer T := 3.0;
594 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
595 T.start;
596 alt {
597 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
598 setverdict(pass);
599 }
600 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200601 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100602 }
603 }
604}
605testcase TC_chan_deact_not_active() runs on test_CT {
606 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100607 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100608 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
609 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200610 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100611}
612
613/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
614function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
615 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
616 alt {
617 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200618 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100619 }
620 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
621 setverdict(pass);
622 }
623 }
624}
625private type record WrongChanNrCase {
626 RslChannelNr chan_nr,
627 charstring description
628}
629private type record of WrongChanNrCase WrongChanNrCases;
630private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
631 chan_nr := chan_nr,
632 description := desc
633}
634
635testcase TC_chan_act_wrong_nr() runs on test_CT {
636 var ConnHdlr vc_conn;
637 var ConnHdlrPars pars;
638
Harald Welte294b0a22018-03-10 23:26:48 +0100639 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100640
641 var WrongChanNrCases wrong := {
642 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
643 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
644 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
645 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
646 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
647 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
648 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
649 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
650 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
651 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
652 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
653 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
654 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
655 };
656
657 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
658 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
659 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
660 vc_conn.done;
661 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200662 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100663}
664
Harald Weltee613f962018-04-18 22:38:16 +0200665/* execute the same callback function on a variety of logical channels */
666private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
667 var ConnHdlr vc_conn;
668 f_init(testcasename());
669
670 /* test on each of the channels we have */
671 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
672 pars.chan_nr := valueof(g_AllChanTypes[i]);
673
674 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
675 vc_conn := f_start_handler(fn, pars);
676 vc_conn.done;
677 }
678
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200680}
681
Harald Welte93640c62018-02-25 16:59:33 +0100682/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100683 * SACCH handling
684 ***********************************************************************/
685
686private function f_exp_sacch(boolean exp) runs on ConnHdlr {
687 timer T_sacch := 3.0;
688 T_sacch.start;
689 alt {
690 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200691 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100692 }
693 [not exp] T_sacch.timeout {
694 setverdict(pass);
695 }
696 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
697 setverdict(pass);
698 }
699 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200700 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100701 }
702 [] L1CTL.receive { repeat; }
703 [] RSL.receive { repeat; }
704 }
705}
706
707/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
708private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
709 f_l1_tune(L1CTL);
710 RSL.clear;
711
712 /* activate the logical channel */
713 f_est_dchan();
714 L1CTL.clear;
715
716 /* check that SACCH actually are received as expected */
717 f_exp_sacch(true);
718
719 /* deactivate SACCH on the logical channel */
720 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
721 f_sleep(1.0);
722 L1CTL.clear;
723
724 /* check that no SACCH are received anymore */
725 f_exp_sacch(false);
726
727 /* release the channel */
728 f_rsl_chan_deact();
729 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
730}
731testcase TC_deact_sacch() runs on test_CT {
732 var ConnHdlr vc_conn;
733 var ConnHdlrPars pars;
734 f_init();
735 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
736 //for (var integer i := 0; i < 1; i := i+1) {
737 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
738 log(testcasename(), ": Starting for ", g_AllChannels[i]);
739 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
740 vc_conn.done;
741 }
742 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200743 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100744}
745
Harald Welte55700662018-03-12 13:15:43 +0100746/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100747private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
748 var L1ctlDlMessage dl;
749 /* check that the specified SI5 value is actually sent */
750 timer T_sacch := 3.0;
751 L1CTL.clear;
752 T_sacch.start;
753 alt {
754 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
755 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
756 if (match(l3, l3_exp)) {
757 setverdict(pass);
758 } else {
759 repeat;
760 }
761 }
762 [] L1CTL.receive { repeat; }
763 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200764 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100765 }
766 }
767}
768
Harald Welte55700662018-03-12 13:15:43 +0100769/* verify that given SACCH payload is not present */
770private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
771 var L1ctlDlMessage dl;
772 /* check that the specified SI5 value is actually sent */
773 timer T_sacch := 3.0;
774 L1CTL.clear;
775 T_sacch.start;
776 alt {
777 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
778 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
779 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200780 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100781 } else {
782 repeat;
783 }
784 }
785 [] L1CTL.receive { repeat; }
786 [] T_sacch.timeout {
787 setverdict(pass);
788 }
789 }
790}
791
Harald Welte629cc6b2018-03-11 17:19:05 +0100792/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100793private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
794 /* Set a known default SACCH filling for SI5 */
795 var octetstring si5 := f_rnd_octstring(19);
796 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
797
798 f_l1_tune(L1CTL);
799 RSL.clear;
800
801 /* activate the logical channel */
802 f_est_dchan();
803
804 /* check that the specified SI5 value is actually sent */
805 f_sacch_present(si5);
806
807 /* release the channel */
808 RSL.clear;
809 f_rsl_chan_deact();
810 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
811}
812testcase TC_sacch_filling() runs on test_CT {
813 var ConnHdlr vc_conn;
814 var ConnHdlrPars pars;
815 f_init();
816 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
817 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
818 log(testcasename(), ": Starting for ", g_AllChannels[i]);
819 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
820 vc_conn.done;
821 }
822 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200823 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100824}
825
Harald Welte629cc6b2018-03-11 17:19:05 +0100826/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100827private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
828 /* Set a known default SACCH filling for SI5 */
829 var octetstring si5 := f_rnd_octstring(19);
830 var octetstring si5_diff := f_rnd_octstring(19);
831 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
832
833 f_l1_tune(L1CTL);
834 RSL.clear;
835
836 log("Activating channel, expecting standard SI5");
837 /* activate the logical channel */
838 f_est_dchan();
839 /* check that the specified SI5 value is actually sent */
840 f_sacch_present(si5);
841
842 /* set channel-specific different SI5 */
843 log("Setting channel specific SACCH INFO, expecting it");
844 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
845 /* check that the specified lchan-specific value is now used */
846 f_sacch_present(si5_diff);
847
848 /* deactivate the channel and re-activate it, this should result in default SI5 */
849 log("De-activating and re-activating channel, expecting standard SI5");
850 f_rsl_chan_deact();
851 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
852 /* Verify that the TRX-wide default SACCH filling is present again */
853 f_sacch_present(si5);
854
855 /* release the channel */
856 RSL.clear;
857 f_rsl_chan_deact();
858 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
859}
860testcase TC_sacch_info_mod() runs on test_CT {
861 var ConnHdlr vc_conn;
862 var ConnHdlrPars pars;
863 f_init();
864 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
865 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
866 log(testcasename(), ": Starting for ", g_AllChannels[i]);
867 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
868 vc_conn.done;
869 }
870 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200871 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100872}
873
Harald Welte075d84c2018-03-12 13:07:24 +0100874/* Test SACCH scheduling of multiple different SI message types */
875private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
876 var octetstring si5 := f_rnd_octstring(19);
877 var octetstring si5bis := f_rnd_octstring(19);
878 var octetstring si5ter := f_rnd_octstring(19);
879 var octetstring si6 := f_rnd_octstring(19);
880
881 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
882 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
883 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
884 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
885
886 f_l1_tune(L1CTL);
887 RSL.clear;
888
889 /* activate the logical channel */
890 f_est_dchan();
891 L1CTL.clear;
892
893 /* check that SACCH actually are received as expected */
894 f_sacch_present(si5);
895 f_sacch_present(si5bis);
896 f_sacch_present(si5ter);
897 f_sacch_present(si6);
898
899 /* release the channel */
900 f_rsl_chan_deact();
901 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
902}
903testcase TC_sacch_multi() runs on test_CT {
904 var ConnHdlr vc_conn;
905 var ConnHdlrPars pars;
906 f_init();
907 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
908 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
909 log(testcasename(), ": Starting for ", g_AllChannels[i]);
910 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
911 vc_conn.done;
912 }
913 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200914 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100915}
916
Harald Welte55700662018-03-12 13:15:43 +0100917/* Test if SACH information is modified as expected */
918private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
919 var octetstring si5 := f_rnd_octstring(19);
920 var octetstring si6 := f_rnd_octstring(19);
921
922 /* First, configure both SI5 and SI6 to be transmitted */
923 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
924 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
925
926 f_l1_tune(L1CTL);
927 RSL.clear;
928
929 /* activate the logical channel */
930 f_est_dchan();
931 L1CTL.clear;
932
933 /* check that SACCH actually are received as expected */
934 f_sacch_present(si5);
935 f_sacch_present(si6);
936
937 /* disable SI6 */
938 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
939
940 /* check that SI5 is still transmitted */
941 f_sacch_present(si5);
942 /* check if SI6 is now gone */
943 f_sacch_missing(si6);
944
945 /* release the channel */
946 f_rsl_chan_deact();
947 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
948}
949testcase TC_sacch_multi_chg() runs on test_CT {
950 var ConnHdlr vc_conn;
951 var ConnHdlrPars pars;
952 f_init();
953 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
954 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
955 log(testcasename(), ": Starting for ", g_AllChannels[i]);
956 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
957 vc_conn.done;
958 }
959 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200960 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +0100961}
962
Harald Welte075d84c2018-03-12 13:07:24 +0100963/* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
964/* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
Harald Welte629cc6b2018-03-11 17:19:05 +0100965
966
967/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100968 * RACH Handling
969 ***********************************************************************/
970
Harald Welte8c24c2b2018-02-26 08:31:31 +0100971/* like L1SAP_IS_PACKET_RACH */
972private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100973 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100974 return true;
975 }
976 return false;
977}
978
979/* generate a random RACH for circuit-switched */
980private function f_rnd_ra_cs() return OCT1 {
981 var OCT1 ra;
982 do {
983 ra := f_rnd_octstring(1);
984 } while (ra_is_ps(ra));
985 return ra;
986}
987
Harald Welte883340c2018-02-28 18:59:29 +0100988/* generate a random RACH for packet-switched */
989private function f_rnd_ra_ps() return OCT1 {
990 var OCT1 ra;
991 do {
992 ra := f_rnd_octstring(1);
993 } while (not ra_is_ps(ra));
994 return ra;
995}
996
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +0700997/* generate a random 11-bit RA (packet-switched only) */
998private function f_rnd_ra11_ps() return BIT11 {
999 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1000 return int2bit(ra11, 11);
1001}
1002
Harald Welte8c24c2b2018-02-26 08:31:31 +01001003/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1004testcase TC_rach_content() runs on test_CT {
1005 f_init(testcasename());
1006 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001007 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001008
Harald Welte8c24c2b2018-02-26 08:31:31 +01001009 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001010 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001011 for (var integer i := 0; i < 1000; i := i+1) {
1012 var OCT1 ra := f_rnd_ra_cs();
1013 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1014 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001015 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001016 }
1017 fn_last := fn;
1018
1019 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001020 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001021 alt {
1022 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1023 T.stop;
1024 }
1025 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001026 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001027 }
1028 [] RSL_CCHAN.receive { repeat; }
1029 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001030 test_failed := true;
1031 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001032 }
1033 }
1034 }
Maxba06feb2019-03-05 10:52:46 +01001035 if (test_failed) {
1036 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001037 }
Maxba06feb2019-03-05 10:52:46 +01001038 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001039 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001040}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001041
1042/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1043testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001044 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001045 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001046 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001047 f_l1_tune(L1CTL);
1048
1049 var GsmFrameNumber fn_last := 0;
1050 for (var integer i := 0; i < 1000; i := i+1) {
1051 var OCT1 ra := f_rnd_ra_cs();
1052 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1053 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001054 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001055 }
1056 fn_last := fn;
1057 }
1058 var integer rsl_chrqd := 0;
1059 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001060 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001061 alt {
1062 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1063 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001064 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001065 repeat;
1066 }
1067 [] RSL_CCHAN.receive { repeat; }
1068 [] T.timeout { }
1069 }
1070 if (rsl_chrqd == 1000) {
1071 setverdict(pass);
1072 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001073 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001074 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001075 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001076}
1077
Harald Welte54a2a2d2018-02-26 09:14:05 +01001078private function f_main_trxc_connect() runs on test_CT {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001079 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001080 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001081 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Welted3a88a62018-03-01 16:04:52 +01001082 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001083 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001084 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 +02001085 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001086 g_bts_trxc_conn_id := res.connId;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001087}
1088
1089private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001090 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001091 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001092 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001093 f_sleep(0.5);
1094
1095 /* Transmit RACH request + wait for confirmation */
1096 var OCT1 ra := f_rnd_ra_cs();
1097 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1098
1099 /* Check for expected result */
1100 timer T := 1.5;
1101 T.start;
1102 alt {
1103 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1104 setverdict(pass);
1105 }
1106 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001107 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001108 }
1109 [] RSL_CCHAN.receive { repeat; }
1110 [not expect_pass] T.timeout {
1111 setverdict(pass);
1112 }
1113 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001114 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001115 }
1116 }
1117}
1118
1119/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1120testcase TC_rach_max_ta() runs on test_CT {
1121 f_init(testcasename());
1122 f_init_l1ctl();
1123 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001124 f_sleep(1.0);
1125
1126 /* default max-ta is 63 (full range of GSM timing advance */
1127
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001128 /* We allow early arrival up to 2 symbols */
1129 f_rach_toffs(-1*256, true);
1130 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001131 f_rach_toffs(-10*256, false);
1132
1133 /* 0 / 32 / 63 bits is legal / permitted */
1134 f_rach_toffs(0, true);
1135 f_rach_toffs(32*256, true);
1136 f_rach_toffs(63*256, true);
1137
1138 /* more than 63 bits is not legal / permitted */
1139 f_rach_toffs(64*256, false);
1140 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001141 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001142}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001143
Harald Welte93640c62018-02-25 16:59:33 +01001144/***********************************************************************
1145 * Measurement Processing / Reporting
1146 ***********************************************************************/
1147
Harald Welte70767382018-02-21 12:16:40 +01001148template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1149 spare := '0'B,
1150 lpd := 0,
1151 sapi := sapi,
1152 c_r := c_r,
1153 ea := true
1154}
1155
Harald Welted879bd92018-03-12 15:01:23 +01001156template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001157 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001158 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001159 len := 0, /* overwritten */
1160 m := false,
1161 el := 1,
1162 payload := pl
1163}
1164
1165/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1166altstep as_l1_sacch() runs on ConnHdlr {
1167 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001168 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001169 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001170 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 +01001171 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001172 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001173
1174 var L1ctlDataReq data_req := {
1175 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1176 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1177 }
1178 log("Sending Measurement Report: ", data_req);
1179 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001180 repeat;
1181 }
1182}
1183
1184altstep as_l1_dcch() runs on ConnHdlr {
1185 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001186 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001187 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1188 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001189 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1190 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001191 repeat;
1192 }
1193}
1194
1195type record MeasElem {
1196 uint6_t rxlev,
1197 uint3_t rxqual
1198}
1199
1200type record MeasElemFS {
1201 MeasElem full,
1202 MeasElem sub
1203}
1204
1205type record ConnL1Pars {
1206 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001207 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001208 MeasElemFS meas_ul,
1209 int16_t timing_offset_256syms,
1210 uint5_t bs_power_level,
1211 uint5_t ms_power_level,
1212 uint8_t ms_actual_ta
1213}
1214
1215/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1216private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1217 return 63 + (toffs256s/256);
1218}
1219
Harald Welted5684392018-03-10 18:22:04 +01001220private function f_max(integer a, integer b) return integer {
1221 if (a > b) {
1222 return a;
1223 } else {
1224 return b;
1225 }
1226}
1227
1228private function f_min(integer a, integer b) return integer {
1229 if (a < b) {
1230 return a;
1231 } else {
1232 return b;
1233 }
1234}
1235
1236/* compute negative tolerance val-tolerance, ensure >= min */
1237private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1238 val := val - tolerance;
1239 return f_max(val, min);
1240}
1241
1242/* compute positive tolerance val+tolerance, ensure <= max */
1243private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1244 val := val + tolerance;
1245 return f_min(val, max);
1246}
1247
1248/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1249private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1250return template integer {
1251 var template integer ret;
1252 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1253 return ret;
1254}
1255
1256
Harald Welte70767382018-02-21 12:16:40 +01001257/* build a template for matching measurement results against */
1258private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1259 var ConnL1Pars l1p := g_pars.l1_pars;
1260 var template RSL_IE_UplinkMeas ul_meas := {
1261 len := 3,
1262 rfu := '0'B,
1263 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001264 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001265 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001266 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001267 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001268 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1269 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001270 supp_meas_info := omit
1271 };
Harald Welte685d5982018-02-27 20:42:05 +01001272 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001273 ul_meas.len := (3+8);
1274 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001275 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001276 toa256_min := ?,
1277 toa256_max := ?,
1278 toa256_std_dev := ?
1279 }
Harald Welte685d5982018-02-27 20:42:05 +01001280 }
Harald Welte70767382018-02-21 12:16:40 +01001281 var template RSL_IE_BS_Power bs_power := {
1282 reserved := 0,
1283 epc := false,
1284 fpc := false,
1285 power_level := l1p.bs_power_level
1286 };
1287 var template RSL_IE_L1Info l1_info := {
1288 ms_power_lvl := l1p.ms_power_level,
1289 fpc := false,
1290 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001291 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001292 };
1293 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001294 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001295 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1296 ?, t_toffs);
1297}
1298
1299/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001300altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001301 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001302 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001303 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1304 /* increment counter of next to-be-expected meas rep */
1305 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1306 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001307 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001308 repeat;
1309 }
1310 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001311 /* increment counter of next to-be-expected meas rep */
1312 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1313 if (g_first_meas_res) {
1314 g_first_meas_res := false;
1315 repeat;
1316 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001317 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001318 }
Harald Welte70767382018-02-21 12:16:40 +01001319 }
1320 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001321 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001322 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001323 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001324 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001325 }
1326}
1327
Harald Weltee613f962018-04-18 22:38:16 +02001328private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1329 select (rsl_alg_id) {
1330 case (RSL_ALG_ID_A5_0) { return 0; }
1331 case (RSL_ALG_ID_A5_1) { return 1; }
1332 case (RSL_ALG_ID_A5_2) { return 2; }
1333 case (RSL_ALG_ID_A5_3) { return 3; }
1334 case (RSL_ALG_ID_A5_4) { return 4; }
1335 case (RSL_ALG_ID_A5_5) { return 5; }
1336 case (RSL_ALG_ID_A5_6) { return 6; }
1337 case (RSL_ALG_ID_A5_7) { return 7; }
1338 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001339 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1340 /* Make compiler happy by calling mtc.stop here. It is already
1341 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001342 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001343 }
1344 }
1345}
1346
1347private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1348 select (rsl_alg_id) {
1349 case (RSL_ALG_ID_A5_1) { return '000'B; }
1350 case (RSL_ALG_ID_A5_2) { return '001'B; }
1351 case (RSL_ALG_ID_A5_3) { return '010'B; }
1352 case (RSL_ALG_ID_A5_4) { return '011'B; }
1353 case (RSL_ALG_ID_A5_5) { return '100'B; }
1354 case (RSL_ALG_ID_A5_6) { return '101'B; }
1355 case (RSL_ALG_ID_A5_7) { return '110'B; }
1356 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001357 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1358 /* Make compiler happy by calling mtc.stop here. It is already
1359 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001360 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001361 }
1362 }
1363}
1364
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001365/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1366private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1367 var GsmFrameNumber fn;
1368 timer T := 8.0;
1369
1370 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1371 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1372
1373 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1374 /* Send the actual RACH */
1375 fn := f_L1CTL_RACH(L1CTL, ra);
1376
1377 T.start;
1378 alt {
1379 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1380 [] T.timeout {
1381 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1382 }
1383 }
1384 T.stop
1385 return fn;
1386}
Harald Weltee613f962018-04-18 22:38:16 +02001387
Harald Welte70767382018-02-21 12:16:40 +01001388/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltee613f962018-04-18 22:38:16 +02001389private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001390 var GsmFrameNumber fn;
1391 var ImmediateAssignment imm_ass;
1392 var integer ra := 23;
1393
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001394 /* Send RACH request and wait for ChanReq */
1395 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001396
1397 /* Activate channel on BTS side */
Harald Weltee613f962018-04-18 22:38:16 +02001398 f_rsl_chan_act(g_pars.chan_mode, encr_enable);
Harald Welte70767382018-02-21 12:16:40 +01001399
1400 /* Send IMM.ASS via CCHAN */
1401 var ChannelDescription ch_desc := {
1402 chan_nr := g_pars.chan_nr,
1403 tsc := 7,
1404 h := false,
1405 arfcn := mp_trx0_arfcn,
1406 maio_hsn := omit
1407 };
1408 var MobileAllocation ma := {
1409 len := 0,
1410 ma := ''B
1411 };
1412 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1413 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1414
1415 /* receive IMM.ASS on MS side */
1416 var ImmediateAssignment ia_um;
1417 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1418 /* enable dedicated mode */
1419 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001420 /* enable encryption, if requested */
1421 if (encr_enable) {
1422 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1423 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1424 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001425
1426 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001427}
1428
1429/* establish DChan, verify existance + contents of measurement reports */
1430function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001431 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001432 RSL.clear;
1433
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001434 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001435 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001436 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1437 }
Harald Welte70767382018-02-21 12:16:40 +01001438
1439 f_est_dchan();
1440
1441 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1442 * RSL measurement reports on Abis side */
1443 timer T := 8.0;
1444 T.start;
1445 alt {
1446 [] as_l1_sacch();
1447 [] as_meas_res();
1448 [] as_l1_dcch();
1449 [] L1CTL.receive { repeat; }
1450 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001451 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001452 * of any earlier errors, so if we reach this timeout, we're good */
1453 setverdict(pass);
1454 }
1455 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001456 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001457 }
1458 }
1459 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001460 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001461}
Harald Welte0472ab42018-03-12 15:02:26 +01001462
Harald Welte70767382018-02-21 12:16:40 +01001463testcase TC_meas_res_sign_tchf() runs on test_CT {
1464 var ConnHdlr vc_conn;
1465 var ConnHdlrPars pars;
1466 f_init(testcasename());
1467 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1468 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1469 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1470 vc_conn.done;
1471 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001472 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001473}
1474testcase TC_meas_res_sign_tchh() runs on test_CT {
1475 var ConnHdlr vc_conn;
1476 var ConnHdlrPars pars;
1477 f_init(testcasename());
1478 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1479 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1480 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1481 vc_conn.done;
1482 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001483 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001484}
1485testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1486 var ConnHdlr vc_conn;
1487 var ConnHdlrPars pars;
1488 f_init(testcasename());
1489 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1490 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1491 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1492 vc_conn.done;
1493 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001494 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001495}
1496testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1497 var ConnHdlr vc_conn;
1498 var ConnHdlrPars pars;
1499 f_init(testcasename());
1500 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1501 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1502 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1503 vc_conn.done;
1504 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001505 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001506}
Harald Welte685d5982018-02-27 20:42:05 +01001507testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1508 var ConnHdlr vc_conn;
1509 var ConnHdlrPars pars;
1510 f_init(testcasename());
1511 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1512 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1513 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1514 pars.l1_pars.toa256_enabled := true;
1515 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1516 vc_conn.done;
1517 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001518 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01001519}
1520
Philipp Maier4d1e9c92018-12-20 11:11:56 +01001521/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
1522 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
1523function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
1524 var L1ctlDlMessage l1_dl;
1525 var RSL_IE_MS_Power ms_power;
1526 var RSL_Message rsl;
1527 var uint5_t power_level := 0;
1528
1529 f_l1_tune(L1CTL);
1530 RSL.clear;
1531
1532 f_est_dchan();
1533
1534 ms_power.reserved := 0;
1535 ms_power.fpc_epc := false;
1536
1537 /* Send the first power control command. This will disable any BTS/TRX
1538 * internal power control and switch the MS (which is not in scope of
1539 * this test) to a constant power level. We start with a power level
1540 * of 0 */
1541 ms_power.power_level := power_level;
1542 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1543 RSL.send(rsl);
1544
1545 alt {
1546
1547 /* Pick all SACCH blocks for checking */
1548 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1549
1550 /* The first byte of the L1 header contains the power level.
1551 * The reserved bits and the fpc bit is set to 0, so we may
1552 * compare directly. */
1553 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
1554 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
1555 }
1556
1557 /* Signal a new power level via RSL for the next turn. */
1558 if (power_level < 31) {
1559 power_level := power_level + 1;
1560 ms_power.power_level := power_level;
1561 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1562 RSL.send(rsl);
1563 repeat;
1564 }
1565
1566 }
1567
1568 /* Ignore all other blocks */
1569 [] L1CTL.receive { repeat; }
1570
1571 }
1572
1573 f_rsl_chan_deact();
1574 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1575
1576 setverdict(pass);
1577}
1578
1579testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
1580 var ConnHdlr vc_conn;
1581 var ConnHdlrPars pars;
1582 f_init(testcasename());
1583
1584 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1585 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1586 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
1587 vc_conn.done;
1588 }
1589 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1590}
Harald Welte70767382018-02-21 12:16:40 +01001591
Harald Welte0472ab42018-03-12 15:02:26 +01001592/* 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 +01001593private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001594 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001595 RSL.clear;
1596
1597 f_est_dchan();
1598 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001599 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001600
1601 timer T := 40.0;
1602 T.start;
1603 alt {
1604 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1605 setverdict(pass)
1606 }
1607 [] RSL.receive { repeat };
1608 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001609 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01001610 }
1611 }
1612 f_rsl_chan_deact();
1613}
1614testcase TC_conn_fail_crit() runs on test_CT {
1615 var ConnHdlr vc_conn;
1616 var ConnHdlrPars pars;
1617 f_init(testcasename());
1618 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1619 pars.t_guard := 60.0;
1620 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1621 vc_conn.done;
1622}
1623
Harald Welte93640c62018-02-25 16:59:33 +01001624/***********************************************************************
1625 * Paging
1626 ***********************************************************************/
1627
Harald Welte68e495b2018-02-25 00:05:57 +01001628function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1629 if (tmsi == 'FFFFFFFF'O) {
1630 return true;
1631 } else {
1632 return false;
1633 }
1634}
Harald Welte70767382018-02-21 12:16:40 +01001635
Philipp Maier82cb0b12018-08-31 14:41:39 +02001636type record allowedFn { integer frame_nr }
1637template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
1638template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
1639template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
1640template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
1641template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
1642template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
1643template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
1644template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
1645function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
1646{
1647 var integer frame_nr_51;
1648 frame_nr_51 := frame_nr mod 51
1649
1650 var allowedFn fn_check;
1651 fn_check.frame_nr := frame_nr_51;
1652
1653 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001654 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02001655 return;
1656 }
1657
1658 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
1659 return;
1660 }
1661 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
1662 return;
1663 }
1664 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
1665 return;
1666 }
1667 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
1668 return;
1669 }
1670 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
1671 return;
1672 }
1673 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
1674 return;
1675 }
1676 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
1677 return;
1678 }
1679 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
1680 return;
1681 }
1682
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001683 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02001684 return;
1685}
1686
1687altstep 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 +01001688runs on test_CT {
1689 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001690 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001691 repeat;
1692 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001693 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001694 var octetstring without_plen :=
1695 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1696 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02001697
1698 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
1699
Harald Welte68e495b2018-02-25 00:05:57 +01001700 if (match(rr, tr_PAGING_REQ1)) {
1701 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1702 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1703 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1704 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1705 }
1706 } else if (match(rr, tr_PAGING_REQ2)) {
1707 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1708 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1709 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1710 }
1711 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1712 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1713 }
1714 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1715 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1716 }
1717 } else if (match(rr, tr_PAGING_REQ3)) {
1718 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1719 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1720 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1721 }
1722 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1723 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1724 }
1725 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1726 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1727 }
1728 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1729 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1730 }
1731 }
1732 repeat;
1733 }
1734}
1735
1736type record PagingTestCfg {
1737 boolean combined_ccch,
1738 integer bs_ag_blks_res,
1739 float load_factor,
1740 boolean exp_load_ind,
1741 boolean exp_overload,
1742 boolean use_tmsi
1743}
1744
1745type record PagingTestState {
1746 integer num_paging_sent,
1747 integer num_paging_rcv_msgs,
1748 integer num_paging_rcv_ids,
1749 integer num_overload
1750}
1751
1752/* receive + ignore RSL RF RES IND */
1753altstep as_rsl_res_ind() runs on test_CT {
1754 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1755 repeat;
1756 }
1757}
1758
1759/* Helper function for paging related testing */
1760private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1761 f_init(testcasename());
1762 f_init_l1ctl();
1763 f_l1_tune(L1CTL);
1764
1765 var PagingTestState st := {
1766 num_paging_sent := 0,
1767 num_paging_rcv_msgs := 0,
1768 num_paging_rcv_ids := 0,
1769 num_overload := 0
1770 };
1771
1772 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1773 var float max_pch_imsi_per_sec;
1774 if (cfg.use_tmsi) {
1775 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1776 } else {
1777 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1778 }
1779 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1780 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001781 var float time_total := 20.0;
1782 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
1783 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01001784
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001785 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
1786 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01001787
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001788 timer T_itv := 0.0;
1789 T_itv.start;
1790 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01001791 alt {
1792 /* check for presence of CCCH LOAD IND (paging load) */
1793 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1794 st.num_overload := st.num_overload + 1;
1795 repeat;
1796 }
1797 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001798 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01001799 }
1800 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1801 log("Rx LOAD_IND");
1802 /* FIXME: analyze/verify interval + contents */
1803 repeat;
1804 }
1805 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02001806 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001807 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001808 [] T_itv.timeout {
1809 /* Send paging cmds based on elapsed time */
1810 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
1811 while (st.num_paging_sent < new_sent) {
1812 /* build mobile Identity */
1813 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1814 if (cfg.use_tmsi) {
1815 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1816 } else {
1817 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
1818 }
1819 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1820 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1821
1822 /* Send RSL PAGING COMMAND */
1823 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
1824
1825 st.num_paging_sent := st.num_paging_sent + 1;
1826 }
1827 if (st.num_paging_sent < pkt_total) {
1828 /* Wait for interval to next PAGING COMMAND */
1829 var float time_now := T_total.read;
1830 var float next_sched := int2float(st.num_paging_sent)*interval;
1831 if (next_sched > time_now) {
1832 T_itv.start(next_sched - time_now);
1833 } else {
1834 T_itv.start(0.0);
1835 }
1836 } else {
1837 /* We are done, no need to keep counting */
1838 T_total.stop;
1839 }
1840 }
1841 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01001842 [] as_rsl_res_ind();
1843 }
1844 }
1845
1846 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1847 timer T_wait := 18.0;
1848 T_wait.start;
1849 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02001850 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001851 [] L1CTL.receive { repeat; }
1852 /* 65535 == empty paging queue, we can terminate*/
1853 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1854 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1855 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001856 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01001857 }
1858 [] as_rsl_res_ind();
1859 }
1860
1861 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1862 " rcvd_ids=", st.num_paging_rcv_ids);
1863 return st;
1864}
1865
1866/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1867 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1868 * - that CCCH LOAD IND (PCH) are being generated
1869 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1870testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001871 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001872 var PagingTestCfg cfg := {
1873 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001874 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001875 load_factor := 0.8,
1876 exp_load_ind := true,
1877 exp_overload := false,
1878 use_tmsi := false
1879 };
1880 var PagingTestState st := f_TC_paging(cfg);
1881 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001882 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
1883 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01001884 } else {
1885 setverdict(pass);
1886 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001887 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001888}
1889
1890/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1891 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1892 * - that CCCH LOAD IND (PCH) are being generated
1893 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1894testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001895 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001896 var PagingTestCfg cfg := {
1897 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001898 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001899 load_factor := 0.8,
1900 exp_load_ind := true,
1901 exp_overload := false,
1902 use_tmsi := true
1903 };
1904 var PagingTestState st := f_TC_paging(cfg);
1905 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
1907 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01001908 } else {
1909 setverdict(pass);
1910 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001911 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001912}
1913
1914/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1915 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1916 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1917 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1918testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001919 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001920 var PagingTestCfg cfg := {
1921 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001922 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001923 load_factor := 2.0,
1924 exp_load_ind := true,
1925 exp_overload := true,
1926 use_tmsi := false
1927 };
1928 var PagingTestState st := f_TC_paging(cfg);
1929 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1930 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001931 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001932 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001933 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 +01001934 } else {
1935 setverdict(pass);
1936 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001937 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001938}
1939
1940/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1941 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1942 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1943 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1944testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001945 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001946 var PagingTestCfg cfg := {
1947 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001948 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001949 load_factor := 2.0,
1950 exp_load_ind := true,
1951 exp_overload := true,
1952 use_tmsi := true
1953 };
1954 var PagingTestState st := f_TC_paging(cfg);
1955 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1956 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001957 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001958 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001959 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 +01001960 } else {
1961 setverdict(pass);
1962 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001963 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01001964}
1965
1966
Harald Welte93640c62018-02-25 16:59:33 +01001967/***********************************************************************
1968 * Immediate Assignment / AGCH
1969 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02001970const MobileAllocation c_MA_null := {
1971 len := 0,
1972 ma := ''B
1973}
Harald Welte93640c62018-02-25 16:59:33 +01001974
Harald Weltee8d750e2018-06-10 21:41:35 +02001975template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
1976 uint12_t arfcn := 871) := {
1977 chan_nr := chan_nr,
1978 tsc := tsc,
1979 h := false,
1980 arfcn := arfcn,
1981 maio_hsn := omit
1982}
1983
1984private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
1985 return int2str(num_tx) & " sent, "
1986 & int2str(num_rx) & " received, "
1987 & int2str(num_del) & " deleted";
1988}
1989
1990private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
1991 var L1ctlDlMessage l1_dl;
1992 timer T := 10.0;
1993 var integer num_tx := 0;
1994 var integer num_rx := 0;
1995 var integer num_del := 0;
1996 var charstring res_str;
1997 var float rx_ratio;
1998
Harald Welte68e495b2018-02-25 00:05:57 +01001999 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02002000 f_init_l1ctl();
2001 f_l1_tune(L1CTL);
2002
2003 for (var integer i := 0; i < num_total; i := i+1) {
2004 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
2005 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
2006 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01002007 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02002008 num_tx := num_tx+1;
2009 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01002010 }
2011 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02002012 T.start;
2013 alt {
2014 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
2015 num_del := num_del+1;
2016 repeat;
2017 }
2018 [] RSL_CCHAN.receive {
2019 repeat;
2020 }
2021 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
2022 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2023 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
2024 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
2025 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002026 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02002027 } else {
2028 num_rx := num_rx+1;
2029 }
2030 repeat;
2031 }
2032 [] L1CTL.receive { repeat; }
2033 [] T.timeout { }
2034 }
2035 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
2036 log("AGCH test: " & res_str);
2037 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002038 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002039 }
2040 rx_ratio := int2float(num_rx) / int2float(num_tx);
2041 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002042 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 +02002043 } else {
2044 setverdict(pass);
2045 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002046 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002047}
2048
Harald Weltee8d750e2018-06-10 21:41:35 +02002049/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
2050testcase TC_imm_ass_1000_20ms() runs on test_CT {
2051 f_TC_imm_ass(1000, 0.02, 0.25);
2052}
2053
2054/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
2055testcase TC_imm_ass_200_0ms() runs on test_CT {
2056 f_TC_imm_ass(200, 0.0, 0.05);
2057}
2058
2059/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
2060testcase TC_imm_ass_200_76ms() runs on test_CT {
2061 f_TC_imm_ass(150, 0.076, 1.00);
2062}
2063
2064
2065
Harald Welte48494ca2018-02-25 16:59:50 +01002066/***********************************************************************
2067 * BCCH
2068 ***********************************************************************/
2069
2070/* tuple of Frame Number + decoded SI */
2071type record SystemInformationFn {
2072 GsmFrameNumber frame_number,
2073 SystemInformation si
2074}
2075
2076/* an arbitrary-length vector of decoded SI + gsmtap header */
2077type record of SystemInformationFn SystemInformationVector;
2078
2079/* an array of SI-vectors indexed by TC value */
2080type SystemInformationVector SystemInformationVectorPerTc[8];
2081
2082/* determine if a given SI vector contains given SI type at least once */
2083function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2084 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2085 var integer fn_mod51 := arr[i].frame_number mod 51;
2086 if (not bcch_ext and fn_mod51 == 2 or
2087 bcch_ext and fn_mod51 == 6) {
2088 if (arr[i].si.header.message_type == key) {
2089 return true;
2090 }
2091 }
2092 }
2093 return false;
2094}
2095
2096/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2097function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2098 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002099 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002100 }
2101}
2102
2103/* check if a given SI vector contains given SI type at least once on any TC */
2104function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2105 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2106 if (f_si_vecslot_contains(arr[tc], key) or
2107 f_si_vecslot_contains(arr[tc], key, true)) {
2108 return true;
2109 }
2110 }
2111 return false;
2112}
2113
2114/* determine if a given SI vector contains given SI type at least N of M times */
2115function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2116 var integer count := 0;
2117 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002118 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01002119 }
2120 for (var integer i:= 0; i < m; i := i + 1) {
2121 var integer fn_mod51 := arr[i].frame_number mod 51;
2122 if (not bcch_ext and fn_mod51 == 2 or
2123 bcch_ext and fn_mod51 == 6) {
2124 if (arr[i].si.header.message_type == key) {
2125 count := count + 1;
2126 }
2127 }
2128 }
2129 if (count >= n) {
2130 return true;
2131 } else {
2132 return false;
2133 }
2134}
2135
2136/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2137function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2138 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002139 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002140 }
2141}
2142
2143/* determine if a given SI vector contains given SI type at least once */
2144function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2145 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2146 var integer fn_mod51 := arr[i].frame_number mod 51;
2147 if (not bcch_ext and fn_mod51 == 2 or
2148 bcch_ext and fn_mod51 == 6) {
2149 if (arr[i].si.header.message_type != key) {
2150 return false;
2151 }
2152 }
2153 }
2154 return true;
2155}
2156
2157/* ensure a given TC slot of the SI vector contains only given SI type */
2158function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2159 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002160 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002161 }
2162}
2163
2164/* SI configuration of cell, against which we validate actual SI messages */
2165type set SystemInformationConfig {
2166 boolean bcch_extended,
2167 boolean si1_present,
2168 boolean si2bis_present,
2169 boolean si2ter_present,
2170 boolean si2quater_present,
2171 boolean si7_present,
2172 boolean si8_present,
2173 boolean si9_present,
2174 boolean si13_present,
2175 boolean si13alt_present,
2176 boolean si15_present,
2177 boolean si16_present,
2178 boolean si17_present,
2179 boolean si2n_present,
2180 boolean si21_present,
2181 boolean si22_present
2182}
2183
2184/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2185function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2186 var integer i;
2187 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2188 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002189 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01002190 }
2191 }
2192 if (cfg.si1_present) {
2193 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2194 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2195 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2196 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2197 /* make sure *ALL* contain SI1 */
2198 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2199 }
2200 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2201 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2202 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2203 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2204 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2205 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2206
2207 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2208 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2209 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2210 * consecutive occurrences of TC = 4. */
2211 if (cfg.si2bis_present and not cfg.si2ter_present) {
2212 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2213 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2214 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2215 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2216 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2217 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2218 }
2219
2220 if (cfg.si7_present or cfg.si8_present) {
2221 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2222 * if System Information type 4 does not contain all information needed for cell
2223 * selection and reselection. */
2224 if (not cfg.bcch_extended) {
2225 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2226 }
2227 if (cfg.si7_present) {
2228 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2229 }
2230 if (cfg.si8_present) {
2231 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2232 }
2233 }
2234
2235 if (cfg.si2quater_present) {
2236 /* iii) System information type 2 quater is sent if needed, as determined by the system
2237 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2238 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2239 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2240 * within any of 4 consecutive occurrences of TC = 5. */
2241 if (not (cfg.bcch_extended)) {
2242 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2243 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2244 } else {
2245 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2246 }
2247 } else {
2248 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2249 }
2250 }
2251 if (cfg.si9_present) {
2252 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2253 * in system information type 3 as defined in 3GPP TS 44.018. */
2254 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2255 }
2256 if (cfg.si13_present) {
2257 /* vii) System Information type 13 is only related to the GPRS service. System Information
2258 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2259 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2260 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2261 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2262 * within any of 4 consecutive occurrences of TC=4. */
2263 if (not cfg.bcch_extended) {
2264 log("not-bccch-extended");
2265 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2266 } else {
2267 log("bccch-extended");
2268 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2269 }
2270 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002271 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002272 }
2273 }
2274 if (cfg.si16_present or cfg.si17_present) {
2275 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2276 * should not be sent in a cell where network sharing is used (see rule xv). */
2277 if (cfg.si22_present) {
2278 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2279 }
2280 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002281 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002282 }
2283 if (not cfg.bcch_extended) {
2284 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2285 }
2286 if (cfg.si16_present) {
2287 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2288 }
2289 if (cfg.si17_present) {
2290 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2291 }
2292 }
2293
2294 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2295 * broadcast information. The frequency with which they are sent is determined by the
2296 * system operator. System Information type 9 identifies the scheduling of System
2297 * Information type 18 and 20 messages. */
2298
2299 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2300 * Information Type 19 is present, then its scheduling shall be indicated in System
2301 * Information Type 9. */
2302
2303 if (cfg.si15_present) {
2304 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2305 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2306 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2307 * 4 consecutive occurrences of TC = 1. */
2308 if (not cfg.bcch_extended) {
2309 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2310 } else {
2311 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2312 }
2313 }
2314 if (cfg.si13alt_present) {
2315 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2316 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2317 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2318 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2319 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2320 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2321 * of TC = 4. */
2322 if (cfg.si13_present) {
2323 testcase.stop("Error: Cannot have SI13alt and SI13");
2324 }
2325 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002326 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002327 }
2328 if (not cfg.bcch_extended) {
2329 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2330 } else {
2331 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2332 }
2333 }
2334 if (cfg.si2n_present) {
2335 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2336 * as determined by the system operator. In the case that the message is sent on the
2337 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2338 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2339 * consecutive occurrences of TC = 4. */
2340 if (not cfg.bcch_extended) {
2341 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2342 } else {
2343 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2344 }
2345 }
2346 if (cfg.si21_present) {
2347 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2348 * determined by the system operator. If Extended Access Barring is in use in the cell
2349 * then this message is sent at least once within any of 4 consecutive occurrences of
2350 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2351 * cell then this message shall only be sent on BCCH Ext. */
2352 if (not cfg.bcch_extended) {
2353 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2354 } else {
2355 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2356 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002357 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01002358 }
2359 }
2360 }
2361 if (cfg.si22_present) {
2362 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2363 * should not be sent in a cell where SoLSA is used (see rule viii). System
2364 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2365 * =2 and TC=6. */
2366 if (cfg.si16_present or cfg.si17_present) {
2367 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2368 }
2369 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2370 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002371 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002372 }
2373 if (not cfg.bcch_extended) {
2374 testcase.stop("Error: SI22 requires BCCH Extd!");
2375 } else {
2376 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2377 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2378 }
2379 }
2380}
2381
2382/* sample Systme Information for specified duration via L1CTL */
2383function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2384 timer T := duration;
2385 var SystemInformationVectorPerTc si_per_tc;
2386 var L1ctlDlMessage l1_dl;
2387
2388 /* initialize all per-TC vectors empty */
2389 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2390 si_per_tc[i] := {};
2391 }
2392
2393 /* flush all previous L1 queued msgs */
2394 pt.clear;
2395
2396 T.start;
2397 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002398 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002399 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2400 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2401 log("Ignoring non-RR SI ", l1_dl);
2402 repeat;
2403 }
2404 var SystemInformationFn sig := {
2405 frame_number := l1_dl.dl_info.frame_nr,
2406 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2407 }
2408 var integer tc := f_gsm_compute_tc(sig.frame_number);
2409 log("SI received at TC=", tc, ": ", sig.si);
2410 /* append to the per-TC bucket */
2411 si_per_tc[tc] := si_per_tc[tc] & { sig };
2412 repeat;
2413 }
2414 [] pt.receive { repeat; }
2415 [] T.timeout { }
2416 }
2417
2418 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2419 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2420 }
2421 log("si_per_tc=", si_per_tc);
2422 return si_per_tc;
2423}
2424
2425/* helper function: Set given SI via RSL + validate scheduling.
2426 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2427function f_TC_si_sched() runs on test_CT {
2428 var SystemInformationVectorPerTc si_per_tc;
2429 f_init_l1ctl();
2430 f_l1_tune(L1CTL);
2431
2432 /* Sample + Validate Scheduling */
2433 si_per_tc := f_l1_sample_si(L1CTL);
2434 f_validate_si_scheduling(si_cfg, si_per_tc);
2435
2436 setverdict(pass);
2437}
2438
2439testcase TC_si_sched_default() runs on test_CT {
2440 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002441 /* 2+3+4 are mandatory and set in f_init() */
2442 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002443 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01002444}
2445
2446testcase TC_si_sched_1() runs on test_CT {
2447 f_init();
2448 si_cfg.si1_present := true;
2449 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002450 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002451 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002452}
2453
2454testcase TC_si_sched_2bis() runs on test_CT {
2455 f_init();
2456 si_cfg.si2bis_present := true;
2457 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2458 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002459 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002460}
2461
2462testcase TC_si_sched_2ter() runs on test_CT {
2463 f_init();
2464 si_cfg.si2ter_present := true;
2465 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2466 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002467 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002468}
2469
2470testcase TC_si_sched_2ter_2bis() runs on test_CT {
2471 f_init();
2472 si_cfg.si2bis_present := true;
2473 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2474 si_cfg.si2ter_present := true;
2475 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2476 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002477 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002478}
2479
2480testcase TC_si_sched_2quater() runs on test_CT {
2481 f_init();
2482 si_cfg.si2quater_present := true;
2483 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2484 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002485 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002486}
2487
2488testcase TC_si_sched_13() runs on test_CT {
2489 f_init();
2490 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002491 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002492 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002493 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002494}
2495
2496testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2497 f_init();
2498 si_cfg.si2bis_present := true;
2499 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2500 si_cfg.si2ter_present := true;
2501 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2502 si_cfg.si2quater_present := true;
2503 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2504 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002505 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002506 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002507 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002508}
2509
2510
Harald Welte68e495b2018-02-25 00:05:57 +01002511testcase TC_bcch_info() runs on test_CT {
2512 f_init(testcasename());
2513 /* FIXME: enable / disable individual BCCH info */
2514 //ts_RSL_BCCH_INFO(si_type, info);
2515 /* expect no ERROR REPORT after either of them *
2516 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002517 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002518}
2519
Harald Welte93640c62018-02-25 16:59:33 +01002520/***********************************************************************
2521 * Low-Level Protocol Errors / ERROR REPORT
2522 ***********************************************************************/
2523
Harald Welte01d982c2018-02-25 01:31:40 +01002524private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2525 timer T := 5.0;
2526 T.start;
2527 alt {
2528 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2529 setverdict(pass);
2530 }
2531 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002532 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002533 }
2534 [] RSL_CCHAN.receive {
2535 repeat;
2536 }
2537 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002538 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002539 }
2540 }
2541}
2542
2543/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2544testcase TC_rsl_protocol_error() runs on test_CT {
2545 f_init(testcasename());
2546 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2547 rsl.ies := omit;
2548 RSL_CCHAN.send(ts_RSL_UD(rsl));
2549
2550 f_exp_err_rep(RSL_ERR_PROTO);
2551}
2552
2553/* Provoke a mandatory IE error and match on ERROR REPORT */
2554testcase TC_rsl_mand_ie_error() runs on test_CT {
2555 f_init(testcasename());
2556
2557 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2558 rsl.ies := { rsl.ies[0] };
2559 RSL_CCHAN.send(ts_RSL_UD(rsl));
2560
2561 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2562}
2563
2564/* Provoke an IE content error and match on ERROR REPORT */
2565testcase TC_rsl_ie_content_error() runs on test_CT {
2566 f_init(testcasename());
2567 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2568 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2569 RSL_CCHAN.send(ts_RSL_UD(rsl));
2570
2571 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2572}
2573
Harald Welte93640c62018-02-25 16:59:33 +01002574/***********************************************************************
2575 * IPA CRCX/MDCX/DLCS media stream handling
2576 ***********************************************************************/
2577
Harald Weltea871a382018-02-25 02:03:14 +01002578/* Send IPA DLCX to inactive lchan */
2579function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01002580 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2581 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01002582}
2583testcase TC_ipa_dlcx_not_active() runs on test_CT {
2584 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2585 f_init(testcasename());
2586 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
2587 vc_conn.done;
2588}
Harald Welte68e495b2018-02-25 00:05:57 +01002589
Harald Weltea3f1df92018-02-25 12:49:55 +01002590/* Send IPA CRCX twice to inactive lchan */
2591function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
2592 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2593 "IPA CRCX ACK");
2594 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
2595 "IPA CRCX NACK");
2596}
2597testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
2598 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2599 f_init(testcasename());
2600 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
2601 vc_conn.done;
2602}
2603
2604/* Regular sequence of CRCX/MDCX/DLCX */
2605function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2606 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2607 "IPA CRCX ACK");
2608 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2609 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2610 var uint7_t rtp_pt2 := f_rnd_int(127);
2611 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2612 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2613 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2614 "IPA MDCX ACK");
2615 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2616 "IPA DLCX ACK");
2617}
2618testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
2619 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2620 f_init(testcasename());
2621 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
2622 vc_conn.done;
2623}
2624
Harald Welte3ae11da2018-02-25 13:36:06 +01002625/* Sequence of CRCX, 2x MDCX, DLCX */
2626function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2627 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2628 "IPA CRCX ACK");
2629 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2630 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2631 var uint7_t rtp_pt2 := f_rnd_int(127);
2632 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2633 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2634 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2635 "IPA MDCX ACK");
2636 /* Second MDCX */
2637 remote_ip := f_rnd_int(c_UINT32_MAX);
2638 remote_port := f_rnd_int(c_UINT16_MAX);
2639 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2640 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2641 "IPA MDCX ACK");
2642 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2643 "IPA DLCX ACK");
2644}
2645testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2646 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2647 f_init(testcasename());
2648 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2649 vc_conn.done;
2650}
2651
Harald Welte9912eb52018-02-25 13:30:15 +01002652/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2653function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2654 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2655 "IPA CRCX NACK");
2656}
2657testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2658 var ConnHdlrPars pars;
2659 var ConnHdlr vc_conn;
2660 f_init(testcasename());
2661
2662 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2663 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2664 vc_conn.done;
2665
2666 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2667 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2668 vc_conn.done;
2669}
2670
Harald Weltea3f1df92018-02-25 12:49:55 +01002671
Harald Welte883340c2018-02-28 18:59:29 +01002672/***********************************************************************
2673 * PCU Socket related tests
2674 ***********************************************************************/
2675
2676private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2677runs on test_CT {
2678 timer T := 3.0;
2679
2680 /* we don't expect any RTS.req before PDCH are active */
2681 T.start;
2682 alt {
2683 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002684 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01002685 }
2686 [] PCU.receive { repeat; }
2687 [] T.timeout { }
2688 }
2689
2690 /* Send PDCH activate request for known PDCH timeslot */
2691 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2692
2693 /* we now expect RTS.req for this timeslot (only) */
2694 T.start;
2695 alt {
2696 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2697 setverdict(pass);
2698 }
2699 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2700 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01002702 }
2703 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002704 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01002705 }
2706 [] PCU.receive { repeat; }
2707 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002708 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01002709 }
2710 [not exp_success] T.timeout {
2711 setverdict(pass);
2712 }
2713 }
2714}
2715
2716private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2717runs on test_CT {
2718 timer T := 3.0;
2719
2720 /* Send PDCH activate request for known PDCH timeslot */
2721 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2722
2723 PCU.clear;
2724 /* we now expect no RTS.req for this timeslot */
2725 T.start;
2726 alt {
2727 [] 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 +02002728 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01002729 }
2730 [] PCU.receive { repeat; }
2731 [] T.timeout {
2732 setverdict(pass);
2733 }
2734 }
2735}
2736
Max2c6f5632019-03-18 17:25:17 +01002737private function f_init_pcu_test() runs on test_CT {
2738 f_init();
2739 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
2740}
2741
Harald Welte883340c2018-02-28 18:59:29 +01002742/* PDCH activation via PCU socket; check for presence of RTS.req */
2743testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002744 f_init_pcu_test();
2745
Harald Welte883340c2018-02-28 18:59:29 +01002746 f_TC_pcu_act_req(0, 0, 7, true);
2747}
2748
2749/* PDCH activation via PCU socket on non-PDCU timeslot */
2750testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002751 f_init_pcu_test();
2752
Harald Welte883340c2018-02-28 18:59:29 +01002753 f_TC_pcu_act_req(0, 0, 1, false);
2754}
2755
2756/* PDCH activation via PCU socket on wrong BTS */
2757testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002758 f_init_pcu_test();
2759
Harald Welte883340c2018-02-28 18:59:29 +01002760 f_TC_pcu_act_req(23, 0, 7, false);
2761}
2762
2763/* PDCH activation via PCU socket on wrong TRX */
2764testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002765 f_init_pcu_test();
2766
Harald Welte883340c2018-02-28 18:59:29 +01002767 f_TC_pcu_act_req(0, 23, 7, false);
2768}
2769
2770/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2771testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002772 f_init_pcu_test();
2773
Harald Welte883340c2018-02-28 18:59:29 +01002774 /* Activate PDCH */
2775 f_TC_pcu_act_req(0, 0, 7, true);
2776 f_sleep(1.0);
2777 /* and De-Activate again */
2778 f_TC_pcu_deact_req(0, 0, 7);
2779}
2780
2781/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2782testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002783 f_init_pcu_test();
2784
Harald Welte883340c2018-02-28 18:59:29 +01002785 f_TC_pcu_deact_req(0, 0, 1);
2786}
2787
2788/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2789testcase TC_pcu_ver_si13() runs on test_CT {
2790 const octetstring si13 := '00010203040506070909'O;
2791 var PCUIF_send_data sd;
2792 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01002793 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002794
2795 /* Set SI13 via RSL */
2796 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01002797
Harald Welte883340c2018-02-28 18:59:29 +01002798 T.start;
2799 alt {
2800 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2801 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2802 setverdict(pass);
2803 } else {
2804 repeat;
2805 }
2806 }
2807 [] PCU.receive { repeat; }
2808 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002809 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01002810 }
2811 }
2812}
2813
2814private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2815
2816/* helper function to send a PCU DATA.req */
2817private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2818 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2819runs on test_CT
2820{
2821 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2822 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2823}
2824
2825/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2826private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2827 PCUIF_Sapi sapi, octetstring data)
2828runs on test_CT
2829{
2830 var PCUIF_send_data sd;
2831
2832 timer T := 3.0;
2833 T.start;
2834 alt {
2835 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2836 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2837 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2838 sd.data.u.rts_req.fn, sapi, data);
2839 }
2840 [] PCU.receive { repeat; }
2841 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002842 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01002843 }
2844 }
2845}
2846
2847/* Send DATA.req on invalid BTS */
2848testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002849 f_init_pcu_test();
2850
Harald Welte883340c2018-02-28 18:59:29 +01002851 f_TC_pcu_act_req(0, 0, 7, true);
2852 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2853 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2854 f_sleep(10.0);
2855}
2856
2857/* Send DATA.req on invalid TRX */
2858testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002859 f_init_pcu_test();
2860
Harald Welte883340c2018-02-28 18:59:29 +01002861 f_TC_pcu_act_req(0, 0, 7, true);
2862 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2863 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2864 f_sleep(10.0);
2865}
2866
2867/* Send DATA.req on invalid timeslot */
2868testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002869 f_init_pcu_test();
2870
Harald Welte883340c2018-02-28 18:59:29 +01002871 f_TC_pcu_act_req(0, 0, 7, true);
2872 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2873 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2874 f_sleep(10.0);
2875}
2876
2877/* Send DATA.req on timeslot that hasn't been activated */
2878testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002879 f_init_pcu_test();
2880
Harald Welte883340c2018-02-28 18:59:29 +01002881 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2882 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2883 f_sleep(2.0);
2884}
2885
2886testcase TC_pcu_data_req_pdtch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002887 f_init_pcu_test();
2888
Harald Welte883340c2018-02-28 18:59:29 +01002889 f_TC_pcu_act_req(0, 0, 7, true);
2890 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2891 /* FIXME: how to check this was actually sent */
2892 f_sleep(2.0);
2893}
2894
2895testcase TC_pcu_data_req_ptcch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002896 f_init_pcu_test();
2897
Harald Welte883340c2018-02-28 18:59:29 +01002898 f_TC_pcu_act_req(0, 0, 7, true);
2899 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2900 /* FIXME: how to check this was actually sent */
2901 f_sleep(2.0);
2902}
2903
2904/* Send AGCH from PCU; check it appears on Um side */
2905testcase TC_pcu_data_req_agch() runs on test_CT {
2906 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01002907 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002908 f_init_l1ctl();
2909 f_l1_tune(L1CTL);
2910
2911 f_TC_pcu_act_req(0, 0, 7, true);
2912 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2913
2914 T.start;
2915 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002916 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002917 setverdict(pass);
2918 }
2919 [] L1CTL.receive { repeat; }
2920 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002921 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01002922 }
2923 }
2924}
2925
2926/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2927testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2928 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01002929 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002930 f_init_l1ctl();
2931 f_l1_tune(L1CTL);
2932
2933 /* append 3 last imsi digits so BTS can compute pagng group */
2934 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2935
2936 timer T := 0.5;
2937 T.start;
2938 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002939 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002940 /* TODO: verify paging group */
2941 setverdict(pass);
2942 }
2943 [] L1CTL.receive { repeat; }
2944 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002945 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01002946 }
2947 }
2948}
2949
2950/* Send RACH from Um side, expect it to show up on PCU socket */
2951testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01002952 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01002953 f_init_l1ctl();
2954 f_l1_tune(L1CTL);
2955
2956 var GsmFrameNumber fn_last := 0;
2957 for (var integer i := 0; i < 1000; i := i+1) {
2958 var OCT1 ra := f_rnd_ra_ps();
2959 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2960 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002961 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01002962 }
2963 fn_last := fn;
2964
2965 timer T := 2.0;
2966 T.start;
2967 alt {
2968 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2969 T.stop;
2970 }
2971 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002972 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01002973 }
2974 [] PCU.receive { repeat; }
2975 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002976 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01002977 }
2978 }
2979 }
2980 setverdict(pass);
2981}
2982
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07002983/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
2984 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
2985testcase TC_pcu_ext_rach_content() runs on test_CT {
2986 var template PCUIF_Message pcu_rach_ind;
2987 var GsmFrameNumber fn_last := 0;
2988 var L1ctlRachSynchSeq synch_seq;
2989 var PCUIF_BurstType pcu_bt;
2990 var GsmFrameNumber fn;
2991 var BIT11 ra11;
2992
2993 f_init_pcu_test();
2994 f_init_l1ctl();
2995 f_l1_tune(L1CTL);
2996
2997 for (var integer i := 0; i < 1000; i := i+1) {
2998 /* We need to test both TS1 & TS2 */
2999 if (i rem 2 == 0) {
3000 synch_seq := RACH_SYNCH_SEQ_TS1;
3001 pcu_bt := BURST_TYPE_1;
3002 } else {
3003 synch_seq := RACH_SYNCH_SEQ_TS2;
3004 pcu_bt := BURST_TYPE_2;
3005 }
3006
3007 ra11 := f_rnd_ra11_ps();
3008 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
3009 if (fn == fn_last) {
3010 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3011 "Two RACH in same FN?!?");
3012 }
3013 fn_last := fn;
3014
3015 /* Compose the expected message */
3016 pcu_rach_ind := tr_PCUIF_RACH_IND(
3017 bts_nr := 0,
3018 ra := bit2int(ra11),
3019 is_11bit := 1,
3020 burst_type := pcu_bt,
3021 fn := fn);
3022
3023 timer T := 2.0;
3024 T.start;
3025 alt {
3026 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
3027 T.stop;
3028 }
3029 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
3030 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
3031 }
3032 [] PCU.receive { repeat; }
3033 [] T.timeout {
3034 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
3035 }
3036 }
3037 }
3038 setverdict(pass);
3039}
3040
Harald Welte883340c2018-02-28 18:59:29 +01003041private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
3042 var integer strlen := lengthof(str);
3043 for (var integer i := 0; i < len-strlen; i := i+1) {
3044 str := str & pad;
3045 }
3046 return str;
3047}
3048
3049/* Send PAGING via RSL, expect it to shw up on PCU socket */
3050testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003051 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003052
3053 for (var integer i := 0; i < 100; i := i+1) {
3054 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
3055 timer T := 3.0;
3056 if (i < 50) {
3057 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
3058 } else {
3059 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
3060 }
3061 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
3062 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
3063 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
3064
3065 /* Send RSL PAGING COMMAND */
3066 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
3067 T.start;
3068 alt {
3069 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
3070 }
3071 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003072 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003073 }
3074 [] PCU.receive { repeat; }
3075 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003076 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003077 }
3078 }
3079 }
3080 setverdict(pass);
3081}
3082
Harald Welte3d04ae62018-04-04 20:29:05 +02003083/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02003084 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02003085 ***********************************************************************/
3086
3087private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3088runs on ConnHdlr {
3089 var PCUIF_send_data sd;
3090 /* Expect BTS to immediately acknowledge activation as PDCH */
3091 PCU.clear;
3092 f_rsl_chan_act(g_pars.chan_mode);
3093 /* expect INFO_IND on PCU interface listing TS as PDCH */
3094 alt {
3095 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3096 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 +02003097 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003098 }
3099 }
3100 [] PCU.receive { repeat; }
3101 }
3102 /* try to activate this PDCH from the PCU point of view */
3103 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3104 /* FIXME: is there a response? */
3105}
3106
3107private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3108runs on ConnHdlr {
3109 var PCUIF_send_data sd;
3110 /* Send RSL CHAN REL (deactivate) */
3111 PCU.clear;
3112 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3113 /* expect BTS to ask PCU to deactivate the channel */
3114 alt {
3115 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3116 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 +02003117 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003118 }
3119 }
3120 [] PCU.receive { repeat; }
3121 }
3122 /* Emulate PCU asking BTS to deactivate PDCH */
3123 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3124 alt {
3125 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
3126 setverdict(pass);
3127 }
3128 [] RSL.receive { repeat; }
3129 }
3130}
3131
3132/* Activate Osmocom-style dynamic PDCH from BSC side */
3133function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3134 var PCUIF_Message first_info;
3135 var integer ts_nr := g_chan_nr.tn;
3136 var integer trx_nr := 0;
3137 var integer bts_nr := 0;
3138 var integer pcu_conn_id := -1;
3139
3140 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3141
3142 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3143 f_sleep(3.0);
3144 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3145 setverdict(pass);
3146}
3147testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3148 var ConnHdlrPars pars;
3149 var ConnHdlr vc_conn;
3150 f_init(testcasename());
3151
3152 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3153 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3154 vc_conn.done;
3155}
3156
3157/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3158function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3159 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003160 var integer pcu_conn_id := -1;
3161
3162 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3163
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003164 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3165 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3166 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003167 setverdict(pass);
3168}
3169testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3170 var ConnHdlrPars pars;
3171 var ConnHdlr vc_conn;
3172 f_init(testcasename());
3173
3174 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3175 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3176 vc_conn.done;
3177}
3178
3179/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3180function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3181 var PCUIF_Message first_info;
3182 var integer ts_nr := g_chan_nr.tn;
3183 var integer trx_nr := 0;
3184 var integer bts_nr := 0;
3185 var integer pcu_conn_id := -1;
3186
3187 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3188
3189 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003190 /* Send a second Chan Activ and expect it to be NACKed */
3191 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3192 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003193 setverdict(pass);
3194}
3195testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3196 var ConnHdlrPars pars;
3197 var ConnHdlr vc_conn;
3198 f_init(testcasename());
3199
3200 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3201 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3202 vc_conn.done;
3203}
3204
3205/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3206function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3207 var PCUIF_Message first_info;
3208 var integer ts_nr := g_chan_nr.tn;
3209 var integer trx_nr := 0;
3210 var integer bts_nr := 0;
3211 var integer pcu_conn_id := -1;
3212 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3213
3214 /* register for the TCH/F channel number */
3215 f_rslem_register(0, chan_nr);
3216
3217 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3218
3219 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3220 "RSL CHAN ACT");
3221 setverdict(pass);
3222}
3223testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3224 var ConnHdlrPars pars;
3225 var ConnHdlr vc_conn;
3226 f_init(testcasename());
3227
3228 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3229 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3230 vc_conn.done;
3231}
3232
3233/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3234function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3235 var PCUIF_Message first_info;
3236 var integer ts_nr := g_chan_nr.tn;
3237 var integer trx_nr := 0;
3238 var integer bts_nr := 0;
3239 var integer pcu_conn_id := -1;
3240 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3241 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3242
3243 /* register for the TCH/H channel numbers */
3244 f_rslem_register(0, chan_nr[0]);
3245 f_rslem_register(0, chan_nr[1]);
3246
3247 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3248
3249 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3250 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3251 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3252 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3253 setverdict(pass);
3254}
3255testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3256 var ConnHdlrPars pars;
3257 var ConnHdlr vc_conn;
3258 f_init(testcasename());
3259
3260 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3261 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3262 vc_conn.done;
3263}
3264
Harald Welte9bbbfb52018-04-05 09:33:19 +02003265/***********************************************************************
3266 * IPA Style Dynamic Timeslot Support
3267 ***********************************************************************/
3268
3269private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3270runs on ConnHdlr {
3271 var PCUIF_send_data sd;
3272 /* Expect BTS to immediately acknowledge activation as PDCH */
3273 PCU.clear;
3274 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3275 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003276 timer T_wait := 2.0;
3277 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003278 alt {
3279 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3280 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 +01003281 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
3282 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3283 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003284 }
3285 }
3286 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003287 [] T_wait.timeout {
3288 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3289 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
3290 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003291 }
3292 /* try to activate this PDCH from the PCU point of view */
3293 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3294 /* FIXME: is there a response? */
3295
3296 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3297}
3298
3299private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3300runs on ConnHdlr {
3301 var PCUIF_send_data sd;
3302 /* Send RSL CHAN REL (deactivate) */
3303 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3304 PCU.clear;
3305 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003306 timer T_wait := 2.0;
3307 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003308 alt {
3309 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3310 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 +01003311 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
3312 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3313 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003314 }
3315 }
3316 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003317 [] T_wait.timeout {
3318 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3319 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
3320 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003321 }
3322 /* Emulate PCU asking BTS to deactivate PDCH */
3323 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3324 alt {
3325 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3326 setverdict(pass);
3327 }
3328 [] RSL.receive { repeat; }
3329 }
3330}
3331
3332/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3333function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3334 var PCUIF_Message first_info;
3335 var integer ts_nr := g_chan_nr.tn;
3336 var integer trx_nr := 0;
3337 var integer bts_nr := 0;
3338 var integer pcu_conn_id := -1;
3339
3340 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3341
3342 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3343 f_sleep(3.0);
3344 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3345
3346 setverdict(pass);
3347
3348}
3349testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3350 var ConnHdlrPars pars;
3351 var ConnHdlr vc_conn;
3352 f_init();
3353
3354 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3355 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3356 vc_conn.done;
3357}
3358
3359/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3360function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3361 var PCUIF_Message first_info;
3362 var integer ts_nr := g_chan_nr.tn;
3363 var integer trx_nr := 0;
3364 var integer bts_nr := 0;
3365 var integer pcu_conn_id := -1;
3366
3367 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3368
3369 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3370 "RSL CHAN ACT");
3371 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3372 "RF CHAN REL", true);
3373 setverdict(pass);
3374}
3375testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3376 var ConnHdlrPars pars;
3377 var ConnHdlr vc_conn;
3378 f_init(testcasename());
3379
3380 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3381 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3382 vc_conn.done;
3383}
3384
3385/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3386function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3387 var PCUIF_Message first_info;
3388 var integer ts_nr := g_chan_nr.tn;
3389 var integer trx_nr := 0;
3390 var integer bts_nr := 0;
3391 var integer pcu_conn_id := -1;
3392
3393 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3394
3395 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3396 "RSL CHAN ACT");
3397
3398 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3399 alt {
3400 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3401 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003402 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02003403 }
3404 [] RSL.receive { repeat; }
3405 }
3406
3407 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3408 "RF CHAN REL", true);
3409 setverdict(pass);
3410}
3411testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3412 var ConnHdlrPars pars;
3413 var ConnHdlr vc_conn;
3414 f_init(testcasename());
3415
3416 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3417 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3418 vc_conn.done;
3419}
3420
3421/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3422function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3423 var PCUIF_Message first_info;
3424 var integer ts_nr := g_chan_nr.tn;
3425 var integer trx_nr := 0;
3426 var integer bts_nr := 0;
3427 var integer pcu_conn_id := -1;
3428
3429 /* register for the TCH/F channel number */
3430 f_rslem_register(0, g_chan_nr);
3431
3432 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3433
3434 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3435
3436 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3437 "RSL CHAN ACT");
3438
3439 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3440
3441 setverdict(pass);
3442}
3443testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3444 var ConnHdlrPars pars;
3445 var ConnHdlr vc_conn;
3446 f_init(testcasename());
3447
3448 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3449 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3450 vc_conn.done;
3451}
3452
3453
Harald Welte0472ab42018-03-12 15:02:26 +01003454/***********************************************************************
3455 * LAPDm / RLL related
3456 ***********************************************************************/
3457
3458private function f_tx_lapdm(template (value) LapdmFrame l,
3459 template (value) RslLinkId link_id) runs on ConnHdlr {
3460 var octetstring l2 := enc_LapdmFrame(valueof(l));
3461 if (valueof(link_id.c) == SACCH) {
3462 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02003463 var L1ctlDataReq l1hl2 := {
3464 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
3465 l2_payload := f_pad_oct(l2, 21, '2B'O)
3466 }
3467 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
3468 } else {
3469 /* If required, pad L2 frame with constant 0x2b filling */
3470 l2 := f_pad_oct(l2, 23, '2B'O);
3471
3472 log("encoding ", l, " to ", l2);
3473 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01003474 }
Harald Welte0472ab42018-03-12 15:02:26 +01003475}
3476
3477type record RllTestCase {
3478 uint3_t sapi,
3479 RslLinkId link_id,
3480 octetstring l3,
3481 boolean exp
3482}
3483type record of RllTestCase RllTestCases;
3484template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3485 sapi := sapi,
3486 link_id := id,
3487 l3 := l3,
3488 exp := exp
3489}
3490
3491/* execute the same callback function with a set of different parameters (tcs) on a
3492 * variety of logical channels */
3493private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
3494 var ConnHdlrPars pars;
3495 var ConnHdlr vc_conn;
3496 f_init(testcasename());
3497
3498 /* test on each of the channels we have */
3499 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
3500 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
3501
3502 /* test each of the test cases on the current channel */
3503 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
3504 pars.spec.rll := tcs[j];
3505 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
3506 vc_conn := f_start_handler(fn, pars);
3507 vc_conn.done;
3508 }
3509 }
3510
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003511 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01003512}
3513
3514/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
3515private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
3516 var RllTestCase tc := g_pars.spec.rll;
3517 timer T := 3.0;
3518
3519 f_l1_tune(L1CTL);
3520 RSL.clear;
3521
3522 /* activate the logical channel */
3523 f_est_dchan();
3524 L1CTL.clear;
3525
3526 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
3527 T.start;
3528 alt {
3529 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
3530 if (tc.exp) {
3531 setverdict(pass);
3532 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003533 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01003534 }
3535 }
3536 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
3537 if (tc.exp) {
3538 setverdict(pass);
3539 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003540 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01003541 }
3542 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003543 /* We also expect to receive the measurements */
3544 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003545 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003546 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01003547 }
3548 [not tc.exp] T.timeout {
3549 setverdict(pass);
3550 }
3551 }
3552
3553 f_rsl_chan_deact();
3554 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3555 f_rslem_unregister(0, g_chan_nr);
3556}
3557testcase TC_rll_est_ind() runs on test_CT {
3558 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02003559 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01003560 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02003561 /* normal SAPI0 establishment */
3562 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01003563 /* SAPI 3 doesn't support contention resolution */
3564 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
3565 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
3566 /* normal SAPI3 establishment on main DCCH */
3567 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3568 /* normal SAPI3 establishment on SACCH */
3569 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3570 };
3571 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
3572}
3573
3574/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
3575private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
3576 var RllTestCase tc := g_pars.spec.rll;
3577 var L1ctlDlMessage dl;
3578 timer T := 3.0;
3579
3580 f_l1_tune(L1CTL);
3581 RSL.clear;
3582
3583 /* activate the logical channel */
3584 f_est_dchan();
3585 L1CTL.clear;
3586
3587 /* Send a RSL EST REQ for SAPI3 on main DCCH */
3588 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
3589 T.start;
3590 alt {
3591 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3592 var LapdmFrame lapdm;
3593 var octetstring l2 := dl.payload.data_ind.payload;
3594 if (dl.dl_info.link_id.c == SACCH) {
3595 /* remove L1 header */
3596 l2 := substr(l2, 2, lengthof(l2)-2);
3597 }
3598 lapdm.ab := dec_LapdmFrameAB(l2);
3599 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
3600 setverdict(pass);
3601 } else {
3602 repeat;
3603 }
3604 }
3605 [] L1CTL.receive { repeat; }
3606 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003607 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01003608 }
3609 }
3610
3611 f_rsl_chan_deact();
3612 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3613 f_rslem_unregister(0, g_chan_nr);
3614}
3615testcase TC_rll_est_req_DCCH_3() runs on test_CT {
3616 var RllTestCases tcs := {
3617 /* normal SAPI3 establishment on main DCCH */
3618 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
3619 };
3620 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3621}
3622testcase TC_rll_est_req_ACCH_3() runs on test_CT {
3623 var RllTestCases tcs := {
3624 /* normal SAPI3 establishment on SACCH */
3625 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3626 }
3627 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3628}
3629
3630/* altstep to receive a LAPDm frame matching the given template */
3631private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
3632 var L1ctlDlMessage dl;
3633 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3634 var LapdmFrame lapdm;
3635 var octetstring l2 := dl.payload.data_ind.payload;
3636 if (dl.dl_info.link_id.c == SACCH) {
3637 /* remove L1 header */
3638 l2 := substr(l2, 2, lengthof(l2)-2);
3639 }
3640 if (ischosen(exp.ab)) {
3641 lapdm.ab := dec_LapdmFrameAB(l2);
3642 } else if (ischosen(exp.b4)) {
3643 lapdm.b4 := dec_LapdmFrameB4(l2);
3644 } else if (ischosen(exp.bbis)) {
3645 lapdm.bbis := dec_LapdmFrameBbis(l2);
3646 }
3647 log("Rx LAPDm ", lapdm);
3648 if (match(lapdm, exp)) {
3649 setverdict(pass);
3650 } else {
3651 repeat;
3652 }
3653 }
3654 [] L1CTL.receive { repeat; }
3655}
3656private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
3657 timer T := t;
3658 T.start;
3659 alt {
3660 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003661 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01003662 }
3663 [] as_l1_exp_lapdm(exp);
3664 }
3665}
3666
3667/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
3668private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3669 /* send SABM from MS -> BTS */
3670 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
3671 /* expect RLL EST IND on Abis */
3672 alt {
3673 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
3674 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
3675 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003676 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01003677 }
3678 [] RSL.receive { repeat; }
3679 }
3680 /* expect UA from BTS -> MS */
3681 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
3682}
3683
3684/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
3685private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
3686 var RllTestCase tc := g_pars.spec.rll;
3687
3688 f_l1_tune(L1CTL);
3689 RSL.clear;
3690
3691 /* activate the logical channel */
3692 f_est_dchan();
3693 L1CTL.clear;
3694
3695 /* first establish the link-layer */
3696 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3697
3698 /* then send the DISC */
3699 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
3700 /* ... and expect the REL IND on the RSL side */
3701 alt {
3702 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
3703 setverdict(pass);
3704 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003705 /* We also expect to receive the measurements */
3706 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003707 }
3708
3709 /* release the channel */
3710 f_rsl_chan_deact();
3711 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3712 f_rslem_unregister(0, g_chan_nr);
3713}
3714testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
3715 var RllTestCases tcs := {
3716 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
3717 };
3718 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3719}
3720
3721testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
3722 var RllTestCases tcs := {
3723 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
3724 };
3725 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3726}
3727testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
3728 var RllTestCases tcs := {
3729 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
3730 };
3731 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3732}
3733testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
3734 var RllTestCases tcs := {
3735 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3736 };
3737 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3738}
3739
3740/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
3741private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
3742 var RllTestCase tc := g_pars.spec.rll;
3743 f_l1_tune(L1CTL);
3744 RSL.clear;
3745
3746 /* activate the logical channel */
3747 f_est_dchan();
3748 L1CTL.clear;
3749
3750 /* first establish the link-layer */
3751 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3752
3753 /* then send the REL REQ via RSL */
3754 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
3755 /* ... and expect the DISC on the Um side */
3756 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02003757 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01003758 /* FIXME: send a UA in resposne to the DISC */
3759 }
3760 }
3761
3762 /* release the channel */
3763 f_rsl_chan_deact();
3764 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3765 f_rslem_unregister(0, g_chan_nr);
3766}
3767testcase TC_rll_rel_req() runs on test_CT {
3768 var RllTestCases tcs := {
3769 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
3770 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
3771 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3772 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3773 };
3774 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
3775}
3776
3777/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
3778testcase TC_rll_data_req() runs on test_CT {
3779}
3780
3781/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
3782testcase TC_rll_data_ind() runs on test_CT {
3783}
3784
3785/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
3786private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
3787 var RllTestCase tc := g_pars.spec.rll;
3788
3789 f_l1_tune(L1CTL);
3790 RSL.clear;
3791
3792 f_est_dchan();
3793 L1CTL.clear;
3794
3795 /* Send UNITDATA REQ on RSL side */
3796 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
3797 /* Expect it to arrive on the other side */
3798 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02003799 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003800 } else {
Harald Weltee613f962018-04-18 22:38:16 +02003801 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003802 }
3803
3804 /* release the channel */
3805 f_rsl_chan_deact();
3806 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3807 f_rslem_unregister(0, g_chan_nr);
3808}
3809testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
3810 var octetstring l3 := f_rnd_octstring(15);
3811 var RllTestCases tcs := {
3812 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3813 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3814 };
3815 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3816}
3817testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
3818 var octetstring l3 := f_rnd_octstring(19);
3819 var RllTestCases tcs := {
3820 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3821 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3822 };
3823 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3824}
3825
3826/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
3827private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
3828 var RllTestCase tc := g_pars.spec.rll;
3829
3830 f_l1_tune(L1CTL);
3831 RSL.clear;
3832
3833 f_est_dchan();
3834 L1CTL.clear;
3835
3836 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02003837 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01003838 /* Expdct RLL UNITDATA IND on RSL side */
3839 alt {
3840 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
3841 setverdict(pass);
3842 }
3843 [] RSL.receive { repeat; }
3844 }
3845
3846 /* release the channel */
3847 f_rsl_chan_deact();
3848 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3849 f_rslem_unregister(0, g_chan_nr);
3850}
3851testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02003852 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01003853 var RllTestCases tcs := {
3854 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3855 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3856 };
3857 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3858}
3859testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
3860 var octetstring l3 := f_rnd_octstring(18);
3861 var RllTestCases tcs := {
3862 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3863 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3864 };
3865 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3866}
3867
Harald Weltee613f962018-04-18 22:38:16 +02003868/***********************************************************************
3869 * Encryption Related
3870 ***********************************************************************/
3871
3872/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3873function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3874 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
3875 if (link_id.c == SACCH) {
3876 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
3877 } else {
3878 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
3879 }
3880}
3881
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003882/* Expect (or not expect) other kinds of messages */
3883private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
3884 [exp_any] RSL.receive { repeat; }
3885 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003886 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003887 }
3888}
3889
Harald Weltee613f962018-04-18 22:38:16 +02003890/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07003891private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003892 RslLinkId link_id,
3893 octetstring l3,
3894 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003895 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003896) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02003897 timer T := 3.0;
3898 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
3899 T.start;
3900 /* Expect RLL UNITDATA IND on RSL side */
3901 alt {
3902 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
3903 setverdict(pass);
3904 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003905 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003906 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02003907 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003908 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02003909 }
Harald Weltee613f962018-04-18 22:38:16 +02003910 }
3911}
3912
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003913/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
3914private function f_data_mo(
3915 RslLinkId link_id,
3916 boolean p, uint3_t nr, uint3_t ns,
3917 octetstring l3,
3918 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003919 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003920) runs on ConnHdlr {
3921 timer T := 3.0;
3922 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
3923 T.start;
3924 /* Expect RLL DATA IND on RSL side */
3925 alt {
3926 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
3927 setverdict(pass);
3928 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003929 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003930 [] as_rsl_any_ind(exp_any);
3931 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003932 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003933 }
3934 }
3935}
3936
Harald Weltee613f962018-04-18 22:38:16 +02003937/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
3938function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
3939 f_l1_tune(L1CTL);
3940 f_est_dchan(true);
3941
3942 /* now we actually need to transmit some data both ways to check if the encryption works */
3943 var L1ctlDlMessage dl;
3944
Stefan Sperling603d98e2018-07-25 16:47:28 +02003945 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02003946 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3947
3948 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3949 f_unitdata_mt(link_id, l3);
3950
3951 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
3952 f_unitdata_mo(link_id, l3);
3953
3954 /* release the channel */
3955 f_rsl_chan_deact();
3956 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3957 f_rslem_unregister(0, g_chan_nr);
3958}
3959testcase TC_chan_act_a51() 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_1, f_rnd_octstring(8)));
3962 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3963}
3964testcase TC_chan_act_a52() 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_2, f_rnd_octstring(8)));
3967 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3968}
3969testcase TC_chan_act_a53() runs on test_CT {
3970 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3971 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3972 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3973}
3974
3975
3976/* Test unencrypted channel activation followed by explicit ENCR CMD later */
3977function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
3978 /* L3 payload doesn't matter, as it is passed transparently */
3979 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
3980 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
3981 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3982
3983 f_l1_tune(L1CTL);
3984
3985 /* first establish a dedicated channel in the clear */
3986 f_est_dchan(false);
3987
3988 /* Establish ABM */
3989 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3990
3991 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
3992 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
3993 /* expect the L3 to arrive still unencrypted on the MS side */
3994 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
3995
3996 /* configure L1 to apply ciphering */
3997 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
3998 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
3999
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004000 /* send first ciphered I-frame in response and expect it on RSL */
4001 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02004002
4003 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
4004 * and hence enable encryption also on the downlink */
4005
4006 /* expect bi-directional communication work in encrypted mode */
4007 f_unitdata_mo(link_id, f_rnd_octstring(15));
4008 f_unitdata_mt(link_id, f_rnd_octstring(15));
4009
4010 /* release the channel */
4011 f_rsl_chan_deact();
4012 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4013 f_rslem_unregister(0, g_chan_nr);
4014}
4015testcase TC_encr_cmd_a51() 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_1, f_rnd_octstring(8)));
4018 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4019}
4020testcase TC_encr_cmd_a52() 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_2, f_rnd_octstring(8)));
4023 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4024}
4025testcase TC_encr_cmd_a53() runs on test_CT {
4026 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4027 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4028 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4029}
4030
4031private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
4032 var LapdmFrame lf;
4033 var octetstring reenc;
4034
4035 /* decode the LAPDm frame */
4036 if (ischosen(exp_match.ab)) {
4037 lf.ab := dec_LapdmFrameAB(enc);
4038 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004039 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02004040 }
4041
4042 /* check if decoder result matches expectation */
4043 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004044 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004045 } else {
4046 log(name, ": matched");
4047 setverdict(pass);
4048 }
4049
4050 /* test if re-encoded frame equals original input */
4051 reenc := enc_LapdmFrame(lf);
4052 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004053 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004054 } else {
4055 setverdict(pass);
4056 }
4057}
4058
4059testcase TC_lapdm_selftest() runs on test_CT {
4060 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
4061 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
4062 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
4063 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
4064 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
4065 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
4066 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
4067}
4068
Stefan Sperling4880be42018-08-07 18:12:59 +02004069/***********************************************************************
4070 * DTX Related (see GSM 05.08, section 8.3)
4071 ***********************************************************************/
4072
4073/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
4074function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
4075 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
4076 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
4077 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
4078 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
4079}
4080function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
4081 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
4082 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
4083}
4084function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
4085 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
4086 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
4087 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
4088 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
4089}
4090function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
4091 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
4092 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
4093 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
4094 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
4095 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
4096 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
4097 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
4098 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
4099}
4100
4101function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
4102 var L1ctlDlMessage dl;
4103 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
4104 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
4105 var GsmFrameNumber first_fn;
4106 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004107 var integer nfill_frames_sacch := 0;
4108 var integer nfill_frames_nonsacch := 0;
4109 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02004110 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
4111 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004112 const integer frame_dtx_tchf_mod := 104;
4113 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
4114 * which operates in terms of blocks rather than frames. */
4115 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
4116 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02004117 timer T := 5.0;
4118
4119 f_l1_tune(L1CTL);
4120 RSL.clear;
4121 L1CTL.clear;
4122
4123 /* activate TCHF signalling channel */
4124 f_est_dchan(false);
4125
4126 T.start;
4127 alt {
4128 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4129 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4130 var octetstring l2 := dl.payload.data_ind.payload;
4131
4132 if (is_first_frame) {
4133 is_first_frame := false;
4134 first_fn := dl.dl_info.frame_nr;
4135 }
4136
4137 if (dl.dl_info.link_id.c == SACCH) {
4138 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4139 if (not match(l2_fill_frame_sacch, l2)) {
4140 repeat;
4141 }
4142 } else if (not match(l2_fill_frame, l2)) {
4143 repeat;
4144 }
4145
4146 if (dtxd) {
4147 if (not f_g_chan_is_tchf()) {
4148 T.stop;
4149 f_rsl_chan_deact();
4150 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004151 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 +02004152 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004153 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004154 T.stop;
4155 f_rsl_chan_deact();
4156 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004157
4158 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4159 * 2 SACCH, 1 TCH/F */
4160 expected_fill_frames := 3;
4161
4162 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4163 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4164 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004165 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004166 } else {
4167 setverdict(pass);
4168 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004169 } else {
4170 if (dl.dl_info.link_id.c == SACCH) {
4171 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004172 repeat;
4173 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004174 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4175 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4176 * we should only see the subset of frames numbers which correspond to a block boundary.
4177 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4178 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4179 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4180 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4181 repeat;
4182 }
4183 }
4184 log("Received DTX TCH fill frame with bad frame number: ", fn,
4185 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4186 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4187 f_rsl_chan_deact();
4188 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004189 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004190 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004191 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004192 if (dl.dl_info.link_id.c == SACCH) {
4193 nfill_frames_sacch := nfill_frames_sacch + 1;
4194 } else {
4195 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4196 }
4197 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004198 T.stop;
4199 if (f_g_chan_is_tchf()) {
4200 /* Without DTX we can expect 25 fill frames for every 104 frames.
4201 * (24 FACCH + 1 SACCH filling) */
4202 expected_fill_frames := 25;
4203 } else if (f_g_chan_is_tchh()) {
4204 /* We can expect 2 fill frames for every 104 frames. */
4205 expected_fill_frames := 2;
4206 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4207 /* We can expect 5 fill frames for every 104 frames. */
4208 expected_fill_frames := 5;
4209 } else {
4210 f_rsl_chan_deact();
4211 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004212 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02004213 }
4214
4215 f_rsl_chan_deact();
4216 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004217
4218 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004219 setverdict(pass);
4220 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004221 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4222 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004223 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004224 }
4225 } else {
4226 repeat;
4227 }
4228 }
4229 }
4230 [] L1CTL.receive { repeat; }
4231 [] T.timeout {
4232 f_rsl_chan_deact();
4233 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004235 }
4236 }
4237}
4238
4239function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4240 f_test_l2_fill_frames(false);
4241}
4242
4243function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4244 f_test_l2_fill_frames(true);
4245}
4246
4247function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4248 var ConnHdlr vc_conn;
4249 var ConnHdlrPars pars;
4250 pars.t_guard := 60.0;
4251 f_init(testcasename());
4252 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4253 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4254 if (dtxd) {
4255 if (i >= 4) { /* DTX is only allowed on TCH/F */
4256 break;
4257 }
4258 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4259 } else {
4260 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4261 }
4262 vc_conn.done;
4263 }
4264}
4265
4266/* Verify that L2 fill frames are sent on TCH in signaling mode if
4267 * there is nothing to transmit while DTX is disabled on downlink. */
4268testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4269 f_tch_sign_l2_fill_frame(false);
4270}
4271
4272/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4273 * there is nothing to transmit while DTX is enabled on downlink. */
4274testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4275 f_tch_sign_l2_fill_frame(true);
4276}
Harald Welte0472ab42018-03-12 15:02:26 +01004277
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004278testcase TC_chopped_ipa_ping() runs on test_CT {
4279 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4280}
4281
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004282testcase TC_chopped_ipa_payload() runs on test_CT {
4283 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4284}
4285
Harald Welte0472ab42018-03-12 15:02:26 +01004286/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4287/* protocol error as per 44.006 */
4288/* link layer failure (repetition of I-frame N200 times without ACK */
4289/* repetition of SABM or DISC N200 times without ACK */
4290/* receptiom of SABM in multi-frame established state */
4291
4292
4293
4294
Harald Welte883340c2018-02-28 18:59:29 +01004295
Harald Welte68e495b2018-02-25 00:05:57 +01004296/* TODO Areas:
4297
4298* channel activation
4299** with BS_Power / MS_Power, bypassing power control loop
4300** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004301** with timing advance from initial activation on
4302* mode modify
4303** encryption
4304** multirate
4305* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004306** unsupported algorithm
4307* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01004308* BS Power Control
4309* Physical Context
Harald Welte43c54642018-09-15 17:47:04 +03004310* CCCH Load Indication for RACH
Harald Welte68e495b2018-02-25 00:05:57 +01004311* SMS Broadcast Req / Cmd / CBCH LOad Ind
4312* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004313* error handling
Harald Welte43c54642018-09-15 17:47:04 +03004314** discriminator error
Harald Welte68e495b2018-02-25 00:05:57 +01004315** type error
4316** sequence error
4317** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004318* PCU interface
4319** TIME_IND from BTS->PCU
4320** DATA_IND from BTS->PCU
4321** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004322
4323*/
Harald Welte70767382018-02-21 12:16:40 +01004324
4325control {
4326 execute( TC_chan_act_stress() );
4327 execute( TC_chan_act_react() );
4328 execute( TC_chan_deact_not_active() );
4329 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004330 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004331 execute( TC_sacch_filling() );
4332 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004333 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004334 execute( TC_sacch_multi_chg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004335 execute( TC_rach_content() );
4336 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004337 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004338 execute( TC_meas_res_sign_tchf() );
4339 execute( TC_meas_res_sign_tchh() );
4340 execute( TC_meas_res_sign_sdcch4() );
4341 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004342 execute( TC_meas_res_sign_tchh_toa256() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01004343 execute( TC_rsl_ms_pwr_ctrl() );
Harald Welte70767382018-02-21 12:16:40 +01004344 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004345 execute( TC_paging_imsi_80percent() );
4346 execute( TC_paging_tmsi_80percent() );
4347 execute( TC_paging_imsi_200percent() );
4348 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004349 execute( TC_rsl_protocol_error() );
4350 execute( TC_rsl_mand_ie_error() );
4351 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004352 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004353 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004354 execute( TC_si_sched_2bis() );
4355 execute( TC_si_sched_2ter() );
4356 execute( TC_si_sched_2ter_2bis() );
4357 execute( TC_si_sched_2quater() );
4358 execute( TC_si_sched_13() );
4359 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004360 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004361 execute( TC_ipa_crcx_twice_not_active() );
4362 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004363 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004364 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004365
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004366 if (mp_pcu_socket != "") {
4367 execute( TC_pcu_act_req() );
4368 execute( TC_pcu_act_req_wrong_ts() );
4369 execute( TC_pcu_act_req_wrong_bts() );
4370 execute( TC_pcu_act_req_wrong_trx() );
4371 execute( TC_pcu_deact_req() );
4372 execute( TC_pcu_deact_req_wrong_ts() );
4373 execute( TC_pcu_ver_si13() );
4374 execute( TC_pcu_data_req_wrong_bts() );
4375 execute( TC_pcu_data_req_wrong_trx() );
4376 execute( TC_pcu_data_req_wrong_ts() );
4377 execute( TC_pcu_data_req_ts_inactive() );
4378 execute( TC_pcu_data_req_pdtch() );
4379 execute( TC_pcu_data_req_ptcch() );
4380 execute( TC_pcu_data_req_agch() );
4381 execute( TC_pcu_data_req_imm_ass_pch() );
4382 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004383 execute( TC_pcu_ext_rach_content() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004384 execute( TC_pcu_paging_from_rsl() );
4385 } else {
4386 log("PCU socket path not available, skipping PCU tests");
4387 }
Harald Welte3d04ae62018-04-04 20:29:05 +02004388
4389 execute( TC_dyn_osmo_pdch_act_deact() );
4390 execute( TC_dyn_osmo_pdch_unsol_deact() );
4391 execute( TC_dyn_osmo_pdch_double_act() );
4392 execute( TC_dyn_osmo_pdch_tchf_act() );
4393 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004394 execute( TC_dyn_ipa_pdch_act_deact() );
4395 execute( TC_dyn_ipa_pdch_tchf_act() );
4396 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4397 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004398
4399 execute( TC_rll_est_ind() );
4400 execute( TC_rll_est_req_DCCH_3() );
4401 execute( TC_rll_est_req_ACCH_3() );
4402 execute( TC_rll_rel_ind_DCCH_0() );
4403 execute( TC_rll_rel_ind_DCCH_3() );
4404 execute( TC_rll_rel_ind_ACCH_0() );
4405 execute( TC_rll_rel_ind_ACCH_3() );
4406 execute( TC_rll_rel_req() );
4407 execute( TC_rll_unit_data_req_DCCH() );
4408 execute( TC_rll_unit_data_req_ACCH() );
4409 execute( TC_rll_unit_data_ind_DCCH() );
4410 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004411
4412 execute( TC_chan_act_a51() );
4413 execute( TC_chan_act_a52() );
4414 execute( TC_chan_act_a53() );
4415 execute( TC_encr_cmd_a51() );
4416 execute( TC_encr_cmd_a52() );
4417 execute( TC_encr_cmd_a53() );
4418
4419 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004420
4421 execute( TC_tch_sign_l2_fill_frame() );
4422 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004423
4424 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004425 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01004426}
4427
4428
4429}