blob: 9c749b45992f1dc4027a0e58a31ed15f25fd43d5 [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
3import from General_Types all;
4import from GSM_Types all;
5import from GSM_RR_Types all;
6import from Osmocom_Types all;
7import from GSM_Types all;
Harald Welte82ccef72018-02-25 16:17:33 +01008import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +01009import from L1CTL_PortType all;
10import from L1CTL_Types all;
11import from LAPDm_Types all;
12import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020013import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010014
15import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010016import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010017import from IPA_Emulation all;
18import from RSL_Emulation all;
19
20import from IPL4asp_Types all;
21import from TRXC_Types all;
22import from TRXC_CodecPort all;
23import from TRXC_CodecPort_CtrlFunct all;
24
Harald Welte883340c2018-02-28 18:59:29 +010025import from PCUIF_Types all;
26import from PCUIF_CodecPort all;
27
Harald Welte7484fc42018-02-24 14:09:45 +010028import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010029import from MobileL3_RRM_Types all;
30import from MobileL3_Types all;
31import from L3_Templates all;
Harald Welte7484fc42018-02-24 14:09:45 +010032
Harald Welte8da48242018-02-27 20:41:32 +010033import from Osmocom_VTY_Functions all;
34import from TELNETasp_PortType all;
35
Harald Welte70767382018-02-21 12:16:40 +010036/* The tests assume a BTS with the following timeslot configuration:
37 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020038 * TS1 : TCH/F
39 * TS2 : TCH/F
40 * TS3 : TCH/F_PDCH (IPA Style)
41 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010042 * TS5 : TCH/H
43 * TS6 : SDCCH/8
44 * TS7 : PDCH
45 */
46
47modulepar {
48 charstring mp_rsl_ip := "127.0.0.2";
49 integer mp_rsl_port := 3003;
50 integer mp_trx0_arfcn := 871;
Harald Weltea4d8f352018-03-01 15:47:20 +010051 charstring mp_bb_trxc_ip := "127.0.0.1";
Harald Welteef3e1c92018-02-28 23:40:14 +010052 integer mp_bb_trxc_port := 6701;
Harald Welte883340c2018-02-28 18:59:29 +010053 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020054 charstring mp_ctrl_ip := "127.0.0.1";
55 integer mp_ctrl_port := 4238;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020056 integer mp_tolerance_rxqual := 1;
57 integer mp_tolerance_rxlev := 3;
58 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020059 integer mp_rxlev_exp := 57;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020060 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020061 integer mp_ms_actual_ta_exp := 0;
62 integer mp_timing_offset_256syms_exp := 512;
Harald Welte70767382018-02-21 12:16:40 +010063}
64
Harald Welte629cc6b2018-03-11 17:19:05 +010065type record of RslChannelNr ChannelNrs;
66
Harald Welte70767382018-02-21 12:16:40 +010067type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010068 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010069 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010070 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010071 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010072 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010073 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010074
75 /* L1CTL port (for classic tests) */
76 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010077
Harald Welte54a2a2d2018-02-26 09:14:05 +010078 /* TRXC port (for classic tests) */
79 port TRXC_CODEC_PT BB_TRXC;
80 var integer g_bb_trxc_conn_id;
81
Harald Weltef50e3ae2018-09-10 10:27:56 +020082 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010083 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020084 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010085
Harald Welte883340c2018-02-28 18:59:29 +010086 /* PCU Interface of BTS */
87 port PCUIF_CODEC_PT PCU;
88 var integer g_pcu_conn_id;
89 /* Last PCU INFO IND we received */
90 var PCUIF_Message g_pcu_last_info;
91
Harald Welte48494ca2018-02-25 16:59:50 +010092 /* SI configuration */
93 var SystemInformationConfig si_cfg := {
94 bcch_extended := false,
95 si1_present := false,
96 si2bis_present := false,
97 si2ter_present := false,
98 si2quater_present := false,
99 si7_present := false,
100 si8_present := false,
101 si9_present := false,
102 si13_present := false,
103 si13alt_present := false,
104 si15_present := false,
105 si16_present := false,
106 si17_present := false,
107 si2n_present := false,
108 si21_present := false,
109 si22_present := false
110 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100111
112 /* all logical channels available on the BTS */
113 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100114 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100115}
116
117/* an individual call / channel */
118type component ConnHdlr extends RSL_DchanHdlr {
119 port L1CTL_PT L1CTL;
120
121 port TRXC_CODEC_PT BB_TRXC;
122 var integer g_bb_trxc_conn_id;
123
124 timer g_Tguard;
125 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
126
127 var ConnHdlrPars g_pars;
128 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100129 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200130
131 /* PCU Interface of BTS */
132 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100133}
134
135function f_init_rsl(charstring id) runs on test_CT {
136 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
137 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
138
139 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
140 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
141 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
142
143 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
144 vc_RSL.start(RSL_Emulation.main(false));
145}
146
147type record ConnHdlrPars {
148 RslChannelNr chan_nr,
149 RSL_IE_ChannelMode chan_mode,
150 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100151 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200152 TestSpecUnion spec optional,
153 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100154}
155
156/* Test-specific parameters */
157type union TestSpecUnion {
158 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100159}
160
Harald Welte82ccef72018-02-25 16:17:33 +0100161template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100162 max_retrans := RACH_MAX_RETRANS_7,
163 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100164 cell_barr_access := false,
165 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100166 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100167};
168
Harald Weltef10153f2018-02-25 16:34:05 +0100169template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100170 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200171 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100172 acs := '0'B,
173 neci := true,
174 rxlev_access_min := 0
175}
176
177template (value) LocationAreaIdentification ts_LAI_default := {
178 mcc_mnc := '262F42'H,
179 lac := 42
180}
181
Harald Welte7484fc42018-02-24 14:09:45 +0100182/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100183template (value) SystemInformation ts_SI3_default := {
184 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100185 payload := {
186 si3 := {
187 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100188 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100189 ctrl_chan_desc := {
190 msc_r99 := true,
191 att := true,
192 bs_ag_blks_res := 1,
193 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100194 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100195 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
196 spare := '00'B,
197 bs_pa_mfrms := 0, /* 2 multiframes */
198 t3212 := 1 /* 6 minutes */
199 },
Harald Welte82ccef72018-02-25 16:17:33 +0100200 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100201 dn_ind := false,
202 pwrc := false,
203 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100204 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100205 },
Harald Weltef10153f2018-02-25 16:34:05 +0100206 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100207 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100208 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100209 }
210 }
211}
Harald Welte70767382018-02-21 12:16:40 +0100212
Harald Weltef8df4cb2018-03-10 15:15:08 +0100213template (value) SystemInformation ts_SI2_default := {
214 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100215 payload := {
216 si2 := {
217 bcch_freq_list := '00000000000000000000000000000000'O,
218 ncc_permitted := '11111111'B,
219 rach_control := ts_RachCtrl_default
220 }
221 }
222}
223
Harald Weltef8df4cb2018-03-10 15:15:08 +0100224template (value) SystemInformation ts_SI4_default := {
225 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100226 payload := {
227 si4 := {
228 lai := ts_LAI_default,
229 cell_sel_par := ts_CellSelPar_default,
230 rach_control := ts_RachCtrl_default,
231 cbch_chan_desc := omit,
232 cbch_mobile_alloc := omit,
233 rest_octets := ''O
234 }
235 }
236}
237
238function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
239runs on test_CT {
240 log("Setting ", rsl_si_type, ": ", si_enc);
241 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
242}
243
244function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
245runs on test_CT {
246 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
247 log("Setting ", rsl_si_type, ": ", si_dec);
248 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
249}
250
Harald Welte8da48242018-02-27 20:41:32 +0100251private function f_init_vty(charstring id) runs on test_CT {
252 map(self:BTSVTY, system:BTSVTY);
253 f_vty_set_prompts(BTSVTY);
254 f_vty_transceive(BTSVTY, "enable");
255}
256
Harald Weltef50e3ae2018-09-10 10:27:56 +0200257private function f_init_vty_bsc() runs on test_CT {
258 map(self:BSCVTY, system:BSCVTY);
259 f_vty_set_prompts(BSCVTY, "OsmoBSC");
260 f_vty_transceive(BSCVTY, "enable");
261}
262
Harald Welte883340c2018-02-28 18:59:29 +0100263/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200264private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
265 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100266 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200267 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
268 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100269 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200270 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Harald Welted378a252018-03-13 17:02:14 +0100271 setverdict(fail, "Invalid PCU Version/BTS Number received");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200272 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +0100273 }
274}
275
Harald Weltef26de0b2018-04-04 20:28:05 +0200276private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
277 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100278 timer T := 2.0;
279 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100280 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200281 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100282 return;
283 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200284 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100285
286 T.start;
287 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200288 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100289 [] T.timeout {
290 setverdict(fail, "Timeout waiting for PCU INFO_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200291 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +0100292 }
293 }
294}
295
Harald Welte70767382018-02-21 12:16:40 +0100296/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100297function f_init(charstring id := "BTS-Test") runs on test_CT {
Harald Welte83f6dbf2018-06-03 18:26:50 +0200298 timer T := 10.0;
Harald Welte629cc6b2018-03-11 17:19:05 +0100299 g_AllChannels := {
300 /* TS 1..4: TCH/F */
301 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
302 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
303 /* TS 5: TCH/H */
304 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
305 /* TS 0: SDCCH/4 */
306 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
307 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
308 /* TS 6: SDCCH/8 */
309 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
310 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
311 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
312 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
313 };
Harald Welte0472ab42018-03-12 15:02:26 +0100314 g_AllChanTypes := {
315 /* TS 1..4: TCH/F */
Vadim Yanitskiyb0970092018-07-27 02:40:43 +0700316 valueof(ts_RslChanNr_Bm(1)),
Harald Welte0472ab42018-03-12 15:02:26 +0100317 /* TS 5: TCH/H */
Vadim Yanitskiy7b8c5222018-09-16 16:55:48 +0700318 valueof(ts_RslChanNr_Lm(5,1)),
Harald Welte0472ab42018-03-12 15:02:26 +0100319 /* TS 0: SDCCH/4 */
320 valueof(ts_RslChanNr_SDCCH4(0,2)),
321 /* TS 6: SDCCH/8 */
322 valueof(ts_RslChanNr_SDCCH8(6,4))
323 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100324
Harald Welte70767382018-02-21 12:16:40 +0100325 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200326 T.start;
327 alt {
328 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
329 [] T.timeout {
330 setverdict(fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200331 mtc.stop;
Harald Welte83f6dbf2018-06-03 18:26:50 +0200332 }
333 }
Harald Welte2d142592018-02-25 13:19:44 +0100334 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100335 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200336 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100337
338 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100339 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
340 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
341 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
342 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100343
Harald Weltef26de0b2018-04-04 20:28:05 +0200344 map(self:PCU, system:PCU);
345 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100346
Harald Welte84271622018-03-10 17:21:03 +0100347 if (mp_bb_trxc_port != -1) {
348 var TrxcMessage ret;
349 /* start with a default moderate timing offset equalling TA=2 */
350 f_main_trxc_connect();
351 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
352 }
Harald Welte70767382018-02-21 12:16:40 +0100353}
354
Harald Welte294b0a22018-03-10 23:26:48 +0100355function f_shutdown() runs on test_CT {
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200356 /* mtc.stop cleanly stops testcase execution to avoid unclean shutdown */
Daniel Willmannb85a6292018-07-25 22:53:32 +0200357 all component.stop;
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200358 mtc.stop;
Harald Welte294b0a22018-03-10 23:26:48 +0100359}
360
Harald Welte68e495b2018-02-25 00:05:57 +0100361/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
362function f_init_l1ctl() runs on test_CT {
363 map(self:L1CTL, system:L1CTL);
364 f_connect_reset(L1CTL);
365}
366
Harald Welte70767382018-02-21 12:16:40 +0100367type function void_fn(charstring id) runs on ConnHdlr;
368
369/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200370function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100371runs on test_CT return ConnHdlr {
372 var charstring id := testcasename();
373 var ConnHdlr vc_conn;
374
375 vc_conn := ConnHdlr.create(id);
376 /* connect to RSL Emulation main component */
377 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
378 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200379 if (pcu_comp) {
380 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
381 * it from the test_CT and connect it to the component. This obviously only
382 * works for one component, i.e. no concurrency */
383 unmap(self:PCU, system:PCU);
384 map(vc_conn:PCU, system:PCU);
385 }
Harald Welte70767382018-02-21 12:16:40 +0100386
387 vc_conn.start(f_handler_init(fn, id, pars));
388 return vc_conn;
389}
390
Harald Welte7484fc42018-02-24 14:09:45 +0100391template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
392 streamId := sid,
393 rsl := rsl
394}
395
396template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
397 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
398 streamId := sid,
399 rsl := rsl
400}
401
Harald Welte70767382018-02-21 12:16:40 +0100402private altstep as_Tguard() runs on ConnHdlr {
403 [] g_Tguard.timeout {
404 setverdict(fail, "Tguard timeout");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200405 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100406 }
407}
408
Harald Welte68e495b2018-02-25 00:05:57 +0100409private function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200410 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100411}
412
413private function f_trxc_connect() runs on ConnHdlr {
414 map(self:BB_TRXC, system:BB_TRXC);
415 var Result res;
Harald Weltea4d8f352018-03-01 15:47:20 +0100416 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
417 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200418 if (not ispresent(res.connId)) {
419 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200420 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200421 }
Harald Welte70767382018-02-21 12:16:40 +0100422 g_bb_trxc_conn_id := res.connId;
423}
424
425private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100426 var TrxcMessage ret;
427 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100428}
429
430private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100431 var TrxcMessage ret;
432 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100433}
434
435/* first function started in ConnHdlr component */
436private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
437runs on ConnHdlr {
438 g_pars := pars;
439 g_chan_nr := pars.chan_nr;
440
441 map(self:L1CTL, system:L1CTL);
442 f_connect_reset(L1CTL);
443
Harald Welte84271622018-03-10 17:21:03 +0100444 if (mp_bb_trxc_port != -1) {
445 f_trxc_connect();
446 }
Harald Welte70767382018-02-21 12:16:40 +0100447
448 g_Tguard.start(pars.t_guard);
449 activate(as_Tguard());
450
451 f_rslem_register(0, pars.chan_nr);
452
453 /* call the user-supplied test case function */
454 fn.apply(id);
455}
456
Harald Welteb1726c92018-03-30 11:56:38 +0200457function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
458 boolean ignore_other := false)
459runs on ConnHdlr return RSL_Message {
460 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100461 timer T := 3.0;
462 RSL.send(tx);
463 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100464 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200465 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100466 T.stop;
467 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100468 }
Harald Welte1eba3742018-02-25 12:48:14 +0100469 [] T.timeout {
470 setverdict(fail, "Timeout expecting " & id);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200471 mtc.stop;
Harald Welte1eba3742018-02-25 12:48:14 +0100472 }
Harald Welte21240e62018-03-11 21:43:35 +0100473 [not ignore_other] as_l1_sacch();
474 [not ignore_other] as_meas_res();
475 [not ignore_other] as_l1_dcch();
476 [not ignore_other] RSL.receive {
Harald Welte1eba3742018-02-25 12:48:14 +0100477 setverdict(fail, "Unexpected RSL message received");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200478 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100479 }
Harald Welte21240e62018-03-11 21:43:35 +0100480 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100481 }
Harald Welteb1726c92018-03-30 11:56:38 +0200482 return rx;
483}
484
485function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
486 boolean ignore_other := false)
487runs on ConnHdlr {
488 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100489}
490
Harald Weltee613f962018-04-18 22:38:16 +0200491function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false)
492runs on ConnHdlr {
493 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode));
494 if (encr_enable) {
495 /* append encryption related IEs, if requested */
496 var RSL_IE_EncryptionInfo encr_info;
497 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
498 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
499encr_info})) };
500 }
501 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100502}
503
Harald Welte70767382018-02-21 12:16:40 +0100504function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100505 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 +0100506 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100507}
508
Harald Welte70767382018-02-21 12:16:40 +0100509private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
510 template RSL_IE_ChannelMode chan_mode,
511 float t_guard := 20.0) := {
512 chan_nr := valueof(chan_nr),
513 chan_mode := valueof(chan_mode),
514 t_guard := t_guard,
515 l1_pars := {
516 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100517 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100518 meas_ul := {
519 full := {
520 rxlev := dbm2rxlev(-53),
521 rxqual := 0
522 },
523 sub := {
524 rxlev := dbm2rxlev(-53),
525 rxqual := 0
526 }
527 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200528 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100529 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200530 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200531 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100532 },
Harald Weltee613f962018-04-18 22:38:16 +0200533 spec := omit,
534 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100535}
536
Harald Welte93640c62018-02-25 16:59:33 +0100537/***********************************************************************
538 * Channel Activation / Deactivation
539 ***********************************************************************/
540
Harald Welte70767382018-02-21 12:16:40 +0100541/* Stress test: Do 500 channel activations/deactivations in rapid succession */
542function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
543 for (var integer i := 0; i < 500; i := i+1) {
544 f_rsl_chan_act(g_pars.chan_mode);
545 f_rsl_chan_deact();
546 }
547 setverdict(pass);
548}
549testcase TC_chan_act_stress() runs on test_CT {
550 var ConnHdlr vc_conn;
551 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
552 f_init(testcasename());
553 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
554 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100555 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100556}
557
558/* Test if re-activation of an already active channel fails as expected */
559function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
560 f_rsl_chan_act(g_pars.chan_mode);
561 /* attempt to activate the same lchan again -> expect reject */
562 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
563 alt {
564 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
565 setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200566 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100567 }
568 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
569 setverdict(pass);
570 }
571 }
572 f_rsl_chan_deact();
573}
574testcase TC_chan_act_react() runs on test_CT {
575 var ConnHdlr vc_conn;
576 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100577 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100578 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
579 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100580 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100581}
582
583/* Attempt to de-activate a channel that's not active */
584function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
585 timer T := 3.0;
586 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
587 T.start;
588 alt {
589 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
590 setverdict(pass);
591 }
592 [] T.timeout {
593 setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200594 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100595 }
596 }
597}
598testcase TC_chan_deact_not_active() runs on test_CT {
599 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100600 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100601 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
602 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100603 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100604}
605
606/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
607function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
608 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
609 alt {
610 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
611 setverdict(fail, "Unexpected CHAN ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200612 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100613 }
614 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
615 setverdict(pass);
616 }
617 }
618}
619private type record WrongChanNrCase {
620 RslChannelNr chan_nr,
621 charstring description
622}
623private type record of WrongChanNrCase WrongChanNrCases;
624private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
625 chan_nr := chan_nr,
626 description := desc
627}
628
629testcase TC_chan_act_wrong_nr() runs on test_CT {
630 var ConnHdlr vc_conn;
631 var ConnHdlrPars pars;
632
Harald Welte294b0a22018-03-10 23:26:48 +0100633 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100634
635 var WrongChanNrCases wrong := {
636 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
637 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
638 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
639 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
640 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
641 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
642 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
643 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
644 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
645 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
646 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
647 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
648 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
649 };
650
651 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
652 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
653 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
654 vc_conn.done;
655 }
Harald Welte294b0a22018-03-10 23:26:48 +0100656 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100657}
658
Harald Weltee613f962018-04-18 22:38:16 +0200659/* execute the same callback function on a variety of logical channels */
660private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
661 var ConnHdlr vc_conn;
662 f_init(testcasename());
663
664 /* test on each of the channels we have */
665 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
666 pars.chan_nr := valueof(g_AllChanTypes[i]);
667
668 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
669 vc_conn := f_start_handler(fn, pars);
670 vc_conn.done;
671 }
672
673 f_shutdown();
674}
675
Harald Welte93640c62018-02-25 16:59:33 +0100676/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100677 * SACCH handling
678 ***********************************************************************/
679
680private function f_exp_sacch(boolean exp) runs on ConnHdlr {
681 timer T_sacch := 3.0;
682 T_sacch.start;
683 alt {
684 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
685 setverdict(fail, "Received SACCH when not expecting it");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200686 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100687 }
688 [not exp] T_sacch.timeout {
689 setverdict(pass);
690 }
691 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
692 setverdict(pass);
693 }
694 [exp] T_sacch.timeout {
695 setverdict(fail, "Timeout waiting for SACCH on ", g_chan_nr);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200696 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100697 }
698 [] L1CTL.receive { repeat; }
699 [] RSL.receive { repeat; }
700 }
701}
702
703/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
704private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
705 f_l1_tune(L1CTL);
706 RSL.clear;
707
708 /* activate the logical channel */
709 f_est_dchan();
710 L1CTL.clear;
711
712 /* check that SACCH actually are received as expected */
713 f_exp_sacch(true);
714
715 /* deactivate SACCH on the logical channel */
716 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
717 f_sleep(1.0);
718 L1CTL.clear;
719
720 /* check that no SACCH are received anymore */
721 f_exp_sacch(false);
722
723 /* release the channel */
724 f_rsl_chan_deact();
725 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
726}
727testcase TC_deact_sacch() runs on test_CT {
728 var ConnHdlr vc_conn;
729 var ConnHdlrPars pars;
730 f_init();
731 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
732 //for (var integer i := 0; i < 1; i := i+1) {
733 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
734 log(testcasename(), ": Starting for ", g_AllChannels[i]);
735 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
736 vc_conn.done;
737 }
738 /* TODO: do the above in parallel, rather than sequentially? */
739 f_shutdown();
740}
741
Harald Welte55700662018-03-12 13:15:43 +0100742/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100743private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
744 var L1ctlDlMessage dl;
745 /* check that the specified SI5 value is actually sent */
746 timer T_sacch := 3.0;
747 L1CTL.clear;
748 T_sacch.start;
749 alt {
750 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
751 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
752 if (match(l3, l3_exp)) {
753 setverdict(pass);
754 } else {
755 repeat;
756 }
757 }
758 [] L1CTL.receive { repeat; }
759 [] T_sacch.timeout {
760 setverdict(fail, "Timeout waiting for SACCH ", l3_exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200761 mtc.stop;
Harald Welteea17b912018-03-11 22:29:31 +0100762 }
763 }
764}
765
Harald Welte55700662018-03-12 13:15:43 +0100766/* verify that given SACCH payload is not present */
767private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
768 var L1ctlDlMessage dl;
769 /* check that the specified SI5 value is actually sent */
770 timer T_sacch := 3.0;
771 L1CTL.clear;
772 T_sacch.start;
773 alt {
774 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
775 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
776 if (match(l3, l3_exp)) {
777 setverdict(fail, "Received unexpected SACCH ", dl);
Daniel Willmann3487a852018-07-05 15:41:59 +0200778 mtc.stop;
Harald Welte55700662018-03-12 13:15:43 +0100779 } else {
780 repeat;
781 }
782 }
783 [] L1CTL.receive { repeat; }
784 [] T_sacch.timeout {
785 setverdict(pass);
786 }
787 }
788}
789
Harald Welte629cc6b2018-03-11 17:19:05 +0100790/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100791private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
792 /* Set a known default SACCH filling for SI5 */
793 var octetstring si5 := f_rnd_octstring(19);
794 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
795
796 f_l1_tune(L1CTL);
797 RSL.clear;
798
799 /* activate the logical channel */
800 f_est_dchan();
801
802 /* check that the specified SI5 value is actually sent */
803 f_sacch_present(si5);
804
805 /* release the channel */
806 RSL.clear;
807 f_rsl_chan_deact();
808 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
809}
810testcase TC_sacch_filling() runs on test_CT {
811 var ConnHdlr vc_conn;
812 var ConnHdlrPars pars;
813 f_init();
814 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
815 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
816 log(testcasename(), ": Starting for ", g_AllChannels[i]);
817 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
818 vc_conn.done;
819 }
820 /* TODO: do the above in parallel, rather than sequentially? */
821 f_shutdown();
822}
823
Harald Welte629cc6b2018-03-11 17:19:05 +0100824/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100825private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
826 /* Set a known default SACCH filling for SI5 */
827 var octetstring si5 := f_rnd_octstring(19);
828 var octetstring si5_diff := f_rnd_octstring(19);
829 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
830
831 f_l1_tune(L1CTL);
832 RSL.clear;
833
834 log("Activating channel, expecting standard SI5");
835 /* activate the logical channel */
836 f_est_dchan();
837 /* check that the specified SI5 value is actually sent */
838 f_sacch_present(si5);
839
840 /* set channel-specific different SI5 */
841 log("Setting channel specific SACCH INFO, expecting it");
842 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
843 /* check that the specified lchan-specific value is now used */
844 f_sacch_present(si5_diff);
845
846 /* deactivate the channel and re-activate it, this should result in default SI5 */
847 log("De-activating and re-activating channel, expecting standard SI5");
848 f_rsl_chan_deact();
849 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
850 /* Verify that the TRX-wide default SACCH filling is present again */
851 f_sacch_present(si5);
852
853 /* release the channel */
854 RSL.clear;
855 f_rsl_chan_deact();
856 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
857}
858testcase TC_sacch_info_mod() runs on test_CT {
859 var ConnHdlr vc_conn;
860 var ConnHdlrPars pars;
861 f_init();
862 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
863 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
864 log(testcasename(), ": Starting for ", g_AllChannels[i]);
865 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
866 vc_conn.done;
867 }
868 /* TODO: do the above in parallel, rather than sequentially? */
869 f_shutdown();
870}
871
Harald Welte075d84c2018-03-12 13:07:24 +0100872/* Test SACCH scheduling of multiple different SI message types */
873private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
874 var octetstring si5 := f_rnd_octstring(19);
875 var octetstring si5bis := f_rnd_octstring(19);
876 var octetstring si5ter := f_rnd_octstring(19);
877 var octetstring si6 := f_rnd_octstring(19);
878
879 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
880 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
881 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
882 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
883
884 f_l1_tune(L1CTL);
885 RSL.clear;
886
887 /* activate the logical channel */
888 f_est_dchan();
889 L1CTL.clear;
890
891 /* check that SACCH actually are received as expected */
892 f_sacch_present(si5);
893 f_sacch_present(si5bis);
894 f_sacch_present(si5ter);
895 f_sacch_present(si6);
896
897 /* release the channel */
898 f_rsl_chan_deact();
899 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
900}
901testcase TC_sacch_multi() runs on test_CT {
902 var ConnHdlr vc_conn;
903 var ConnHdlrPars pars;
904 f_init();
905 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
906 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
907 log(testcasename(), ": Starting for ", g_AllChannels[i]);
908 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
909 vc_conn.done;
910 }
911 /* TODO: do the above in parallel, rather than sequentially? */
912 f_shutdown();
913}
914
Harald Welte55700662018-03-12 13:15:43 +0100915/* Test if SACH information is modified as expected */
916private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
917 var octetstring si5 := f_rnd_octstring(19);
918 var octetstring si6 := f_rnd_octstring(19);
919
920 /* First, configure both SI5 and SI6 to be transmitted */
921 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
922 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
923
924 f_l1_tune(L1CTL);
925 RSL.clear;
926
927 /* activate the logical channel */
928 f_est_dchan();
929 L1CTL.clear;
930
931 /* check that SACCH actually are received as expected */
932 f_sacch_present(si5);
933 f_sacch_present(si6);
934
935 /* disable SI6 */
936 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
937
938 /* check that SI5 is still transmitted */
939 f_sacch_present(si5);
940 /* check if SI6 is now gone */
941 f_sacch_missing(si6);
942
943 /* release the channel */
944 f_rsl_chan_deact();
945 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
946}
947testcase TC_sacch_multi_chg() runs on test_CT {
948 var ConnHdlr vc_conn;
949 var ConnHdlrPars pars;
950 f_init();
951 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
952 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
953 log(testcasename(), ": Starting for ", g_AllChannels[i]);
954 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
955 vc_conn.done;
956 }
957 /* TODO: do the above in parallel, rather than sequentially? */
958 f_shutdown();
959}
960
Harald Welte075d84c2018-03-12 13:07:24 +0100961/* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
962/* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
Harald Welte629cc6b2018-03-11 17:19:05 +0100963
964
965/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100966 * RACH Handling
967 ***********************************************************************/
968
Harald Welte8c24c2b2018-02-26 08:31:31 +0100969/* like L1SAP_IS_PACKET_RACH */
970private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100971 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100972 return true;
973 }
974 return false;
975}
976
977/* generate a random RACH for circuit-switched */
978private function f_rnd_ra_cs() return OCT1 {
979 var OCT1 ra;
980 do {
981 ra := f_rnd_octstring(1);
982 } while (ra_is_ps(ra));
983 return ra;
984}
985
Harald Welte883340c2018-02-28 18:59:29 +0100986/* generate a random RACH for packet-switched */
987private function f_rnd_ra_ps() return OCT1 {
988 var OCT1 ra;
989 do {
990 ra := f_rnd_octstring(1);
991 } while (not ra_is_ps(ra));
992 return ra;
993}
994
Harald Welte8c24c2b2018-02-26 08:31:31 +0100995/* Send 1000 RACH requests and check their RA+FN on the RSL side */
996testcase TC_rach_content() runs on test_CT {
997 f_init(testcasename());
998 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +0100999 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001000
Harald Welte8c24c2b2018-02-26 08:31:31 +01001001 var GsmFrameNumber fn_last := 0;
1002 for (var integer i := 0; i < 1000; i := i+1) {
1003 var OCT1 ra := f_rnd_ra_cs();
1004 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1005 if (fn == fn_last) {
1006 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001007 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001008 }
1009 fn_last := fn;
1010
1011 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001012 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001013 alt {
1014 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1015 T.stop;
1016 }
1017 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
1018 setverdict(fail, "Unexpected CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001019 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001020 }
1021 [] RSL_CCHAN.receive { repeat; }
1022 [] T.timeout {
1023 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001024 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001025 }
1026 }
1027 }
1028 setverdict(pass);
Harald Welte294b0a22018-03-10 23:26:48 +01001029 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001030}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001031
1032/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1033testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001034 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001035 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001036 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001037 f_l1_tune(L1CTL);
1038
1039 var GsmFrameNumber fn_last := 0;
1040 for (var integer i := 0; i < 1000; i := i+1) {
1041 var OCT1 ra := f_rnd_ra_cs();
1042 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1043 if (fn == fn_last) {
1044 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001045 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001046 }
1047 fn_last := fn;
1048 }
1049 var integer rsl_chrqd := 0;
1050 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001051 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001052 alt {
1053 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1054 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001055 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001056 repeat;
1057 }
1058 [] RSL_CCHAN.receive { repeat; }
1059 [] T.timeout { }
1060 }
1061 if (rsl_chrqd == 1000) {
1062 setverdict(pass);
1063 } else {
1064 setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH");
1065 }
Harald Welte294b0a22018-03-10 23:26:48 +01001066 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001067}
1068
Harald Welte54a2a2d2018-02-26 09:14:05 +01001069private function f_main_trxc_connect() runs on test_CT {
1070 map(self:BB_TRXC, system:BB_TRXC);
1071 var Result res;
Harald Welted3a88a62018-03-01 16:04:52 +01001072 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
1073 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001074 if (not ispresent(res.connId)) {
1075 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001076 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +02001077 }
Harald Welte54a2a2d2018-02-26 09:14:05 +01001078 g_bb_trxc_conn_id := res.connId;
1079}
1080
1081private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001082 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001083 /* tell fake_trx to use a given timing offset for all bursts */
Harald Weltef8df4cb2018-03-10 15:15:08 +01001084 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001085 f_sleep(0.5);
1086
1087 /* Transmit RACH request + wait for confirmation */
1088 var OCT1 ra := f_rnd_ra_cs();
1089 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1090
1091 /* Check for expected result */
1092 timer T := 1.5;
1093 T.start;
1094 alt {
1095 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1096 setverdict(pass);
1097 }
1098 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welteb3e30942018-03-02 10:33:42 +01001099 setverdict(fail, "RACH passed but was expected to be dropped: ", toffs256);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001100 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001101 }
1102 [] RSL_CCHAN.receive { repeat; }
1103 [not expect_pass] T.timeout {
1104 setverdict(pass);
1105 }
1106 [expect_pass] T.timeout {
1107 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001108 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001109 }
1110 }
1111}
1112
1113/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1114testcase TC_rach_max_ta() runs on test_CT {
1115 f_init(testcasename());
1116 f_init_l1ctl();
1117 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001118 f_sleep(1.0);
1119
1120 /* default max-ta is 63 (full range of GSM timing advance */
1121
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001122 /* We allow early arrival up to 2 symbols */
1123 f_rach_toffs(-1*256, true);
1124 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001125 f_rach_toffs(-10*256, false);
1126
1127 /* 0 / 32 / 63 bits is legal / permitted */
1128 f_rach_toffs(0, true);
1129 f_rach_toffs(32*256, true);
1130 f_rach_toffs(63*256, true);
1131
1132 /* more than 63 bits is not legal / permitted */
1133 f_rach_toffs(64*256, false);
1134 f_rach_toffs(127*256, false);
Harald Welte294b0a22018-03-10 23:26:48 +01001135 f_shutdown();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001136}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001137
Harald Welte93640c62018-02-25 16:59:33 +01001138/***********************************************************************
1139 * Measurement Processing / Reporting
1140 ***********************************************************************/
1141
Harald Welte70767382018-02-21 12:16:40 +01001142template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1143 spare := '0'B,
1144 lpd := 0,
1145 sapi := sapi,
1146 c_r := c_r,
1147 ea := true
1148}
1149
Harald Welted879bd92018-03-12 15:01:23 +01001150template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001151 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001152 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001153 len := 0, /* overwritten */
1154 m := false,
1155 el := 1,
1156 payload := pl
1157}
1158
1159/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1160altstep as_l1_sacch() runs on ConnHdlr {
1161 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001162 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001163 log("SACCH received: ", l1_dl.payload.data_ind.payload);
1164 var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit));
Harald Welted879bd92018-03-12 15:01:23 +01001165 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001166 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001167
1168 var L1ctlDataReq data_req := {
1169 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1170 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1171 }
1172 log("Sending Measurement Report: ", data_req);
1173 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001174 repeat;
1175 }
1176}
1177
1178altstep as_l1_dcch() runs on ConnHdlr {
1179 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001180 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001181 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1182 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001183 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1184 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001185 repeat;
1186 }
1187}
1188
1189type record MeasElem {
1190 uint6_t rxlev,
1191 uint3_t rxqual
1192}
1193
1194type record MeasElemFS {
1195 MeasElem full,
1196 MeasElem sub
1197}
1198
1199type record ConnL1Pars {
1200 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001201 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001202 MeasElemFS meas_ul,
1203 int16_t timing_offset_256syms,
1204 uint5_t bs_power_level,
1205 uint5_t ms_power_level,
1206 uint8_t ms_actual_ta
1207}
1208
1209/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1210private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1211 return 63 + (toffs256s/256);
1212}
1213
Harald Welted5684392018-03-10 18:22:04 +01001214private function f_max(integer a, integer b) return integer {
1215 if (a > b) {
1216 return a;
1217 } else {
1218 return b;
1219 }
1220}
1221
1222private function f_min(integer a, integer b) return integer {
1223 if (a < b) {
1224 return a;
1225 } else {
1226 return b;
1227 }
1228}
1229
1230/* compute negative tolerance val-tolerance, ensure >= min */
1231private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1232 val := val - tolerance;
1233 return f_max(val, min);
1234}
1235
1236/* compute positive tolerance val+tolerance, ensure <= max */
1237private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1238 val := val + tolerance;
1239 return f_min(val, max);
1240}
1241
1242/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1243private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1244return template integer {
1245 var template integer ret;
1246 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1247 return ret;
1248}
1249
1250
Harald Welte70767382018-02-21 12:16:40 +01001251/* build a template for matching measurement results against */
1252private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1253 var ConnL1Pars l1p := g_pars.l1_pars;
1254 var template RSL_IE_UplinkMeas ul_meas := {
1255 len := 3,
1256 rfu := '0'B,
1257 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001258 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001259 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001260 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001261 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001262 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1263 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001264 supp_meas_info := omit
1265 };
Harald Welte685d5982018-02-27 20:42:05 +01001266 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001267 ul_meas.len := (3+8);
1268 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001269 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001270 toa256_min := ?,
1271 toa256_max := ?,
1272 toa256_std_dev := ?
1273 }
Harald Welte685d5982018-02-27 20:42:05 +01001274 }
Harald Welte70767382018-02-21 12:16:40 +01001275 /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */
1276 ul_meas.rxlev_f_u := ?;
1277 ul_meas.rxlev_s_u := ?;
1278 ul_meas.rxq_f_u := ?;
1279 ul_meas.rxq_s_u := ?;
1280 var template RSL_IE_BS_Power bs_power := {
1281 reserved := 0,
1282 epc := false,
1283 fpc := false,
1284 power_level := l1p.bs_power_level
1285 };
1286 var template RSL_IE_L1Info l1_info := {
1287 ms_power_lvl := l1p.ms_power_level,
1288 fpc := false,
1289 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001290 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001291 };
1292 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001293 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001294 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1295 ?, t_toffs);
1296}
1297
1298/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001299altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001300 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001301 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001302 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1303 /* increment counter of next to-be-expected meas rep */
1304 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1305 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001306 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001307 repeat;
1308 }
1309 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001310 /* increment counter of next to-be-expected meas rep */
1311 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1312 if (g_first_meas_res) {
1313 g_first_meas_res := false;
1314 repeat;
1315 } else {
1316 setverdict(fail, "Received unspecific MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001317 mtc.stop;
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 {
1321 setverdict(fail, "Received unexpected MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001322 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001323 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001324 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Harald Welte70767382018-02-21 12:16:40 +01001325 setverdict(fail, "Didn't receive expected measurement result")
Daniel Willmann17ddd852018-07-05 17:33:20 +02001326 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001327 }
1328}
1329
Harald Weltee613f962018-04-18 22:38:16 +02001330private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1331 select (rsl_alg_id) {
1332 case (RSL_ALG_ID_A5_0) { return 0; }
1333 case (RSL_ALG_ID_A5_1) { return 1; }
1334 case (RSL_ALG_ID_A5_2) { return 2; }
1335 case (RSL_ALG_ID_A5_3) { return 3; }
1336 case (RSL_ALG_ID_A5_4) { return 4; }
1337 case (RSL_ALG_ID_A5_5) { return 5; }
1338 case (RSL_ALG_ID_A5_6) { return 6; }
1339 case (RSL_ALG_ID_A5_7) { return 7; }
1340 case else {
1341 setverdict(fail, "Unknwon Algorithm ID");
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 {
1357 setverdict(fail, "Unknwon Algorithm ID");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001358 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001359 }
1360 }
1361}
1362
1363
Harald Welte70767382018-02-21 12:16:40 +01001364/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltee613f962018-04-18 22:38:16 +02001365private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001366 var GsmFrameNumber fn;
1367 var ImmediateAssignment imm_ass;
1368 var integer ra := 23;
1369
Pau Espin Pedrol99a7aca2018-09-28 16:10:32 +02001370 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
Harald Welte70767382018-02-21 12:16:40 +01001371 fn := f_L1CTL_RACH(L1CTL, ra);
1372 /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
1373 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
1374
1375 /* Activate channel on BTS side */
Harald Weltee613f962018-04-18 22:38:16 +02001376 f_rsl_chan_act(g_pars.chan_mode, encr_enable);
Harald Welte70767382018-02-21 12:16:40 +01001377
1378 /* Send IMM.ASS via CCHAN */
1379 var ChannelDescription ch_desc := {
1380 chan_nr := g_pars.chan_nr,
1381 tsc := 7,
1382 h := false,
1383 arfcn := mp_trx0_arfcn,
1384 maio_hsn := omit
1385 };
1386 var MobileAllocation ma := {
1387 len := 0,
1388 ma := ''B
1389 };
1390 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1391 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1392
1393 /* receive IMM.ASS on MS side */
1394 var ImmediateAssignment ia_um;
1395 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1396 /* enable dedicated mode */
1397 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001398 /* enable encryption, if requested */
1399 if (encr_enable) {
1400 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1401 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1402 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001403
1404 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001405}
1406
1407/* establish DChan, verify existance + contents of measurement reports */
1408function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001409 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001410 RSL.clear;
1411
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001412 g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100);
Harald Welte5398d5e2018-03-10 19:00:24 +01001413 g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001414 if (mp_bb_trxc_port != -1) {
1415 f_trxc_fake_rssi(100);
1416 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1417 }
Harald Welte70767382018-02-21 12:16:40 +01001418
1419 f_est_dchan();
1420
1421 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1422 * RSL measurement reports on Abis side */
1423 timer T := 8.0;
1424 T.start;
1425 alt {
1426 [] as_l1_sacch();
1427 [] as_meas_res();
1428 [] as_l1_dcch();
1429 [] L1CTL.receive { repeat; }
1430 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann17ddd852018-07-05 17:33:20 +02001431 /* as_meas_res() would have done setverdict(fail) / mtc.stop in case
Harald Welte70767382018-02-21 12:16:40 +01001432 * of any earlier errors, so if we reach this timeout, we're good */
1433 setverdict(pass);
1434 }
1435 [] T.timeout {
1436 setverdict(fail, "No MEAS RES received at all");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001437 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001438 }
1439 }
1440 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001441 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001442}
Harald Welte0472ab42018-03-12 15:02:26 +01001443
Harald Welte70767382018-02-21 12:16:40 +01001444testcase TC_meas_res_sign_tchf() runs on test_CT {
1445 var ConnHdlr vc_conn;
1446 var ConnHdlrPars pars;
1447 f_init(testcasename());
1448 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1449 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1450 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1451 vc_conn.done;
1452 }
Harald Welte294b0a22018-03-10 23:26:48 +01001453 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001454}
1455testcase TC_meas_res_sign_tchh() runs on test_CT {
1456 var ConnHdlr vc_conn;
1457 var ConnHdlrPars pars;
1458 f_init(testcasename());
1459 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1460 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1461 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1462 vc_conn.done;
1463 }
Harald Welte294b0a22018-03-10 23:26:48 +01001464 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001465}
1466testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1467 var ConnHdlr vc_conn;
1468 var ConnHdlrPars pars;
1469 f_init(testcasename());
1470 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1471 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1472 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1473 vc_conn.done;
1474 }
Harald Welte294b0a22018-03-10 23:26:48 +01001475 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001476}
1477testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1478 var ConnHdlr vc_conn;
1479 var ConnHdlrPars pars;
1480 f_init(testcasename());
1481 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1482 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1483 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1484 vc_conn.done;
1485 }
Harald Welte294b0a22018-03-10 23:26:48 +01001486 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001487}
Harald Welte685d5982018-02-27 20:42:05 +01001488testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1489 var ConnHdlr vc_conn;
1490 var ConnHdlrPars pars;
1491 f_init(testcasename());
1492 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1493 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1494 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1495 pars.l1_pars.toa256_enabled := true;
1496 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1497 vc_conn.done;
1498 }
Harald Welte294b0a22018-03-10 23:26:48 +01001499 f_shutdown();
Harald Welte685d5982018-02-27 20:42:05 +01001500}
1501
Harald Welte70767382018-02-21 12:16:40 +01001502
Harald Welte0472ab42018-03-12 15:02:26 +01001503/* 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 +01001504private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001505 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001506 RSL.clear;
1507
1508 f_est_dchan();
1509 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001510 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001511
1512 timer T := 40.0;
1513 T.start;
1514 alt {
1515 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1516 setverdict(pass)
1517 }
1518 [] RSL.receive { repeat };
1519 [] T.timeout {
1520 setverdict(fail, "No CONN FAIL IND received");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001521 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001522 }
1523 }
1524 f_rsl_chan_deact();
1525}
1526testcase TC_conn_fail_crit() runs on test_CT {
1527 var ConnHdlr vc_conn;
1528 var ConnHdlrPars pars;
1529 f_init(testcasename());
1530 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1531 pars.t_guard := 60.0;
1532 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1533 vc_conn.done;
1534}
1535
Harald Welte93640c62018-02-25 16:59:33 +01001536/***********************************************************************
1537 * Paging
1538 ***********************************************************************/
1539
Harald Welte68e495b2018-02-25 00:05:57 +01001540function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1541 if (tmsi == 'FFFFFFFF'O) {
1542 return true;
1543 } else {
1544 return false;
1545 }
1546}
Harald Welte70767382018-02-21 12:16:40 +01001547
Philipp Maier82cb0b12018-08-31 14:41:39 +02001548type record allowedFn { integer frame_nr }
1549template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
1550template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
1551template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
1552template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
1553template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
1554template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
1555template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
1556template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
1557function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
1558{
1559 var integer frame_nr_51;
1560 frame_nr_51 := frame_nr mod 51
1561
1562 var allowedFn fn_check;
1563 fn_check.frame_nr := frame_nr_51;
1564
1565 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
1566 setverdict(fail, "bs_ag_blks_res out of valid range (0..7)");
1567 mtc.stop;
1568 return;
1569 }
1570
1571 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
1572 return;
1573 }
1574 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
1575 return;
1576 }
1577 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
1578 return;
1579 }
1580 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
1581 return;
1582 }
1583 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
1584 return;
1585 }
1586 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
1587 return;
1588 }
1589 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
1590 return;
1591 }
1592 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
1593 return;
1594 }
1595
1596 setverdict(fail, "received paging on AGCH");
1597 mtc.stop;
1598 return;
1599}
1600
1601altstep 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 +01001602runs on test_CT {
1603 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001604 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001605 repeat;
1606 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001607 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001608 var octetstring without_plen :=
1609 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1610 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02001611
1612 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
1613
Harald Welte68e495b2018-02-25 00:05:57 +01001614 if (match(rr, tr_PAGING_REQ1)) {
1615 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1616 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1617 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1618 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1619 }
1620 } else if (match(rr, tr_PAGING_REQ2)) {
1621 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1622 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1623 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1624 }
1625 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1626 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1627 }
1628 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1629 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1630 }
1631 } else if (match(rr, tr_PAGING_REQ3)) {
1632 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1633 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1634 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1635 }
1636 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1637 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1638 }
1639 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1640 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1641 }
1642 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1643 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1644 }
1645 }
1646 repeat;
1647 }
1648}
1649
1650type record PagingTestCfg {
1651 boolean combined_ccch,
1652 integer bs_ag_blks_res,
1653 float load_factor,
1654 boolean exp_load_ind,
1655 boolean exp_overload,
1656 boolean use_tmsi
1657}
1658
1659type record PagingTestState {
1660 integer num_paging_sent,
1661 integer num_paging_rcv_msgs,
1662 integer num_paging_rcv_ids,
1663 integer num_overload
1664}
1665
1666/* receive + ignore RSL RF RES IND */
1667altstep as_rsl_res_ind() runs on test_CT {
1668 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1669 repeat;
1670 }
1671}
1672
1673/* Helper function for paging related testing */
1674private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1675 f_init(testcasename());
1676 f_init_l1ctl();
1677 f_l1_tune(L1CTL);
1678
1679 var PagingTestState st := {
1680 num_paging_sent := 0,
1681 num_paging_rcv_msgs := 0,
1682 num_paging_rcv_ids := 0,
1683 num_overload := 0
1684 };
1685
1686 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1687 var float max_pch_imsi_per_sec;
1688 if (cfg.use_tmsi) {
1689 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1690 } else {
1691 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1692 }
1693 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1694 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001695 var float time_total := 20.0;
1696 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
1697 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01001698
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001699 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
1700 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01001701
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001702 timer T_itv := 0.0;
1703 T_itv.start;
1704 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01001705 alt {
1706 /* check for presence of CCCH LOAD IND (paging load) */
1707 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1708 st.num_overload := st.num_overload + 1;
1709 repeat;
1710 }
1711 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1712 setverdict(fail, "Unexpected PCH Overload");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001713 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001714 }
1715 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1716 log("Rx LOAD_IND");
1717 /* FIXME: analyze/verify interval + contents */
1718 repeat;
1719 }
1720 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02001721 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001722 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001723 [] T_itv.timeout {
1724 /* Send paging cmds based on elapsed time */
1725 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
1726 while (st.num_paging_sent < new_sent) {
1727 /* build mobile Identity */
1728 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1729 if (cfg.use_tmsi) {
1730 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1731 } else {
1732 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
1733 }
1734 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1735 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1736
1737 /* Send RSL PAGING COMMAND */
1738 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
1739
1740 st.num_paging_sent := st.num_paging_sent + 1;
1741 }
1742 if (st.num_paging_sent < pkt_total) {
1743 /* Wait for interval to next PAGING COMMAND */
1744 var float time_now := T_total.read;
1745 var float next_sched := int2float(st.num_paging_sent)*interval;
1746 if (next_sched > time_now) {
1747 T_itv.start(next_sched - time_now);
1748 } else {
1749 T_itv.start(0.0);
1750 }
1751 } else {
1752 /* We are done, no need to keep counting */
1753 T_total.stop;
1754 }
1755 }
1756 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01001757 [] as_rsl_res_ind();
1758 }
1759 }
1760
1761 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1762 timer T_wait := 18.0;
1763 T_wait.start;
1764 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02001765 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001766 [] L1CTL.receive { repeat; }
1767 /* 65535 == empty paging queue, we can terminate*/
1768 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1769 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1770 [] T_wait.timeout {
1771 setverdict(fail, "Waiting for empty paging queue");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001772 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001773 }
1774 [] as_rsl_res_ind();
1775 }
1776
1777 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1778 " rcvd_ids=", st.num_paging_rcv_ids);
1779 return st;
1780}
1781
1782/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1783 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1784 * - that CCCH LOAD IND (PCH) are being generated
1785 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1786testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001787 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001788 var PagingTestCfg cfg := {
1789 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001790 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001791 load_factor := 0.8,
1792 exp_load_ind := true,
1793 exp_overload := false,
1794 use_tmsi := false
1795 };
1796 var PagingTestState st := f_TC_paging(cfg);
1797 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1798 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1799 st.num_paging_rcv_ids);
1800 } else {
1801 setverdict(pass);
1802 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001803 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001804}
1805
1806/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1807 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1808 * - that CCCH LOAD IND (PCH) are being generated
1809 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1810testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001811 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001812 var PagingTestCfg cfg := {
1813 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001814 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001815 load_factor := 0.8,
1816 exp_load_ind := true,
1817 exp_overload := false,
1818 use_tmsi := true
1819 };
1820 var PagingTestState st := f_TC_paging(cfg);
1821 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1822 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1823 st.num_paging_rcv_ids);
1824 } else {
1825 setverdict(pass);
1826 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001827 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001828}
1829
1830/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1831 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1832 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1833 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1834testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001835 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001836 var PagingTestCfg cfg := {
1837 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001838 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001839 load_factor := 2.0,
1840 exp_load_ind := true,
1841 exp_overload := true,
1842 use_tmsi := false
1843 };
1844 var PagingTestState st := f_TC_paging(cfg);
1845 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1846 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001847 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001848 if (not match(st.num_paging_rcv_ids, tpl)) {
1849 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1850 } else {
1851 setverdict(pass);
1852 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001853 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001854}
1855
1856/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1857 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1858 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1859 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1860testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001861 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001862 var PagingTestCfg cfg := {
1863 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001864 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001865 load_factor := 2.0,
1866 exp_load_ind := true,
1867 exp_overload := true,
1868 use_tmsi := true
1869 };
1870 var PagingTestState st := f_TC_paging(cfg);
1871 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1872 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001873 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001874 if (not match(st.num_paging_rcv_ids, tpl)) {
1875 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1876 } else {
1877 setverdict(pass);
1878 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001879 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001880}
1881
1882
Harald Welte93640c62018-02-25 16:59:33 +01001883/***********************************************************************
1884 * Immediate Assignment / AGCH
1885 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02001886const MobileAllocation c_MA_null := {
1887 len := 0,
1888 ma := ''B
1889}
Harald Welte93640c62018-02-25 16:59:33 +01001890
Harald Weltee8d750e2018-06-10 21:41:35 +02001891template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
1892 uint12_t arfcn := 871) := {
1893 chan_nr := chan_nr,
1894 tsc := tsc,
1895 h := false,
1896 arfcn := arfcn,
1897 maio_hsn := omit
1898}
1899
1900private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
1901 return int2str(num_tx) & " sent, "
1902 & int2str(num_rx) & " received, "
1903 & int2str(num_del) & " deleted";
1904}
1905
1906private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
1907 var L1ctlDlMessage l1_dl;
1908 timer T := 10.0;
1909 var integer num_tx := 0;
1910 var integer num_rx := 0;
1911 var integer num_del := 0;
1912 var charstring res_str;
1913 var float rx_ratio;
1914
Harald Welte68e495b2018-02-25 00:05:57 +01001915 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02001916 f_init_l1ctl();
1917 f_l1_tune(L1CTL);
1918
1919 for (var integer i := 0; i < num_total; i := i+1) {
1920 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
1921 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
1922 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01001923 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02001924 num_tx := num_tx+1;
1925 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01001926 }
1927 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02001928 T.start;
1929 alt {
1930 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
1931 num_del := num_del+1;
1932 repeat;
1933 }
1934 [] RSL_CCHAN.receive {
1935 repeat;
1936 }
1937 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
1938 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
1939 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
1940 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
1941 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
1942 //setverdict(fail, "Unexpected IMM-ASS values on AGCH: ", rr);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001943 //mtc.stop;
Harald Weltee8d750e2018-06-10 21:41:35 +02001944 } else {
1945 num_rx := num_rx+1;
1946 }
1947 repeat;
1948 }
1949 [] L1CTL.receive { repeat; }
1950 [] T.timeout { }
1951 }
1952 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
1953 log("AGCH test: " & res_str);
1954 if (num_rx + num_del != num_tx) {
1955 setverdict(fail, "RX + DEL != TX ?!?: " & res_str);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001956 mtc.stop
Harald Weltee8d750e2018-06-10 21:41:35 +02001957 }
1958 rx_ratio := int2float(num_rx) / int2float(num_tx);
1959 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
1960 setverdict(fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
1961 } else {
1962 setverdict(pass);
1963 }
Daniel Willmann17ddd852018-07-05 17:33:20 +02001964 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001965}
1966
Harald Weltee8d750e2018-06-10 21:41:35 +02001967/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
1968testcase TC_imm_ass_1000_20ms() runs on test_CT {
1969 f_TC_imm_ass(1000, 0.02, 0.25);
1970}
1971
1972/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
1973testcase TC_imm_ass_200_0ms() runs on test_CT {
1974 f_TC_imm_ass(200, 0.0, 0.05);
1975}
1976
1977/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
1978testcase TC_imm_ass_200_76ms() runs on test_CT {
1979 f_TC_imm_ass(150, 0.076, 1.00);
1980}
1981
1982
1983
Harald Welte48494ca2018-02-25 16:59:50 +01001984/***********************************************************************
1985 * BCCH
1986 ***********************************************************************/
1987
1988/* tuple of Frame Number + decoded SI */
1989type record SystemInformationFn {
1990 GsmFrameNumber frame_number,
1991 SystemInformation si
1992}
1993
1994/* an arbitrary-length vector of decoded SI + gsmtap header */
1995type record of SystemInformationFn SystemInformationVector;
1996
1997/* an array of SI-vectors indexed by TC value */
1998type SystemInformationVector SystemInformationVectorPerTc[8];
1999
2000/* determine if a given SI vector contains given SI type at least once */
2001function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2002 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2003 var integer fn_mod51 := arr[i].frame_number mod 51;
2004 if (not bcch_ext and fn_mod51 == 2 or
2005 bcch_ext and fn_mod51 == 6) {
2006 if (arr[i].si.header.message_type == key) {
2007 return true;
2008 }
2009 }
2010 }
2011 return false;
2012}
2013
2014/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2015function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2016 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
2017 setverdict(fail, "No ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002018 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002019 }
2020}
2021
2022/* check if a given SI vector contains given SI type at least once on any TC */
2023function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2024 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2025 if (f_si_vecslot_contains(arr[tc], key) or
2026 f_si_vecslot_contains(arr[tc], key, true)) {
2027 return true;
2028 }
2029 }
2030 return false;
2031}
2032
2033/* determine if a given SI vector contains given SI type at least N of M times */
2034function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2035 var integer count := 0;
2036 if (sizeof(arr) < m) {
2037 setverdict(fail, "Error: Insufficient SI in array");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002038 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002039 }
2040 for (var integer i:= 0; i < m; i := i + 1) {
2041 var integer fn_mod51 := arr[i].frame_number mod 51;
2042 if (not bcch_ext and fn_mod51 == 2 or
2043 bcch_ext and fn_mod51 == 6) {
2044 if (arr[i].si.header.message_type == key) {
2045 count := count + 1;
2046 }
2047 }
2048 }
2049 if (count >= n) {
2050 return true;
2051 } else {
2052 return false;
2053 }
2054}
2055
2056/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2057function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2058 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
2059 setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002060 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002061 }
2062}
2063
2064/* determine if a given SI vector contains given SI type at least once */
2065function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2066 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2067 var integer fn_mod51 := arr[i].frame_number mod 51;
2068 if (not bcch_ext and fn_mod51 == 2 or
2069 bcch_ext and fn_mod51 == 6) {
2070 if (arr[i].si.header.message_type != key) {
2071 return false;
2072 }
2073 }
2074 }
2075 return true;
2076}
2077
2078/* ensure a given TC slot of the SI vector contains only given SI type */
2079function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2080 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
2081 setverdict(fail, "Not all ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002082 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002083 }
2084}
2085
2086/* SI configuration of cell, against which we validate actual SI messages */
2087type set SystemInformationConfig {
2088 boolean bcch_extended,
2089 boolean si1_present,
2090 boolean si2bis_present,
2091 boolean si2ter_present,
2092 boolean si2quater_present,
2093 boolean si7_present,
2094 boolean si8_present,
2095 boolean si9_present,
2096 boolean si13_present,
2097 boolean si13alt_present,
2098 boolean si15_present,
2099 boolean si16_present,
2100 boolean si17_present,
2101 boolean si2n_present,
2102 boolean si21_present,
2103 boolean si22_present
2104}
2105
2106/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2107function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2108 var integer i;
2109 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2110 if (sizeof(si_per_tc[i]) == 0) {
Harald Welte544565a2018-03-02 10:34:08 +01002111 setverdict(fail, "No SI messages for TC=", i);
Daniel Willmann17ddd852018-07-05 17:33:20 +02002112 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002113 }
2114 }
2115 if (cfg.si1_present) {
2116 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2117 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2118 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2119 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2120 /* make sure *ALL* contain SI1 */
2121 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2122 }
2123 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2124 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2125 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2126 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2127 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2128 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2129
2130 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2131 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2132 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2133 * consecutive occurrences of TC = 4. */
2134 if (cfg.si2bis_present and not cfg.si2ter_present) {
2135 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2136 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2137 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2138 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2139 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2140 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2141 }
2142
2143 if (cfg.si7_present or cfg.si8_present) {
2144 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2145 * if System Information type 4 does not contain all information needed for cell
2146 * selection and reselection. */
2147 if (not cfg.bcch_extended) {
2148 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2149 }
2150 if (cfg.si7_present) {
2151 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2152 }
2153 if (cfg.si8_present) {
2154 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2155 }
2156 }
2157
2158 if (cfg.si2quater_present) {
2159 /* iii) System information type 2 quater is sent if needed, as determined by the system
2160 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2161 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2162 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2163 * within any of 4 consecutive occurrences of TC = 5. */
2164 if (not (cfg.bcch_extended)) {
2165 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2166 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2167 } else {
2168 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2169 }
2170 } else {
2171 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2172 }
2173 }
2174 if (cfg.si9_present) {
2175 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2176 * in system information type 3 as defined in 3GPP TS 44.018. */
2177 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2178 }
2179 if (cfg.si13_present) {
2180 /* vii) System Information type 13 is only related to the GPRS service. System Information
2181 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2182 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2183 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2184 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2185 * within any of 4 consecutive occurrences of TC=4. */
2186 if (not cfg.bcch_extended) {
2187 log("not-bccch-extended");
2188 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2189 } else {
2190 log("bccch-extended");
2191 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2192 }
2193 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
2194 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002195 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002196 }
2197 }
2198 if (cfg.si16_present or cfg.si17_present) {
2199 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2200 * should not be sent in a cell where network sharing is used (see rule xv). */
2201 if (cfg.si22_present) {
2202 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2203 }
2204 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
2205 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002206 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002207 }
2208 if (not cfg.bcch_extended) {
2209 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2210 }
2211 if (cfg.si16_present) {
2212 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2213 }
2214 if (cfg.si17_present) {
2215 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2216 }
2217 }
2218
2219 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2220 * broadcast information. The frequency with which they are sent is determined by the
2221 * system operator. System Information type 9 identifies the scheduling of System
2222 * Information type 18 and 20 messages. */
2223
2224 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2225 * Information Type 19 is present, then its scheduling shall be indicated in System
2226 * Information Type 9. */
2227
2228 if (cfg.si15_present) {
2229 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2230 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2231 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2232 * 4 consecutive occurrences of TC = 1. */
2233 if (not cfg.bcch_extended) {
2234 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2235 } else {
2236 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2237 }
2238 }
2239 if (cfg.si13alt_present) {
2240 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2241 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2242 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2243 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2244 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2245 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2246 * of TC = 4. */
2247 if (cfg.si13_present) {
2248 testcase.stop("Error: Cannot have SI13alt and SI13");
2249 }
2250 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
2251 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002252 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002253 }
2254 if (not cfg.bcch_extended) {
2255 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2256 } else {
2257 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2258 }
2259 }
2260 if (cfg.si2n_present) {
2261 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2262 * as determined by the system operator. In the case that the message is sent on the
2263 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2264 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2265 * consecutive occurrences of TC = 4. */
2266 if (not cfg.bcch_extended) {
2267 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2268 } else {
2269 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2270 }
2271 }
2272 if (cfg.si21_present) {
2273 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2274 * determined by the system operator. If Extended Access Barring is in use in the cell
2275 * then this message is sent at least once within any of 4 consecutive occurrences of
2276 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2277 * cell then this message shall only be sent on BCCH Ext. */
2278 if (not cfg.bcch_extended) {
2279 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2280 } else {
2281 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2282 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
2283 setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002284 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002285 }
2286 }
2287 }
2288 if (cfg.si22_present) {
2289 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2290 * should not be sent in a cell where SoLSA is used (see rule viii). System
2291 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2292 * =2 and TC=6. */
2293 if (cfg.si16_present or cfg.si17_present) {
2294 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2295 }
2296 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2297 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
2298 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002299 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002300 }
2301 if (not cfg.bcch_extended) {
2302 testcase.stop("Error: SI22 requires BCCH Extd!");
2303 } else {
2304 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2305 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2306 }
2307 }
2308}
2309
2310/* sample Systme Information for specified duration via L1CTL */
2311function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2312 timer T := duration;
2313 var SystemInformationVectorPerTc si_per_tc;
2314 var L1ctlDlMessage l1_dl;
2315
2316 /* initialize all per-TC vectors empty */
2317 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2318 si_per_tc[i] := {};
2319 }
2320
2321 /* flush all previous L1 queued msgs */
2322 pt.clear;
2323
2324 T.start;
2325 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002326 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002327 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2328 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2329 log("Ignoring non-RR SI ", l1_dl);
2330 repeat;
2331 }
2332 var SystemInformationFn sig := {
2333 frame_number := l1_dl.dl_info.frame_nr,
2334 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2335 }
2336 var integer tc := f_gsm_compute_tc(sig.frame_number);
2337 log("SI received at TC=", tc, ": ", sig.si);
2338 /* append to the per-TC bucket */
2339 si_per_tc[tc] := si_per_tc[tc] & { sig };
2340 repeat;
2341 }
2342 [] pt.receive { repeat; }
2343 [] T.timeout { }
2344 }
2345
2346 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2347 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2348 }
2349 log("si_per_tc=", si_per_tc);
2350 return si_per_tc;
2351}
2352
2353/* helper function: Set given SI via RSL + validate scheduling.
2354 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2355function f_TC_si_sched() runs on test_CT {
2356 var SystemInformationVectorPerTc si_per_tc;
2357 f_init_l1ctl();
2358 f_l1_tune(L1CTL);
2359
2360 /* Sample + Validate Scheduling */
2361 si_per_tc := f_l1_sample_si(L1CTL);
2362 f_validate_si_scheduling(si_cfg, si_per_tc);
2363
2364 setverdict(pass);
2365}
2366
2367testcase TC_si_sched_default() runs on test_CT {
2368 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002369 /* 2+3+4 are mandatory and set in f_init() */
2370 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002371 f_shutdown();
Harald Welte0cae4552018-03-09 22:20:26 +01002372}
2373
2374testcase TC_si_sched_1() runs on test_CT {
2375 f_init();
2376 si_cfg.si1_present := true;
2377 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002378 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002379 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002380}
2381
2382testcase TC_si_sched_2bis() runs on test_CT {
2383 f_init();
2384 si_cfg.si2bis_present := true;
2385 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2386 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002387 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002388}
2389
2390testcase TC_si_sched_2ter() runs on test_CT {
2391 f_init();
2392 si_cfg.si2ter_present := true;
2393 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2394 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002395 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002396}
2397
2398testcase TC_si_sched_2ter_2bis() runs on test_CT {
2399 f_init();
2400 si_cfg.si2bis_present := true;
2401 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2402 si_cfg.si2ter_present := true;
2403 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2404 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002405 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002406}
2407
2408testcase TC_si_sched_2quater() runs on test_CT {
2409 f_init();
2410 si_cfg.si2quater_present := true;
2411 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2412 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002413 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002414}
2415
2416testcase TC_si_sched_13() runs on test_CT {
2417 f_init();
2418 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002419 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002420 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002421 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002422}
2423
2424testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2425 f_init();
2426 si_cfg.si2bis_present := true;
2427 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2428 si_cfg.si2ter_present := true;
2429 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2430 si_cfg.si2quater_present := true;
2431 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2432 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002433 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002434 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002435 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002436}
2437
2438
Harald Welte68e495b2018-02-25 00:05:57 +01002439testcase TC_bcch_info() runs on test_CT {
2440 f_init(testcasename());
2441 /* FIXME: enable / disable individual BCCH info */
2442 //ts_RSL_BCCH_INFO(si_type, info);
2443 /* expect no ERROR REPORT after either of them *
2444 /* negative test: ensure ERROR REPORT on unsupported types */
Harald Welte294b0a22018-03-10 23:26:48 +01002445 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01002446}
2447
Harald Welte93640c62018-02-25 16:59:33 +01002448/***********************************************************************
2449 * Low-Level Protocol Errors / ERROR REPORT
2450 ***********************************************************************/
2451
Harald Welte01d982c2018-02-25 01:31:40 +01002452private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2453 timer T := 5.0;
2454 T.start;
2455 alt {
2456 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2457 setverdict(pass);
2458 }
2459 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
2460 setverdict(fail, "Wrong cause in RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002461 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002462 }
2463 [] RSL_CCHAN.receive {
2464 repeat;
2465 }
2466 [] T.timeout {
2467 setverdict(fail, "Timeout waiting for RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002468 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002469 }
2470 }
2471}
2472
2473/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2474testcase TC_rsl_protocol_error() runs on test_CT {
2475 f_init(testcasename());
2476 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2477 rsl.ies := omit;
2478 RSL_CCHAN.send(ts_RSL_UD(rsl));
2479
2480 f_exp_err_rep(RSL_ERR_PROTO);
2481}
2482
2483/* Provoke a mandatory IE error and match on ERROR REPORT */
2484testcase TC_rsl_mand_ie_error() runs on test_CT {
2485 f_init(testcasename());
2486
2487 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2488 rsl.ies := { rsl.ies[0] };
2489 RSL_CCHAN.send(ts_RSL_UD(rsl));
2490
2491 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2492}
2493
2494/* Provoke an IE content error and match on ERROR REPORT */
2495testcase TC_rsl_ie_content_error() runs on test_CT {
2496 f_init(testcasename());
2497 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2498 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2499 RSL_CCHAN.send(ts_RSL_UD(rsl));
2500
2501 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2502}
2503
Harald Welte93640c62018-02-25 16:59:33 +01002504/***********************************************************************
2505 * IPA CRCX/MDCX/DLCS media stream handling
2506 ***********************************************************************/
2507
Harald Weltea871a382018-02-25 02:03:14 +01002508/* Send IPA DLCX to inactive lchan */
2509function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01002510 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2511 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01002512}
2513testcase TC_ipa_dlcx_not_active() runs on test_CT {
2514 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2515 f_init(testcasename());
2516 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
2517 vc_conn.done;
2518}
Harald Welte68e495b2018-02-25 00:05:57 +01002519
Harald Weltea3f1df92018-02-25 12:49:55 +01002520/* Send IPA CRCX twice to inactive lchan */
2521function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
2522 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2523 "IPA CRCX ACK");
2524 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
2525 "IPA CRCX NACK");
2526}
2527testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
2528 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2529 f_init(testcasename());
2530 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
2531 vc_conn.done;
2532}
2533
2534/* Regular sequence of CRCX/MDCX/DLCX */
2535function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2536 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2537 "IPA CRCX ACK");
2538 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2539 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2540 var uint7_t rtp_pt2 := f_rnd_int(127);
2541 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2542 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2543 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2544 "IPA MDCX ACK");
2545 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2546 "IPA DLCX ACK");
2547}
2548testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
2549 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2550 f_init(testcasename());
2551 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
2552 vc_conn.done;
2553}
2554
Harald Welte3ae11da2018-02-25 13:36:06 +01002555/* Sequence of CRCX, 2x MDCX, DLCX */
2556function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2557 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2558 "IPA CRCX ACK");
2559 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2560 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2561 var uint7_t rtp_pt2 := f_rnd_int(127);
2562 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2563 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2564 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2565 "IPA MDCX ACK");
2566 /* Second MDCX */
2567 remote_ip := f_rnd_int(c_UINT32_MAX);
2568 remote_port := f_rnd_int(c_UINT16_MAX);
2569 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2570 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2571 "IPA MDCX ACK");
2572 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2573 "IPA DLCX ACK");
2574}
2575testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2576 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2577 f_init(testcasename());
2578 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2579 vc_conn.done;
2580}
2581
Harald Welte9912eb52018-02-25 13:30:15 +01002582/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2583function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2584 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2585 "IPA CRCX NACK");
2586}
2587testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2588 var ConnHdlrPars pars;
2589 var ConnHdlr vc_conn;
2590 f_init(testcasename());
2591
2592 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2593 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2594 vc_conn.done;
2595
2596 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2597 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2598 vc_conn.done;
2599}
2600
Harald Weltea3f1df92018-02-25 12:49:55 +01002601
Harald Welte883340c2018-02-28 18:59:29 +01002602/***********************************************************************
2603 * PCU Socket related tests
2604 ***********************************************************************/
2605
2606private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2607runs on test_CT {
2608 timer T := 3.0;
2609
2610 /* we don't expect any RTS.req before PDCH are active */
2611 T.start;
2612 alt {
2613 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
2614 setverdict(fail, "PCU RTS.req before PDCH active?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002615 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002616 }
2617 [] PCU.receive { repeat; }
2618 [] T.timeout { }
2619 }
2620
2621 /* Send PDCH activate request for known PDCH timeslot */
2622 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2623
2624 /* we now expect RTS.req for this timeslot (only) */
2625 T.start;
2626 alt {
2627 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2628 setverdict(pass);
2629 }
2630 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2631 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2632 setverdict(fail, "Unexpected RTS.req for supposedly failing activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002633 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002634 }
2635 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
2636 setverdict(fail, "RTS.req for wrong TRX/TS");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002637 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002638 }
2639 [] PCU.receive { repeat; }
2640 [exp_success] T.timeout {
2641 setverdict(fail, "Timeout waiting for PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002642 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002643 }
2644 [not exp_success] T.timeout {
2645 setverdict(pass);
2646 }
2647 }
2648}
2649
2650private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2651runs on test_CT {
2652 timer T := 3.0;
2653
2654 /* Send PDCH activate request for known PDCH timeslot */
2655 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2656
2657 PCU.clear;
2658 /* we now expect no RTS.req for this timeslot */
2659 T.start;
2660 alt {
2661 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2662 setverdict(fail, "Received unexpected PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002663 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002664 }
2665 [] PCU.receive { repeat; }
2666 [] T.timeout {
2667 setverdict(pass);
2668 }
2669 }
2670}
2671
2672/* PDCH activation via PCU socket; check for presence of RTS.req */
2673testcase TC_pcu_act_req() runs on test_CT {
2674 f_init();
2675 f_TC_pcu_act_req(0, 0, 7, true);
2676}
2677
2678/* PDCH activation via PCU socket on non-PDCU timeslot */
2679testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
2680 f_init();
2681 f_TC_pcu_act_req(0, 0, 1, false);
2682}
2683
2684/* PDCH activation via PCU socket on wrong BTS */
2685testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
2686 f_init();
2687 f_TC_pcu_act_req(23, 0, 7, false);
2688}
2689
2690/* PDCH activation via PCU socket on wrong TRX */
2691testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
2692 f_init();
2693 f_TC_pcu_act_req(0, 23, 7, false);
2694}
2695
2696/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2697testcase TC_pcu_deact_req() runs on test_CT {
2698 f_init();
2699 /* Activate PDCH */
2700 f_TC_pcu_act_req(0, 0, 7, true);
2701 f_sleep(1.0);
2702 /* and De-Activate again */
2703 f_TC_pcu_deact_req(0, 0, 7);
2704}
2705
2706/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2707testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
2708 f_init();
2709 f_TC_pcu_deact_req(0, 0, 1);
2710}
2711
2712/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2713testcase TC_pcu_ver_si13() runs on test_CT {
2714 const octetstring si13 := '00010203040506070909'O;
2715 var PCUIF_send_data sd;
2716 timer T:= 3.0;
2717 f_init();
2718
2719 /* Set SI13 via RSL */
2720 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
2721 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, "BTS_Test v23")));
2722 T.start;
2723 alt {
2724 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2725 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2726 setverdict(pass);
2727 } else {
2728 repeat;
2729 }
2730 }
2731 [] PCU.receive { repeat; }
2732 [] T.timeout {
2733 setverdict(fail, "Timeout waiting for SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002734 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002735 }
2736 }
2737}
2738
2739private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2740
2741/* helper function to send a PCU DATA.req */
2742private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2743 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2744runs on test_CT
2745{
2746 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2747 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2748}
2749
2750/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2751private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2752 PCUIF_Sapi sapi, octetstring data)
2753runs on test_CT
2754{
2755 var PCUIF_send_data sd;
2756
2757 timer T := 3.0;
2758 T.start;
2759 alt {
2760 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2761 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2762 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2763 sd.data.u.rts_req.fn, sapi, data);
2764 }
2765 [] PCU.receive { repeat; }
2766 [] T.timeout {
2767 setverdict(fail, "Timeout waiting for RTS.ind");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002768 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002769 }
2770 }
2771}
2772
2773/* Send DATA.req on invalid BTS */
2774testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
2775 f_init();
2776 f_TC_pcu_act_req(0, 0, 7, true);
2777 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2778 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2779 f_sleep(10.0);
2780}
2781
2782/* Send DATA.req on invalid TRX */
2783testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
2784 f_init();
2785 f_TC_pcu_act_req(0, 0, 7, true);
2786 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2787 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2788 f_sleep(10.0);
2789}
2790
2791/* Send DATA.req on invalid timeslot */
2792testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
2793 f_init();
2794 f_TC_pcu_act_req(0, 0, 7, true);
2795 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2796 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2797 f_sleep(10.0);
2798}
2799
2800/* Send DATA.req on timeslot that hasn't been activated */
2801testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
2802 f_init();
2803 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2804 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2805 f_sleep(2.0);
2806}
2807
2808testcase TC_pcu_data_req_pdtch() runs on test_CT {
2809 f_init();
2810 f_TC_pcu_act_req(0, 0, 7, true);
2811 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2812 /* FIXME: how to check this was actually sent */
2813 f_sleep(2.0);
2814}
2815
2816testcase TC_pcu_data_req_ptcch() runs on test_CT {
2817 f_init();
2818 f_TC_pcu_act_req(0, 0, 7, true);
2819 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2820 /* FIXME: how to check this was actually sent */
2821 f_sleep(2.0);
2822}
2823
2824/* Send AGCH from PCU; check it appears on Um side */
2825testcase TC_pcu_data_req_agch() runs on test_CT {
2826 timer T := 3.0;
2827 f_init();
2828 f_init_l1ctl();
2829 f_l1_tune(L1CTL);
2830
2831 f_TC_pcu_act_req(0, 0, 7, true);
2832 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2833
2834 T.start;
2835 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002836 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002837 setverdict(pass);
2838 }
2839 [] L1CTL.receive { repeat; }
2840 [] T.timeout {
2841 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002842 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002843 }
2844 }
2845}
2846
2847/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2848testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2849 var octetstring imm_ass := f_rnd_octstring(23);
2850 f_init();
2851 f_init_l1ctl();
2852 f_l1_tune(L1CTL);
2853
2854 /* append 3 last imsi digits so BTS can compute pagng group */
2855 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2856
2857 timer T := 0.5;
2858 T.start;
2859 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002860 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002861 /* TODO: verify paging group */
2862 setverdict(pass);
2863 }
2864 [] L1CTL.receive { repeat; }
2865 [] T.timeout {
2866 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002867 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002868 }
2869 }
2870}
2871
2872/* Send RACH from Um side, expect it to show up on PCU socket */
2873testcase TC_pcu_rach_content() runs on test_CT {
2874 f_init();
2875 f_init_l1ctl();
2876 f_l1_tune(L1CTL);
2877
2878 var GsmFrameNumber fn_last := 0;
2879 for (var integer i := 0; i < 1000; i := i+1) {
2880 var OCT1 ra := f_rnd_ra_ps();
2881 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2882 if (fn == fn_last) {
2883 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002884 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002885 }
2886 fn_last := fn;
2887
2888 timer T := 2.0;
2889 T.start;
2890 alt {
2891 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2892 T.stop;
2893 }
2894 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
2895 setverdict(fail, "Unexpected RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002896 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002897 }
2898 [] PCU.receive { repeat; }
2899 [] T.timeout {
2900 setverdict(fail, "Timeout waiting for RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002901 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002902 }
2903 }
2904 }
2905 setverdict(pass);
2906}
2907
2908private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
2909 var integer strlen := lengthof(str);
2910 for (var integer i := 0; i < len-strlen; i := i+1) {
2911 str := str & pad;
2912 }
2913 return str;
2914}
2915
2916/* Send PAGING via RSL, expect it to shw up on PCU socket */
2917testcase TC_pcu_paging_from_rsl() runs on test_CT {
2918 f_init();
2919
2920 for (var integer i := 0; i < 100; i := i+1) {
2921 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2922 timer T := 3.0;
2923 if (i < 50) {
2924 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2925 } else {
2926 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
2927 }
2928 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2929 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2930 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
2931
2932 /* Send RSL PAGING COMMAND */
2933 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
2934 T.start;
2935 alt {
2936 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
2937 }
2938 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
2939 setverdict(fail, "Unexpected PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002940 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002941 }
2942 [] PCU.receive { repeat; }
2943 [] T.timeout {
2944 setverdict(fail, "Timeout waiting for PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002945 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002946 }
2947 }
2948 }
2949 setverdict(pass);
2950}
2951
Harald Welte3d04ae62018-04-04 20:29:05 +02002952/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02002953 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02002954 ***********************************************************************/
2955
2956private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2957runs on ConnHdlr {
2958 var PCUIF_send_data sd;
2959 /* Expect BTS to immediately acknowledge activation as PDCH */
2960 PCU.clear;
2961 f_rsl_chan_act(g_pars.chan_mode);
2962 /* expect INFO_IND on PCU interface listing TS as PDCH */
2963 alt {
2964 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2965 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
2966 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002967 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002968 }
2969 }
2970 [] PCU.receive { repeat; }
2971 }
2972 /* try to activate this PDCH from the PCU point of view */
2973 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
2974 /* FIXME: is there a response? */
2975}
2976
2977private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2978runs on ConnHdlr {
2979 var PCUIF_send_data sd;
2980 /* Send RSL CHAN REL (deactivate) */
2981 PCU.clear;
2982 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
2983 /* expect BTS to ask PCU to deactivate the channel */
2984 alt {
2985 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2986 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
2987 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002988 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002989 }
2990 }
2991 [] PCU.receive { repeat; }
2992 }
2993 /* Emulate PCU asking BTS to deactivate PDCH */
2994 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
2995 alt {
2996 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
2997 setverdict(pass);
2998 }
2999 [] RSL.receive { repeat; }
3000 }
3001}
3002
3003/* Activate Osmocom-style dynamic PDCH from BSC side */
3004function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3005 var PCUIF_Message first_info;
3006 var integer ts_nr := g_chan_nr.tn;
3007 var integer trx_nr := 0;
3008 var integer bts_nr := 0;
3009 var integer pcu_conn_id := -1;
3010
3011 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3012
3013 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3014 f_sleep(3.0);
3015 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3016 setverdict(pass);
3017}
3018testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3019 var ConnHdlrPars pars;
3020 var ConnHdlr vc_conn;
3021 f_init(testcasename());
3022
3023 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3024 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3025 vc_conn.done;
3026}
3027
3028/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3029function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3030 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003031 var integer pcu_conn_id := -1;
3032
3033 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3034
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003035 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3036 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3037 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003038 setverdict(pass);
3039}
3040testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3041 var ConnHdlrPars pars;
3042 var ConnHdlr vc_conn;
3043 f_init(testcasename());
3044
3045 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3046 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3047 vc_conn.done;
3048}
3049
3050/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3051function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3052 var PCUIF_Message first_info;
3053 var integer ts_nr := g_chan_nr.tn;
3054 var integer trx_nr := 0;
3055 var integer bts_nr := 0;
3056 var integer pcu_conn_id := -1;
3057
3058 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3059
3060 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003061 /* Send a second Chan Activ and expect it to be NACKed */
3062 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3063 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003064 setverdict(pass);
3065}
3066testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3067 var ConnHdlrPars pars;
3068 var ConnHdlr vc_conn;
3069 f_init(testcasename());
3070
3071 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3072 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3073 vc_conn.done;
3074}
3075
3076/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3077function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3078 var PCUIF_Message first_info;
3079 var integer ts_nr := g_chan_nr.tn;
3080 var integer trx_nr := 0;
3081 var integer bts_nr := 0;
3082 var integer pcu_conn_id := -1;
3083 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3084
3085 /* register for the TCH/F channel number */
3086 f_rslem_register(0, chan_nr);
3087
3088 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3089
3090 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3091 "RSL CHAN ACT");
3092 setverdict(pass);
3093}
3094testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3095 var ConnHdlrPars pars;
3096 var ConnHdlr vc_conn;
3097 f_init(testcasename());
3098
3099 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3100 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3101 vc_conn.done;
3102}
3103
3104/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3105function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3106 var PCUIF_Message first_info;
3107 var integer ts_nr := g_chan_nr.tn;
3108 var integer trx_nr := 0;
3109 var integer bts_nr := 0;
3110 var integer pcu_conn_id := -1;
3111 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3112 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3113
3114 /* register for the TCH/H channel numbers */
3115 f_rslem_register(0, chan_nr[0]);
3116 f_rslem_register(0, chan_nr[1]);
3117
3118 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3119
3120 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3121 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3122 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3123 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3124 setverdict(pass);
3125}
3126testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3127 var ConnHdlrPars pars;
3128 var ConnHdlr vc_conn;
3129 f_init(testcasename());
3130
3131 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3132 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3133 vc_conn.done;
3134}
3135
Harald Welte9bbbfb52018-04-05 09:33:19 +02003136/***********************************************************************
3137 * IPA Style Dynamic Timeslot Support
3138 ***********************************************************************/
3139
3140private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3141runs on ConnHdlr {
3142 var PCUIF_send_data sd;
3143 /* Expect BTS to immediately acknowledge activation as PDCH */
3144 PCU.clear;
3145 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3146 /* expect INFO_IND on PCU interface listing TS as PDCH */
3147 alt {
3148 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3149 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
3150 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003151 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003152 }
3153 }
3154 [] PCU.receive { repeat; }
3155 }
3156 /* try to activate this PDCH from the PCU point of view */
3157 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3158 /* FIXME: is there a response? */
3159
3160 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3161}
3162
3163private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3164runs on ConnHdlr {
3165 var PCUIF_send_data sd;
3166 /* Send RSL CHAN REL (deactivate) */
3167 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3168 PCU.clear;
3169 /* expect BTS to ask PCU to deactivate the channel */
3170 alt {
3171 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3172 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
3173 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003174 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003175 }
3176 }
3177 [] PCU.receive { repeat; }
3178 }
3179 /* Emulate PCU asking BTS to deactivate PDCH */
3180 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3181 alt {
3182 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3183 setverdict(pass);
3184 }
3185 [] RSL.receive { repeat; }
3186 }
3187}
3188
3189/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3190function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3191 var PCUIF_Message first_info;
3192 var integer ts_nr := g_chan_nr.tn;
3193 var integer trx_nr := 0;
3194 var integer bts_nr := 0;
3195 var integer pcu_conn_id := -1;
3196
3197 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3198
3199 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3200 f_sleep(3.0);
3201 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3202
3203 setverdict(pass);
3204
3205}
3206testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3207 var ConnHdlrPars pars;
3208 var ConnHdlr vc_conn;
3209 f_init();
3210
3211 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3212 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3213 vc_conn.done;
3214}
3215
3216/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3217function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3218 var PCUIF_Message first_info;
3219 var integer ts_nr := g_chan_nr.tn;
3220 var integer trx_nr := 0;
3221 var integer bts_nr := 0;
3222 var integer pcu_conn_id := -1;
3223
3224 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3225
3226 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3227 "RSL CHAN ACT");
3228 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3229 "RF CHAN REL", true);
3230 setverdict(pass);
3231}
3232testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3233 var ConnHdlrPars pars;
3234 var ConnHdlr vc_conn;
3235 f_init(testcasename());
3236
3237 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3238 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3239 vc_conn.done;
3240}
3241
3242/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3243function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3244 var PCUIF_Message first_info;
3245 var integer ts_nr := g_chan_nr.tn;
3246 var integer trx_nr := 0;
3247 var integer bts_nr := 0;
3248 var integer pcu_conn_id := -1;
3249
3250 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3251
3252 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3253 "RSL CHAN ACT");
3254
3255 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3256 alt {
3257 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3258 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
3259 setverdict(fail, "Unexpected PDCH ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003260 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003261 }
3262 [] RSL.receive { repeat; }
3263 }
3264
3265 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3266 "RF CHAN REL", true);
3267 setverdict(pass);
3268}
3269testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3270 var ConnHdlrPars pars;
3271 var ConnHdlr vc_conn;
3272 f_init(testcasename());
3273
3274 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3275 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3276 vc_conn.done;
3277}
3278
3279/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3280function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3281 var PCUIF_Message first_info;
3282 var integer ts_nr := g_chan_nr.tn;
3283 var integer trx_nr := 0;
3284 var integer bts_nr := 0;
3285 var integer pcu_conn_id := -1;
3286
3287 /* register for the TCH/F channel number */
3288 f_rslem_register(0, g_chan_nr);
3289
3290 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3291
3292 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3293
3294 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3295 "RSL CHAN ACT");
3296
3297 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3298
3299 setverdict(pass);
3300}
3301testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3302 var ConnHdlrPars pars;
3303 var ConnHdlr vc_conn;
3304 f_init(testcasename());
3305
3306 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3307 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3308 vc_conn.done;
3309}
3310
3311
Harald Welte0472ab42018-03-12 15:02:26 +01003312/***********************************************************************
3313 * LAPDm / RLL related
3314 ***********************************************************************/
3315
3316private function f_tx_lapdm(template (value) LapdmFrame l,
3317 template (value) RslLinkId link_id) runs on ConnHdlr {
3318 var octetstring l2 := enc_LapdmFrame(valueof(l));
3319 if (valueof(link_id.c) == SACCH) {
3320 /* prepend dummy L1 header */
3321 l2 := '0000'O & l2;
3322 }
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07003323
3324 /* If required, pad L2 frame with constant 0x2b filling */
3325 l2 := f_pad_oct(l2, 23, '2B'O);
3326
Harald Welte0472ab42018-03-12 15:02:26 +01003327 log("encoding ", l, " to ", l2);
3328 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
3329}
3330
3331type record RllTestCase {
3332 uint3_t sapi,
3333 RslLinkId link_id,
3334 octetstring l3,
3335 boolean exp
3336}
3337type record of RllTestCase RllTestCases;
3338template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3339 sapi := sapi,
3340 link_id := id,
3341 l3 := l3,
3342 exp := exp
3343}
3344
3345/* execute the same callback function with a set of different parameters (tcs) on a
3346 * variety of logical channels */
3347private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
3348 var ConnHdlrPars pars;
3349 var ConnHdlr vc_conn;
3350 f_init(testcasename());
3351
3352 /* test on each of the channels we have */
3353 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
3354 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
3355
3356 /* test each of the test cases on the current channel */
3357 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
3358 pars.spec.rll := tcs[j];
3359 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
3360 vc_conn := f_start_handler(fn, pars);
3361 vc_conn.done;
3362 }
3363 }
3364
3365 f_shutdown();
3366}
3367
3368/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
3369private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
3370 var RllTestCase tc := g_pars.spec.rll;
3371 timer T := 3.0;
3372
3373 f_l1_tune(L1CTL);
3374 RSL.clear;
3375
3376 /* activate the logical channel */
3377 f_est_dchan();
3378 L1CTL.clear;
3379
3380 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
3381 T.start;
3382 alt {
3383 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
3384 if (tc.exp) {
3385 setverdict(pass);
3386 } else {
3387 setverdict(fail, "Unexpected EST IND with L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003388 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003389 }
3390 }
3391 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
3392 if (tc.exp) {
3393 setverdict(pass);
3394 } else {
3395 setverdict(fail, "Unexpected EST IND without L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003396 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003397 }
3398 }
3399 [tc.exp] T.timeout {
3400 setverdict(fail, "Timeout waiting for EST IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003401 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003402 }
3403 [not tc.exp] T.timeout {
3404 setverdict(pass);
3405 }
3406 }
3407
3408 f_rsl_chan_deact();
3409 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3410 f_rslem_unregister(0, g_chan_nr);
3411}
3412testcase TC_rll_est_ind() runs on test_CT {
3413 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02003414 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01003415 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02003416 /* normal SAPI0 establishment */
3417 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01003418 /* SAPI 3 doesn't support contention resolution */
3419 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
3420 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
3421 /* normal SAPI3 establishment on main DCCH */
3422 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3423 /* normal SAPI3 establishment on SACCH */
3424 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3425 };
3426 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
3427}
3428
3429/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
3430private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
3431 var RllTestCase tc := g_pars.spec.rll;
3432 var L1ctlDlMessage dl;
3433 timer T := 3.0;
3434
3435 f_l1_tune(L1CTL);
3436 RSL.clear;
3437
3438 /* activate the logical channel */
3439 f_est_dchan();
3440 L1CTL.clear;
3441
3442 /* Send a RSL EST REQ for SAPI3 on main DCCH */
3443 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
3444 T.start;
3445 alt {
3446 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3447 var LapdmFrame lapdm;
3448 var octetstring l2 := dl.payload.data_ind.payload;
3449 if (dl.dl_info.link_id.c == SACCH) {
3450 /* remove L1 header */
3451 l2 := substr(l2, 2, lengthof(l2)-2);
3452 }
3453 lapdm.ab := dec_LapdmFrameAB(l2);
3454 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
3455 setverdict(pass);
3456 } else {
3457 repeat;
3458 }
3459 }
3460 [] L1CTL.receive { repeat; }
3461 [] T.timeout {
3462 setverdict(fail, "Timeout waiting for SABM");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003463 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003464 }
3465 }
3466
3467 f_rsl_chan_deact();
3468 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3469 f_rslem_unregister(0, g_chan_nr);
3470}
3471testcase TC_rll_est_req_DCCH_3() runs on test_CT {
3472 var RllTestCases tcs := {
3473 /* normal SAPI3 establishment on main DCCH */
3474 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
3475 };
3476 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3477}
3478testcase TC_rll_est_req_ACCH_3() runs on test_CT {
3479 var RllTestCases tcs := {
3480 /* normal SAPI3 establishment on SACCH */
3481 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3482 }
3483 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3484}
3485
3486/* altstep to receive a LAPDm frame matching the given template */
3487private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
3488 var L1ctlDlMessage dl;
3489 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3490 var LapdmFrame lapdm;
3491 var octetstring l2 := dl.payload.data_ind.payload;
3492 if (dl.dl_info.link_id.c == SACCH) {
3493 /* remove L1 header */
3494 l2 := substr(l2, 2, lengthof(l2)-2);
3495 }
3496 if (ischosen(exp.ab)) {
3497 lapdm.ab := dec_LapdmFrameAB(l2);
3498 } else if (ischosen(exp.b4)) {
3499 lapdm.b4 := dec_LapdmFrameB4(l2);
3500 } else if (ischosen(exp.bbis)) {
3501 lapdm.bbis := dec_LapdmFrameBbis(l2);
3502 }
3503 log("Rx LAPDm ", lapdm);
3504 if (match(lapdm, exp)) {
3505 setverdict(pass);
3506 } else {
3507 repeat;
3508 }
3509 }
3510 [] L1CTL.receive { repeat; }
3511}
3512private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
3513 timer T := t;
3514 T.start;
3515 alt {
3516 [] T.timeout {
3517 setverdict(fail, "Timeout waiting for LAPDm ", exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003518 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003519 }
3520 [] as_l1_exp_lapdm(exp);
3521 }
3522}
3523
3524/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
3525private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3526 /* send SABM from MS -> BTS */
3527 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
3528 /* expect RLL EST IND on Abis */
3529 alt {
3530 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
3531 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
3532 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
3533 setverdict(fail, "Failing due to RSL_ERROR_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003534 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003535 }
3536 [] RSL.receive { repeat; }
3537 }
3538 /* expect UA from BTS -> MS */
3539 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
3540}
3541
3542/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
3543private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
3544 var RllTestCase tc := g_pars.spec.rll;
3545
3546 f_l1_tune(L1CTL);
3547 RSL.clear;
3548
3549 /* activate the logical channel */
3550 f_est_dchan();
3551 L1CTL.clear;
3552
3553 /* first establish the link-layer */
3554 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3555
3556 /* then send the DISC */
3557 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
3558 /* ... and expect the REL IND on the RSL side */
3559 alt {
3560 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
3561 setverdict(pass);
3562 }
3563 }
3564
3565 /* release the channel */
3566 f_rsl_chan_deact();
3567 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3568 f_rslem_unregister(0, g_chan_nr);
3569}
3570testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
3571 var RllTestCases tcs := {
3572 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
3573 };
3574 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3575}
3576
3577testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
3578 var RllTestCases tcs := {
3579 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
3580 };
3581 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3582}
3583testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
3584 var RllTestCases tcs := {
3585 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
3586 };
3587 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3588}
3589testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
3590 var RllTestCases tcs := {
3591 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3592 };
3593 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3594}
3595
3596/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
3597private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
3598 var RllTestCase tc := g_pars.spec.rll;
3599 f_l1_tune(L1CTL);
3600 RSL.clear;
3601
3602 /* activate the logical channel */
3603 f_est_dchan();
3604 L1CTL.clear;
3605
3606 /* first establish the link-layer */
3607 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3608
3609 /* then send the REL REQ via RSL */
3610 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
3611 /* ... and expect the DISC on the Um side */
3612 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02003613 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01003614 /* FIXME: send a UA in resposne to the DISC */
3615 }
3616 }
3617
3618 /* release the channel */
3619 f_rsl_chan_deact();
3620 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3621 f_rslem_unregister(0, g_chan_nr);
3622}
3623testcase TC_rll_rel_req() runs on test_CT {
3624 var RllTestCases tcs := {
3625 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
3626 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
3627 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3628 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3629 };
3630 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
3631}
3632
3633/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
3634testcase TC_rll_data_req() runs on test_CT {
3635}
3636
3637/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
3638testcase TC_rll_data_ind() runs on test_CT {
3639}
3640
3641/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
3642private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
3643 var RllTestCase tc := g_pars.spec.rll;
3644
3645 f_l1_tune(L1CTL);
3646 RSL.clear;
3647
3648 f_est_dchan();
3649 L1CTL.clear;
3650
3651 /* Send UNITDATA REQ on RSL side */
3652 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
3653 /* Expect it to arrive on the other side */
3654 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02003655 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003656 } else {
Harald Weltee613f962018-04-18 22:38:16 +02003657 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003658 }
3659
3660 /* release the channel */
3661 f_rsl_chan_deact();
3662 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3663 f_rslem_unregister(0, g_chan_nr);
3664}
3665testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
3666 var octetstring l3 := f_rnd_octstring(15);
3667 var RllTestCases tcs := {
3668 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3669 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3670 };
3671 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3672}
3673testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
3674 var octetstring l3 := f_rnd_octstring(19);
3675 var RllTestCases tcs := {
3676 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3677 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3678 };
3679 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3680}
3681
3682/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
3683private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
3684 var RllTestCase tc := g_pars.spec.rll;
3685
3686 f_l1_tune(L1CTL);
3687 RSL.clear;
3688
3689 f_est_dchan();
3690 L1CTL.clear;
3691
3692 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02003693 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01003694 /* Expdct RLL UNITDATA IND on RSL side */
3695 alt {
3696 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
3697 setverdict(pass);
3698 }
3699 [] RSL.receive { repeat; }
3700 }
3701
3702 /* release the channel */
3703 f_rsl_chan_deact();
3704 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3705 f_rslem_unregister(0, g_chan_nr);
3706}
3707testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02003708 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01003709 var RllTestCases tcs := {
3710 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3711 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3712 };
3713 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3714}
3715testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
3716 var octetstring l3 := f_rnd_octstring(18);
3717 var RllTestCases tcs := {
3718 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3719 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3720 };
3721 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3722}
3723
Harald Weltee613f962018-04-18 22:38:16 +02003724/***********************************************************************
3725 * Encryption Related
3726 ***********************************************************************/
3727
3728/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3729function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3730 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
3731 if (link_id.c == SACCH) {
3732 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
3733 } else {
3734 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
3735 }
3736}
3737
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003738/* Expect (or not expect) SACCH messages (Measurement Reports) */
3739private altstep as_rsl_sacch_ind(boolean exp_sacch) runs on ConnHdlr {
3740 [exp_sacch] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) { repeat; }
3741 [not exp_sacch] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) {
3742 setverdict(fail, "Unexpected (SACCH) UNIT_DATA_IND message!");
3743 mtc.stop;
3744 }
3745}
3746/* Expect (or not expect) other kinds of messages */
3747private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
3748 [exp_any] RSL.receive { repeat; }
3749 [not exp_any] RSL.receive {
3750 setverdict(fail, "Unexpected RSL message!");
3751 mtc.stop;
3752 }
3753}
3754
Harald Weltee613f962018-04-18 22:38:16 +02003755/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07003756private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003757 RslLinkId link_id,
3758 octetstring l3,
3759 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003760 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003761) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02003762 timer T := 3.0;
3763 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
3764 T.start;
3765 /* Expect RLL UNITDATA IND on RSL side */
3766 alt {
3767 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
3768 setverdict(pass);
3769 }
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003770 [] as_rsl_sacch_ind(exp_sacch);
3771 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02003772 [] T.timeout {
3773 setverdict(fail, "Timeout waiting for UNIT_DATA_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003774 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003775 }
Harald Weltee613f962018-04-18 22:38:16 +02003776 }
3777}
3778
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003779/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
3780private function f_data_mo(
3781 RslLinkId link_id,
3782 boolean p, uint3_t nr, uint3_t ns,
3783 octetstring l3,
3784 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003785 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003786) runs on ConnHdlr {
3787 timer T := 3.0;
3788 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
3789 T.start;
3790 /* Expect RLL DATA IND on RSL side */
3791 alt {
3792 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
3793 setverdict(pass);
3794 }
3795 [] as_rsl_sacch_ind(exp_sacch);
3796 [] as_rsl_any_ind(exp_any);
3797 [] T.timeout {
3798 setverdict(fail, "Timeout waiting for DATA_IND");
3799 mtc.stop;
3800 }
3801 }
3802}
3803
Harald Weltee613f962018-04-18 22:38:16 +02003804/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
3805function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
3806 f_l1_tune(L1CTL);
3807 f_est_dchan(true);
3808
3809 /* now we actually need to transmit some data both ways to check if the encryption works */
3810 var L1ctlDlMessage dl;
3811
Stefan Sperling603d98e2018-07-25 16:47:28 +02003812 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02003813 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3814
3815 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3816 f_unitdata_mt(link_id, l3);
3817
3818 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
3819 f_unitdata_mo(link_id, l3);
3820
3821 /* release the channel */
3822 f_rsl_chan_deact();
3823 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3824 f_rslem_unregister(0, g_chan_nr);
3825}
3826testcase TC_chan_act_a51() runs on test_CT {
3827 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3828 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3829 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3830}
3831testcase TC_chan_act_a52() runs on test_CT {
3832 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3833 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3834 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3835}
3836testcase TC_chan_act_a53() runs on test_CT {
3837 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3838 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3839 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3840}
3841
3842
3843/* Test unencrypted channel activation followed by explicit ENCR CMD later */
3844function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
3845 /* L3 payload doesn't matter, as it is passed transparently */
3846 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
3847 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
3848 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3849
3850 f_l1_tune(L1CTL);
3851
3852 /* first establish a dedicated channel in the clear */
3853 f_est_dchan(false);
3854
3855 /* Establish ABM */
3856 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3857
3858 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
3859 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
3860 /* expect the L3 to arrive still unencrypted on the MS side */
3861 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
3862
3863 /* configure L1 to apply ciphering */
3864 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
3865 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
3866
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003867 /* send first ciphered I-frame in response and expect it on RSL */
3868 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02003869
3870 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
3871 * and hence enable encryption also on the downlink */
3872
3873 /* expect bi-directional communication work in encrypted mode */
3874 f_unitdata_mo(link_id, f_rnd_octstring(15));
3875 f_unitdata_mt(link_id, f_rnd_octstring(15));
3876
3877 /* release the channel */
3878 f_rsl_chan_deact();
3879 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3880 f_rslem_unregister(0, g_chan_nr);
3881}
3882testcase TC_encr_cmd_a51() runs on test_CT {
3883 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3884 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3885 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3886}
3887testcase TC_encr_cmd_a52() runs on test_CT {
3888 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3889 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3890 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3891}
3892testcase TC_encr_cmd_a53() runs on test_CT {
3893 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3894 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3895 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3896}
3897
3898private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
3899 var LapdmFrame lf;
3900 var octetstring reenc;
3901
3902 /* decode the LAPDm frame */
3903 if (ischosen(exp_match.ab)) {
3904 lf.ab := dec_LapdmFrameAB(enc);
3905 } else {
3906 setverdict(fail, "unsupported frame type");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003907 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003908 }
3909
3910 /* check if decoder result matches expectation */
3911 if (not match(lf, exp_match)) {
3912 setverdict(fail, name, ": decoded LAPDm doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003913 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003914 } else {
3915 log(name, ": matched");
3916 setverdict(pass);
3917 }
3918
3919 /* test if re-encoded frame equals original input */
3920 reenc := enc_LapdmFrame(lf);
3921 if (enc != reenc) {
3922 setverdict(fail, name, ": re-encoded LAPDm frame doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003923 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003924 } else {
3925 setverdict(pass);
3926 }
3927}
3928
3929testcase TC_lapdm_selftest() runs on test_CT {
3930 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
3931 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
3932 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
3933 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
3934 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
3935 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
3936 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
3937}
3938
Stefan Sperling4880be42018-08-07 18:12:59 +02003939/***********************************************************************
3940 * DTX Related (see GSM 05.08, section 8.3)
3941 ***********************************************************************/
3942
3943/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
3944function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
3945 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
3946 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
3947 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
3948 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
3949}
3950function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
3951 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
3952 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
3953}
3954function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
3955 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
3956 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
3957 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
3958 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
3959}
3960function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
3961 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
3962 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
3963 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
3964 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
3965 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
3966 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
3967 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
3968 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
3969}
3970
3971function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
3972 var L1ctlDlMessage dl;
3973 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
3974 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
3975 var GsmFrameNumber first_fn;
3976 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003977 var integer nfill_frames_sacch := 0;
3978 var integer nfill_frames_nonsacch := 0;
3979 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02003980 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
3981 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003982 const integer frame_dtx_tchf_mod := 104;
3983 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
3984 * which operates in terms of blocks rather than frames. */
3985 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
3986 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02003987 timer T := 5.0;
3988
3989 f_l1_tune(L1CTL);
3990 RSL.clear;
3991 L1CTL.clear;
3992
3993 /* activate TCHF signalling channel */
3994 f_est_dchan(false);
3995
3996 T.start;
3997 alt {
3998 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3999 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4000 var octetstring l2 := dl.payload.data_ind.payload;
4001
4002 if (is_first_frame) {
4003 is_first_frame := false;
4004 first_fn := dl.dl_info.frame_nr;
4005 }
4006
4007 if (dl.dl_info.link_id.c == SACCH) {
4008 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4009 if (not match(l2_fill_frame_sacch, l2)) {
4010 repeat;
4011 }
4012 } else if (not match(l2_fill_frame, l2)) {
4013 repeat;
4014 }
4015
4016 if (dtxd) {
4017 if (not f_g_chan_is_tchf()) {
4018 T.stop;
4019 f_rsl_chan_deact();
4020 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4021 setverdict(fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!");
4022 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004023 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004024 T.stop;
4025 f_rsl_chan_deact();
4026 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004027
4028 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4029 * 2 SACCH, 1 TCH/F */
4030 expected_fill_frames := 3;
4031
4032 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4033 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4034 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
4035 setverdict(fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004036 } else {
4037 setverdict(pass);
4038 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004039 } else {
4040 if (dl.dl_info.link_id.c == SACCH) {
4041 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004042 repeat;
4043 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004044 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4045 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4046 * we should only see the subset of frames numbers which correspond to a block boundary.
4047 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4048 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4049 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4050 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4051 repeat;
4052 }
4053 }
4054 log("Received DTX TCH fill frame with bad frame number: ", fn,
4055 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4056 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4057 f_rsl_chan_deact();
4058 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4059 setverdict(fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004060 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004061 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004062 if (dl.dl_info.link_id.c == SACCH) {
4063 nfill_frames_sacch := nfill_frames_sacch + 1;
4064 } else {
4065 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4066 }
4067 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004068 T.stop;
4069 if (f_g_chan_is_tchf()) {
4070 /* Without DTX we can expect 25 fill frames for every 104 frames.
4071 * (24 FACCH + 1 SACCH filling) */
4072 expected_fill_frames := 25;
4073 } else if (f_g_chan_is_tchh()) {
4074 /* We can expect 2 fill frames for every 104 frames. */
4075 expected_fill_frames := 2;
4076 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4077 /* We can expect 5 fill frames for every 104 frames. */
4078 expected_fill_frames := 5;
4079 } else {
4080 f_rsl_chan_deact();
4081 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4082 setverdict(fail, "Unknown channel type");
4083 }
4084
4085 f_rsl_chan_deact();
4086 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004087
4088 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004089 setverdict(pass);
4090 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004091 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4092 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Stefan Sperling4880be42018-08-07 18:12:59 +02004093 setverdict(fail, "Not enough fill frames received");
4094 }
4095 } else {
4096 repeat;
4097 }
4098 }
4099 }
4100 [] L1CTL.receive { repeat; }
4101 [] T.timeout {
4102 f_rsl_chan_deact();
4103 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4104 setverdict(fail, "Timeout waiting for L2 fill frames on Um");
4105 mtc.stop;
4106 }
4107 }
4108}
4109
4110function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4111 f_test_l2_fill_frames(false);
4112}
4113
4114function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4115 f_test_l2_fill_frames(true);
4116}
4117
4118function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4119 var ConnHdlr vc_conn;
4120 var ConnHdlrPars pars;
4121 pars.t_guard := 60.0;
4122 f_init(testcasename());
4123 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4124 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4125 if (dtxd) {
4126 if (i >= 4) { /* DTX is only allowed on TCH/F */
4127 break;
4128 }
4129 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4130 } else {
4131 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4132 }
4133 vc_conn.done;
4134 }
4135}
4136
4137/* Verify that L2 fill frames are sent on TCH in signaling mode if
4138 * there is nothing to transmit while DTX is disabled on downlink. */
4139testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4140 f_tch_sign_l2_fill_frame(false);
4141}
4142
4143/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4144 * there is nothing to transmit while DTX is enabled on downlink. */
4145testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4146 f_tch_sign_l2_fill_frame(true);
4147}
Harald Welte0472ab42018-03-12 15:02:26 +01004148
4149/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4150/* protocol error as per 44.006 */
4151/* link layer failure (repetition of I-frame N200 times without ACK */
4152/* repetition of SABM or DISC N200 times without ACK */
4153/* receptiom of SABM in multi-frame established state */
4154
4155
4156
4157
Harald Welte883340c2018-02-28 18:59:29 +01004158
Harald Welte68e495b2018-02-25 00:05:57 +01004159/* TODO Areas:
4160
4161* channel activation
4162** with BS_Power / MS_Power, bypassing power control loop
4163** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004164** with timing advance from initial activation on
4165* mode modify
4166** encryption
4167** multirate
4168* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004169** unsupported algorithm
4170* handover detection
4171* MS Power Control
4172* BS Power Control
4173* Physical Context
Harald Welte43c54642018-09-15 17:47:04 +03004174* CCCH Load Indication for RACH
Harald Welte68e495b2018-02-25 00:05:57 +01004175* SMS Broadcast Req / Cmd / CBCH LOad Ind
4176* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004177* error handling
Harald Welte43c54642018-09-15 17:47:04 +03004178** discriminator error
Harald Welte68e495b2018-02-25 00:05:57 +01004179** type error
4180** sequence error
4181** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004182* PCU interface
4183** TIME_IND from BTS->PCU
4184** DATA_IND from BTS->PCU
4185** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004186
4187*/
Harald Welte70767382018-02-21 12:16:40 +01004188
4189control {
4190 execute( TC_chan_act_stress() );
4191 execute( TC_chan_act_react() );
4192 execute( TC_chan_deact_not_active() );
4193 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004194 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004195 execute( TC_sacch_filling() );
4196 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004197 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004198 execute( TC_sacch_multi_chg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004199 execute( TC_rach_content() );
4200 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004201 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004202 execute( TC_meas_res_sign_tchf() );
4203 execute( TC_meas_res_sign_tchh() );
4204 execute( TC_meas_res_sign_sdcch4() );
4205 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004206 execute( TC_meas_res_sign_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01004207 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004208 execute( TC_paging_imsi_80percent() );
4209 execute( TC_paging_tmsi_80percent() );
4210 execute( TC_paging_imsi_200percent() );
4211 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004212 execute( TC_rsl_protocol_error() );
4213 execute( TC_rsl_mand_ie_error() );
4214 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004215 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004216 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004217 execute( TC_si_sched_2bis() );
4218 execute( TC_si_sched_2ter() );
4219 execute( TC_si_sched_2ter_2bis() );
4220 execute( TC_si_sched_2quater() );
4221 execute( TC_si_sched_13() );
4222 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004223 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004224 execute( TC_ipa_crcx_twice_not_active() );
4225 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004226 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004227 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004228
4229 execute( TC_pcu_act_req() );
4230 execute( TC_pcu_act_req_wrong_ts() );
4231 execute( TC_pcu_act_req_wrong_bts() );
4232 execute( TC_pcu_act_req_wrong_trx() );
4233 execute( TC_pcu_deact_req() );
4234 execute( TC_pcu_deact_req_wrong_ts() );
4235 execute( TC_pcu_ver_si13() );
4236 execute( TC_pcu_data_req_wrong_bts() );
4237 execute( TC_pcu_data_req_wrong_trx() );
4238 execute( TC_pcu_data_req_wrong_ts() );
4239 execute( TC_pcu_data_req_ts_inactive() );
4240 execute( TC_pcu_data_req_pdtch() );
4241 execute( TC_pcu_data_req_ptcch() );
4242 execute( TC_pcu_data_req_agch() );
4243 execute( TC_pcu_data_req_imm_ass_pch() );
4244 execute( TC_pcu_rach_content() );
4245 execute( TC_pcu_paging_from_rsl() );
Harald Welte3d04ae62018-04-04 20:29:05 +02004246
4247 execute( TC_dyn_osmo_pdch_act_deact() );
4248 execute( TC_dyn_osmo_pdch_unsol_deact() );
4249 execute( TC_dyn_osmo_pdch_double_act() );
4250 execute( TC_dyn_osmo_pdch_tchf_act() );
4251 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004252 execute( TC_dyn_ipa_pdch_act_deact() );
4253 execute( TC_dyn_ipa_pdch_tchf_act() );
4254 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4255 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004256
4257 execute( TC_rll_est_ind() );
4258 execute( TC_rll_est_req_DCCH_3() );
4259 execute( TC_rll_est_req_ACCH_3() );
4260 execute( TC_rll_rel_ind_DCCH_0() );
4261 execute( TC_rll_rel_ind_DCCH_3() );
4262 execute( TC_rll_rel_ind_ACCH_0() );
4263 execute( TC_rll_rel_ind_ACCH_3() );
4264 execute( TC_rll_rel_req() );
4265 execute( TC_rll_unit_data_req_DCCH() );
4266 execute( TC_rll_unit_data_req_ACCH() );
4267 execute( TC_rll_unit_data_ind_DCCH() );
4268 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004269
4270 execute( TC_chan_act_a51() );
4271 execute( TC_chan_act_a52() );
4272 execute( TC_chan_act_a53() );
4273 execute( TC_encr_cmd_a51() );
4274 execute( TC_encr_cmd_a52() );
4275 execute( TC_encr_cmd_a53() );
4276
4277 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004278
4279 execute( TC_tch_sign_l2_fill_frame() );
4280 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Harald Welte70767382018-02-21 12:16:40 +01004281}
4282
4283
4284}