blob: dcdf32b34b366abdf67b99fd44e7b9a583fd8e24 [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;
8import from GSM_RR_Types all;
Harald Welte82ccef72018-02-25 16:17:33 +01009import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010010import from L1CTL_PortType all;
11import from L1CTL_Types all;
12import from LAPDm_Types all;
13import from Osmocom_CTRL_Adapter all;
14
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
38 * TS1 .. TS 4: TCH/F
39 * TS5 : TCH/H
40 * TS6 : SDCCH/8
41 * TS7 : PDCH
42 */
43
44modulepar {
45 charstring mp_rsl_ip := "127.0.0.2";
46 integer mp_rsl_port := 3003;
47 integer mp_trx0_arfcn := 871;
Harald Weltea4d8f352018-03-01 15:47:20 +010048 charstring mp_bb_trxc_ip := "127.0.0.1";
Harald Welteef3e1c92018-02-28 23:40:14 +010049 integer mp_bb_trxc_port := 6701;
Harald Welte883340c2018-02-28 18:59:29 +010050 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Harald Welted5684392018-03-10 18:22:04 +010051 integer mp_tolerance_rxqual := 1;
52 integer mp_tolerance_rxlev := 3;
Harald Welte70767382018-02-21 12:16:40 +010053}
54
Harald Welte629cc6b2018-03-11 17:19:05 +010055type record of RslChannelNr ChannelNrs;
56
Harald Welte70767382018-02-21 12:16:40 +010057type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010058 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010059 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010060 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010061 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010062 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010063 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010064
65 /* L1CTL port (for classic tests) */
66 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010067
Harald Welte54a2a2d2018-02-26 09:14:05 +010068 /* TRXC port (for classic tests) */
69 port TRXC_CODEC_PT BB_TRXC;
70 var integer g_bb_trxc_conn_id;
71
Harald Welte8da48242018-02-27 20:41:32 +010072 port TELNETasp_PT BTSVTY;
73
Harald Welte883340c2018-02-28 18:59:29 +010074 /* PCU Interface of BTS */
75 port PCUIF_CODEC_PT PCU;
76 var integer g_pcu_conn_id;
77 /* Last PCU INFO IND we received */
78 var PCUIF_Message g_pcu_last_info;
79
Harald Welte48494ca2018-02-25 16:59:50 +010080 /* SI configuration */
81 var SystemInformationConfig si_cfg := {
82 bcch_extended := false,
83 si1_present := false,
84 si2bis_present := false,
85 si2ter_present := false,
86 si2quater_present := false,
87 si7_present := false,
88 si8_present := false,
89 si9_present := false,
90 si13_present := false,
91 si13alt_present := false,
92 si15_present := false,
93 si16_present := false,
94 si17_present := false,
95 si2n_present := false,
96 si21_present := false,
97 si22_present := false
98 };
Harald Welte629cc6b2018-03-11 17:19:05 +010099
100 /* all logical channels available on the BTS */
101 var ChannelNrs g_AllChannels;
Harald Welte70767382018-02-21 12:16:40 +0100102}
103
104/* an individual call / channel */
105type component ConnHdlr extends RSL_DchanHdlr {
106 port L1CTL_PT L1CTL;
107
108 port TRXC_CODEC_PT BB_TRXC;
109 var integer g_bb_trxc_conn_id;
110
111 timer g_Tguard;
112 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
113
114 var ConnHdlrPars g_pars;
115 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100116 var boolean g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +0100117}
118
119function f_init_rsl(charstring id) runs on test_CT {
120 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
121 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
122
123 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
124 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
125 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
126
127 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
128 vc_RSL.start(RSL_Emulation.main(false));
129}
130
131type record ConnHdlrPars {
132 RslChannelNr chan_nr,
133 RSL_IE_ChannelMode chan_mode,
134 float t_guard,
135 ConnL1Pars l1_pars
136}
137
Harald Welte82ccef72018-02-25 16:17:33 +0100138template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100139 max_retrans := RACH_MAX_RETRANS_7,
140 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100141 cell_barr_access := false,
142 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100143 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100144};
145
Harald Weltef10153f2018-02-25 16:34:05 +0100146template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100147 cell_resel_hyst_2dB := 2,
148 ms_txpwr_max_cch := 7,
Harald Weltef10153f2018-02-25 16:34:05 +0100149 acs := '0'B,
150 neci := true,
151 rxlev_access_min := 0
152}
153
154template (value) LocationAreaIdentification ts_LAI_default := {
155 mcc_mnc := '262F42'H,
156 lac := 42
157}
158
Harald Welte7484fc42018-02-24 14:09:45 +0100159/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100160template (value) SystemInformation ts_SI3_default := {
161 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100162 payload := {
163 si3 := {
164 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100165 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100166 ctrl_chan_desc := {
167 msc_r99 := true,
168 att := true,
169 bs_ag_blks_res := 1,
170 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100171 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100172 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
173 spare := '00'B,
174 bs_pa_mfrms := 0, /* 2 multiframes */
175 t3212 := 1 /* 6 minutes */
176 },
Harald Welte82ccef72018-02-25 16:17:33 +0100177 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100178 dn_ind := false,
179 pwrc := false,
180 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100181 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100182 },
Harald Weltef10153f2018-02-25 16:34:05 +0100183 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100184 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100185 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100186 }
187 }
188}
Harald Welte70767382018-02-21 12:16:40 +0100189
Harald Weltef8df4cb2018-03-10 15:15:08 +0100190template (value) SystemInformation ts_SI2_default := {
191 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100192 payload := {
193 si2 := {
194 bcch_freq_list := '00000000000000000000000000000000'O,
195 ncc_permitted := '11111111'B,
196 rach_control := ts_RachCtrl_default
197 }
198 }
199}
200
Harald Weltef8df4cb2018-03-10 15:15:08 +0100201template (value) SystemInformation ts_SI4_default := {
202 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100203 payload := {
204 si4 := {
205 lai := ts_LAI_default,
206 cell_sel_par := ts_CellSelPar_default,
207 rach_control := ts_RachCtrl_default,
208 cbch_chan_desc := omit,
209 cbch_mobile_alloc := omit,
210 rest_octets := ''O
211 }
212 }
213}
214
215function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
216runs on test_CT {
217 log("Setting ", rsl_si_type, ": ", si_enc);
218 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
219}
220
221function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
222runs on test_CT {
223 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
224 log("Setting ", rsl_si_type, ": ", si_dec);
225 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
226}
227
Harald Welte8da48242018-02-27 20:41:32 +0100228private function f_init_vty(charstring id) runs on test_CT {
229 map(self:BTSVTY, system:BTSVTY);
230 f_vty_set_prompts(BTSVTY);
231 f_vty_transceive(BTSVTY, "enable");
232}
233
Harald Welte883340c2018-02-28 18:59:29 +0100234/* PCU socket may at any time receive a new INFO.ind */
235private altstep as_pcu_info_ind() runs on test_CT {
236 var PCUIF_send_data sd;
237 [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> value sd {
238 g_pcu_last_info := sd.data;
239 repeat;
240 }
241}
242
243private function f_init_pcu(charstring id) runs on test_CT {
244 timer T := 2.0;
245 var PCUIF_send_data sd;
246 map(self:PCU, system:PCU);
Harald Welte84271622018-03-10 17:21:03 +0100247 if (mp_pcu_socket == "") {
248 g_pcu_conn_id := -1;
249 return;
250 }
Harald Welte883340c2018-02-28 18:59:29 +0100251 g_pcu_conn_id := f_pcuif_connect(PCU, mp_pcu_socket);
252
253 T.start;
254 alt {
255 [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> value sd {
256 g_pcu_last_info := sd.data;
257 }
258 [] T.timeout {
259 setverdict(fail, "Timeout waiting for PCU INFO_IND");
260 self.stop;
261 }
262 }
263}
264
Harald Welte70767382018-02-21 12:16:40 +0100265/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100266function f_init(charstring id := "BTS-Test") runs on test_CT {
Harald Welte629cc6b2018-03-11 17:19:05 +0100267 g_AllChannels := {
268 /* TS 1..4: TCH/F */
269 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
270 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
271 /* TS 5: TCH/H */
272 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
273 /* TS 0: SDCCH/4 */
274 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
275 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
276 /* TS 6: SDCCH/8 */
277 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
278 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
279 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
280 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
281 };
282
Harald Welte70767382018-02-21 12:16:40 +0100283 f_init_rsl(id);
284 RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
Harald Welte2d142592018-02-25 13:19:44 +0100285 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100286 f_init_vty(id);
Harald Welte7484fc42018-02-24 14:09:45 +0100287
288 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100289 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
290 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
291 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
292 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100293
Harald Welte883340c2018-02-28 18:59:29 +0100294 f_init_pcu(id);
295
Harald Welte84271622018-03-10 17:21:03 +0100296 if (mp_bb_trxc_port != -1) {
297 var TrxcMessage ret;
298 /* start with a default moderate timing offset equalling TA=2 */
299 f_main_trxc_connect();
300 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
301 }
Harald Welte70767382018-02-21 12:16:40 +0100302}
303
Harald Welte294b0a22018-03-10 23:26:48 +0100304function f_shutdown() runs on test_CT {
305 /* shut down all "externally interfaced" components first to avoid unclean shutdown */
306 vc_IPA.stop;
307 vc_RSL.stop;
308}
309
Harald Welte68e495b2018-02-25 00:05:57 +0100310/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
311function f_init_l1ctl() runs on test_CT {
312 map(self:L1CTL, system:L1CTL);
313 f_connect_reset(L1CTL);
314}
315
Harald Welte70767382018-02-21 12:16:40 +0100316type function void_fn(charstring id) runs on ConnHdlr;
317
318/* create a new test component */
319function f_start_handler(void_fn fn, ConnHdlrPars pars)
320runs on test_CT return ConnHdlr {
321 var charstring id := testcasename();
322 var ConnHdlr vc_conn;
323
324 vc_conn := ConnHdlr.create(id);
325 /* connect to RSL Emulation main component */
326 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
327 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
328
329 vc_conn.start(f_handler_init(fn, id, pars));
330 return vc_conn;
331}
332
Harald Welte7484fc42018-02-24 14:09:45 +0100333template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
334 streamId := sid,
335 rsl := rsl
336}
337
338template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
339 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
340 streamId := sid,
341 rsl := rsl
342}
343
Harald Welte70767382018-02-21 12:16:40 +0100344private altstep as_Tguard() runs on ConnHdlr {
345 [] g_Tguard.timeout {
346 setverdict(fail, "Tguard timeout");
347 self.stop;
348 }
349}
350
Harald Welte68e495b2018-02-25 00:05:57 +0100351private function f_l1_tune(L1CTL_PT L1CTL) {
Harald Welte70767382018-02-21 12:16:40 +0100352 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED);
353}
354
355private function f_trxc_connect() runs on ConnHdlr {
356 map(self:BB_TRXC, system:BB_TRXC);
357 var Result res;
Harald Weltea4d8f352018-03-01 15:47:20 +0100358 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
359 "", -1, -1, {udp:={}}, {});
Harald Welte70767382018-02-21 12:16:40 +0100360 g_bb_trxc_conn_id := res.connId;
361}
362
363private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100364 var TrxcMessage ret;
365 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100366}
367
368private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100369 var TrxcMessage ret;
370 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100371}
372
373/* first function started in ConnHdlr component */
374private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
375runs on ConnHdlr {
376 g_pars := pars;
377 g_chan_nr := pars.chan_nr;
378
379 map(self:L1CTL, system:L1CTL);
380 f_connect_reset(L1CTL);
381
Harald Welte84271622018-03-10 17:21:03 +0100382 if (mp_bb_trxc_port != -1) {
383 f_trxc_connect();
384 }
Harald Welte70767382018-02-21 12:16:40 +0100385
386 g_Tguard.start(pars.t_guard);
387 activate(as_Tguard());
388
389 f_rslem_register(0, pars.chan_nr);
390
391 /* call the user-supplied test case function */
392 fn.apply(id);
393}
394
Harald Welte21240e62018-03-11 21:43:35 +0100395function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
396 boolean ignore_other := false)
Harald Welte1eba3742018-02-25 12:48:14 +0100397runs on ConnHdlr {
398 timer T := 3.0;
399 RSL.send(tx);
400 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100401 alt {
Harald Welte1eba3742018-02-25 12:48:14 +0100402 [] RSL.receive(exp_rx) {
403 T.stop;
404 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100405 }
Harald Welte1eba3742018-02-25 12:48:14 +0100406 [] T.timeout {
407 setverdict(fail, "Timeout expecting " & id);
408 self.stop;
409 }
Harald Welte21240e62018-03-11 21:43:35 +0100410 [not ignore_other] as_l1_sacch();
411 [not ignore_other] as_meas_res();
412 [not ignore_other] as_l1_dcch();
413 [not ignore_other] RSL.receive {
Harald Welte1eba3742018-02-25 12:48:14 +0100414 setverdict(fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100415 }
Harald Welte21240e62018-03-11 21:43:35 +0100416 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100417 }
418}
419
Harald Welte1eba3742018-02-25 12:48:14 +0100420function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr {
421 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
422 "RSL CHAN ACT");
423}
424
Harald Welte70767382018-02-21 12:16:40 +0100425function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100426 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 +0100427 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100428}
429
Harald Welte70767382018-02-21 12:16:40 +0100430private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
431 template RSL_IE_ChannelMode chan_mode,
432 float t_guard := 20.0) := {
433 chan_nr := valueof(chan_nr),
434 chan_mode := valueof(chan_mode),
435 t_guard := t_guard,
436 l1_pars := {
437 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100438 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100439 meas_ul := {
440 full := {
441 rxlev := dbm2rxlev(-53),
442 rxqual := 0
443 },
444 sub := {
445 rxlev := dbm2rxlev(-53),
446 rxqual := 0
447 }
448 },
449 timing_offset_256syms := 0,
450 bs_power_level := 0,
451 ms_power_level := 0,
452 ms_actual_ta := 0
453 }
454}
455
Harald Welte93640c62018-02-25 16:59:33 +0100456/***********************************************************************
457 * Channel Activation / Deactivation
458 ***********************************************************************/
459
Harald Welte70767382018-02-21 12:16:40 +0100460/* Stress test: Do 500 channel activations/deactivations in rapid succession */
461function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
462 for (var integer i := 0; i < 500; i := i+1) {
463 f_rsl_chan_act(g_pars.chan_mode);
464 f_rsl_chan_deact();
465 }
466 setverdict(pass);
467}
468testcase TC_chan_act_stress() runs on test_CT {
469 var ConnHdlr vc_conn;
470 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
471 f_init(testcasename());
472 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
473 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100474 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100475}
476
477/* Test if re-activation of an already active channel fails as expected */
478function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
479 f_rsl_chan_act(g_pars.chan_mode);
480 /* attempt to activate the same lchan again -> expect reject */
481 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
482 alt {
483 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
484 setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
485 }
486 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
487 setverdict(pass);
488 }
489 }
490 f_rsl_chan_deact();
491}
492testcase TC_chan_act_react() runs on test_CT {
493 var ConnHdlr vc_conn;
494 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100495 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100496 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
497 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100498 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100499}
500
501/* Attempt to de-activate a channel that's not active */
502function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
503 timer T := 3.0;
504 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
505 T.start;
506 alt {
507 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
508 setverdict(pass);
509 }
510 [] T.timeout {
511 setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
512 }
513 }
514}
515testcase TC_chan_deact_not_active() runs on test_CT {
516 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100517 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100518 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
519 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100520 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100521}
522
523/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
524function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
525 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
526 alt {
527 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
528 setverdict(fail, "Unexpected CHAN ACT ACK");
529 }
530 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
531 setverdict(pass);
532 }
533 }
534}
535private type record WrongChanNrCase {
536 RslChannelNr chan_nr,
537 charstring description
538}
539private type record of WrongChanNrCase WrongChanNrCases;
540private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
541 chan_nr := chan_nr,
542 description := desc
543}
544
545testcase TC_chan_act_wrong_nr() runs on test_CT {
546 var ConnHdlr vc_conn;
547 var ConnHdlrPars pars;
548
Harald Welte294b0a22018-03-10 23:26:48 +0100549 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100550
551 var WrongChanNrCases wrong := {
552 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
553 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
554 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
555 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
556 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
557 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
558 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
559 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
560 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
561 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
562 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
563 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
564 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
565 };
566
567 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
568 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
569 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
570 vc_conn.done;
571 }
Harald Welte294b0a22018-03-10 23:26:48 +0100572 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100573}
574
Harald Welte93640c62018-02-25 16:59:33 +0100575/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100576 * SACCH handling
577 ***********************************************************************/
578
579private function f_exp_sacch(boolean exp) runs on ConnHdlr {
580 timer T_sacch := 3.0;
581 T_sacch.start;
582 alt {
583 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
584 setverdict(fail, "Received SACCH when not expecting it");
585 }
586 [not exp] T_sacch.timeout {
587 setverdict(pass);
588 }
589 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
590 setverdict(pass);
591 }
592 [exp] T_sacch.timeout {
593 setverdict(fail, "Timeout waiting for SACCH on ", g_chan_nr);
594 }
595 [] L1CTL.receive { repeat; }
596 [] RSL.receive { repeat; }
597 }
598}
599
600/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
601private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
602 f_l1_tune(L1CTL);
603 RSL.clear;
604
605 /* activate the logical channel */
606 f_est_dchan();
607 L1CTL.clear;
608
609 /* check that SACCH actually are received as expected */
610 f_exp_sacch(true);
611
612 /* deactivate SACCH on the logical channel */
613 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
614 f_sleep(1.0);
615 L1CTL.clear;
616
617 /* check that no SACCH are received anymore */
618 f_exp_sacch(false);
619
620 /* release the channel */
621 f_rsl_chan_deact();
622 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
623}
624testcase TC_deact_sacch() runs on test_CT {
625 var ConnHdlr vc_conn;
626 var ConnHdlrPars pars;
627 f_init();
628 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
629 //for (var integer i := 0; i < 1; i := i+1) {
630 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
631 log(testcasename(), ": Starting for ", g_AllChannels[i]);
632 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
633 vc_conn.done;
634 }
635 /* TODO: do the above in parallel, rather than sequentially? */
636 f_shutdown();
637}
638
639/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
640/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
641/* Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
642
643
644/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100645 * RACH Handling
646 ***********************************************************************/
647
Harald Welte8c24c2b2018-02-26 08:31:31 +0100648/* like L1SAP_IS_PACKET_RACH */
649private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100650 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100651 return true;
652 }
653 return false;
654}
655
656/* generate a random RACH for circuit-switched */
657private function f_rnd_ra_cs() return OCT1 {
658 var OCT1 ra;
659 do {
660 ra := f_rnd_octstring(1);
661 } while (ra_is_ps(ra));
662 return ra;
663}
664
Harald Welte883340c2018-02-28 18:59:29 +0100665/* generate a random RACH for packet-switched */
666private function f_rnd_ra_ps() return OCT1 {
667 var OCT1 ra;
668 do {
669 ra := f_rnd_octstring(1);
670 } while (not ra_is_ps(ra));
671 return ra;
672}
673
Harald Welte8c24c2b2018-02-26 08:31:31 +0100674/* Send 1000 RACH requests and check their RA+FN on the RSL side */
675testcase TC_rach_content() runs on test_CT {
676 f_init(testcasename());
677 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +0100678 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +0100679
Harald Welte8c24c2b2018-02-26 08:31:31 +0100680 var GsmFrameNumber fn_last := 0;
681 for (var integer i := 0; i < 1000; i := i+1) {
682 var OCT1 ra := f_rnd_ra_cs();
683 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
684 if (fn == fn_last) {
685 setverdict(fail, "Two RACH in same FN?!?");
686 self.stop;
687 }
688 fn_last := fn;
689
690 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +0100691 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +0100692 alt {
693 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
694 T.stop;
695 }
696 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
697 setverdict(fail, "Unexpected CHAN RQD");
698 self.stop;
699 }
700 [] RSL_CCHAN.receive { repeat; }
701 [] T.timeout {
702 setverdict(fail, "Timeout waiting for CHAN RQD");
703 self.stop;
704 }
705 }
706 }
707 setverdict(pass);
Harald Welte294b0a22018-03-10 23:26:48 +0100708 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100709}
Harald Welte8c24c2b2018-02-26 08:31:31 +0100710
711/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
712testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +0100713 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +0100714 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +0100715 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +0100716 f_l1_tune(L1CTL);
717
718 var GsmFrameNumber fn_last := 0;
719 for (var integer i := 0; i < 1000; i := i+1) {
720 var OCT1 ra := f_rnd_ra_cs();
721 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
722 if (fn == fn_last) {
723 setverdict(fail, "Two RACH in same FN?!?");
724 self.stop;
725 }
726 fn_last := fn;
727 }
728 var integer rsl_chrqd := 0;
729 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +0100730 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +0100731 alt {
732 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
733 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +0100734 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +0100735 repeat;
736 }
737 [] RSL_CCHAN.receive { repeat; }
738 [] T.timeout { }
739 }
740 if (rsl_chrqd == 1000) {
741 setverdict(pass);
742 } else {
743 setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH");
744 }
Harald Welte294b0a22018-03-10 23:26:48 +0100745 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100746}
747
Harald Welte54a2a2d2018-02-26 09:14:05 +0100748private function f_main_trxc_connect() runs on test_CT {
749 map(self:BB_TRXC, system:BB_TRXC);
750 var Result res;
Harald Welted3a88a62018-03-01 16:04:52 +0100751 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
752 "", -1, -1, {udp:={}}, {});
Harald Welte54a2a2d2018-02-26 09:14:05 +0100753 g_bb_trxc_conn_id := res.connId;
754}
755
756private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100757 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100758 /* tell fake_trx to use a given timing offset for all bursts */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100759 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +0100760 f_sleep(0.5);
761
762 /* Transmit RACH request + wait for confirmation */
763 var OCT1 ra := f_rnd_ra_cs();
764 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
765
766 /* Check for expected result */
767 timer T := 1.5;
768 T.start;
769 alt {
770 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
771 setverdict(pass);
772 }
773 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welteb3e30942018-03-02 10:33:42 +0100774 setverdict(fail, "RACH passed but was expected to be dropped: ", toffs256);
Harald Welte54a2a2d2018-02-26 09:14:05 +0100775 }
776 [] RSL_CCHAN.receive { repeat; }
777 [not expect_pass] T.timeout {
778 setverdict(pass);
779 }
780 [expect_pass] T.timeout {
781 setverdict(fail, "Timeout waiting for CHAN RQD");
782 }
783 }
784}
785
786/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
787testcase TC_rach_max_ta() runs on test_CT {
788 f_init(testcasename());
789 f_init_l1ctl();
790 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +0100791 f_sleep(1.0);
792
793 /* default max-ta is 63 (full range of GSM timing advance */
794
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +0700795 /* We allow early arrival up to 2 symbols */
796 f_rach_toffs(-1*256, true);
797 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +0100798 f_rach_toffs(-10*256, false);
799
800 /* 0 / 32 / 63 bits is legal / permitted */
801 f_rach_toffs(0, true);
802 f_rach_toffs(32*256, true);
803 f_rach_toffs(63*256, true);
804
805 /* more than 63 bits is not legal / permitted */
806 f_rach_toffs(64*256, false);
807 f_rach_toffs(127*256, false);
Harald Welte294b0a22018-03-10 23:26:48 +0100808 f_shutdown();
Harald Welte54a2a2d2018-02-26 09:14:05 +0100809}
Harald Welte8c24c2b2018-02-26 08:31:31 +0100810
Harald Welte93640c62018-02-25 16:59:33 +0100811/***********************************************************************
812 * Measurement Processing / Reporting
813 ***********************************************************************/
814
Harald Welte70767382018-02-21 12:16:40 +0100815template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
816 spare := '0'B,
817 lpd := 0,
818 sapi := sapi,
819 c_r := c_r,
820 ea := true
821}
822
823template LapdmFrameB ts_LAPDm_B(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
824 addr := ts_LapdmAddr(sapi, c_r),
825 ctrl := t_LapdmCtrlUI(p),
826 len := 0, /* overwritten */
827 m := false,
828 el := 1,
829 payload := pl
830}
831
832/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
833altstep as_l1_sacch() runs on ConnHdlr {
834 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +0100835 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +0100836 log("SACCH received: ", l1_dl.payload.data_ind.payload);
837 var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit));
838 var LapdmFrameB lb := valueof(ts_LAPDm_B(0, false, false, enc_GsmRrL3Message(meas_rep)));
839 log("LAPDm: ", lb);
840 var octetstring pl := '0000'O & enc_LapdmFrameB(lb);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100841 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_SACCH(0), pl));
Harald Welte70767382018-02-21 12:16:40 +0100842 repeat;
843 }
844}
845
846altstep as_l1_dcch() runs on ConnHdlr {
847 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +0100848 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +0100849 log("DCCH received: ", l1_dl.payload.data_ind.payload);
850 var octetstring pl := '010301'O;
Harald Weltef8df4cb2018-03-10 15:15:08 +0100851 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), pl));
Harald Welte70767382018-02-21 12:16:40 +0100852 repeat;
853 }
854}
855
856type record MeasElem {
857 uint6_t rxlev,
858 uint3_t rxqual
859}
860
861type record MeasElemFS {
862 MeasElem full,
863 MeasElem sub
864}
865
866type record ConnL1Pars {
867 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +0100868 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +0100869 MeasElemFS meas_ul,
870 int16_t timing_offset_256syms,
871 uint5_t bs_power_level,
872 uint5_t ms_power_level,
873 uint8_t ms_actual_ta
874}
875
876/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
877private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
878 return 63 + (toffs256s/256);
879}
880
Harald Welted5684392018-03-10 18:22:04 +0100881private function f_max(integer a, integer b) return integer {
882 if (a > b) {
883 return a;
884 } else {
885 return b;
886 }
887}
888
889private function f_min(integer a, integer b) return integer {
890 if (a < b) {
891 return a;
892 } else {
893 return b;
894 }
895}
896
897/* compute negative tolerance val-tolerance, ensure >= min */
898private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
899 val := val - tolerance;
900 return f_max(val, min);
901}
902
903/* compute positive tolerance val+tolerance, ensure <= max */
904private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
905 val := val + tolerance;
906 return f_min(val, max);
907}
908
909/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
910private function f_tolerance(integer val, integer min, integer max, integer tolerance)
911return template integer {
912 var template integer ret;
913 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
914 return ret;
915}
916
917
Harald Welte70767382018-02-21 12:16:40 +0100918/* build a template for matching measurement results against */
919private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
920 var ConnL1Pars l1p := g_pars.l1_pars;
921 var template RSL_IE_UplinkMeas ul_meas := {
922 len := 3,
923 rfu := '0'B,
924 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +0100925 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +0100926 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +0100927 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +0100928 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +0100929 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
930 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +0100931 supp_meas_info := omit
932 };
Harald Welte685d5982018-02-27 20:42:05 +0100933 if (l1p.toa256_enabled) {
934 ul_meas.len := 5;
935 ul_meas.supp_meas_info := int2oct(l1p.timing_offset_256syms, 2);
936 }
Harald Welte70767382018-02-21 12:16:40 +0100937 /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */
938 ul_meas.rxlev_f_u := ?;
939 ul_meas.rxlev_s_u := ?;
940 ul_meas.rxq_f_u := ?;
941 ul_meas.rxq_s_u := ?;
942 var template RSL_IE_BS_Power bs_power := {
943 reserved := 0,
944 epc := false,
945 fpc := false,
946 power_level := l1p.bs_power_level
947 };
948 var template RSL_IE_L1Info l1_info := {
949 ms_power_lvl := l1p.ms_power_level,
950 fpc := false,
951 reserved := 0,
952 actual_ta := l1p.ms_actual_ta
953 };
954 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
955 var template uint8_t t_toffs := (offs-1 .. offs+1); /* some tolerance */
956 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
957 ?, t_toffs);
958}
959
960/* verify we regularly receive measurement reports with incrementing numbers */
961altstep as_meas_res() runs on ConnHdlr {
962 var RSL_Message rsl;
963 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
964 /* increment counter of next to-be-expected meas rep */
965 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
966 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +0100967 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +0100968 repeat;
969 }
970 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +0100971 /* increment counter of next to-be-expected meas rep */
972 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
973 if (g_first_meas_res) {
974 g_first_meas_res := false;
975 repeat;
976 } else {
977 setverdict(fail, "Received unspecific MEAS RES ", rsl);
978 self.stop;
979 }
Harald Welte70767382018-02-21 12:16:40 +0100980 }
981 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
982 setverdict(fail, "Received unexpected MEAS RES ", rsl);
983 self.stop;
984 }
985 [] g_Tmeas_exp.timeout {
986 setverdict(fail, "Didn't receive expected measurement result")
987 self.stop;
988 }
989}
990
991/* Establish dedicated channel: L1CTL + RSL side */
992private function f_est_dchan() runs on ConnHdlr {
993 var GsmFrameNumber fn;
994 var ImmediateAssignment imm_ass;
995 var integer ra := 23;
996
997 fn := f_L1CTL_RACH(L1CTL, ra);
998 /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
999 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
1000
1001 /* Activate channel on BTS side */
1002 f_rsl_chan_act(g_pars.chan_mode);
1003
1004 /* Send IMM.ASS via CCHAN */
1005 var ChannelDescription ch_desc := {
1006 chan_nr := g_pars.chan_nr,
1007 tsc := 7,
1008 h := false,
1009 arfcn := mp_trx0_arfcn,
1010 maio_hsn := omit
1011 };
1012 var MobileAllocation ma := {
1013 len := 0,
1014 ma := ''B
1015 };
1016 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1017 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1018
1019 /* receive IMM.ASS on MS side */
1020 var ImmediateAssignment ia_um;
1021 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1022 /* enable dedicated mode */
1023 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltefa45e9e2018-03-10 18:59:03 +01001024
1025 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001026}
1027
1028/* establish DChan, verify existance + contents of measurement reports */
1029function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001030 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001031 RSL.clear;
1032
Harald Welte5398d5e2018-03-10 19:00:24 +01001033 if (mp_bb_trxc_port != -1) {
1034 g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100);
1035 f_trxc_fake_rssi(100);
Harald Welte70767382018-02-21 12:16:40 +01001036
Harald Welte5398d5e2018-03-10 19:00:24 +01001037 g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */
1038 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1039 } else {
1040 g_pars.l1_pars.timing_offset_256syms := 0; /* FIXME */
1041 g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-55); /* FIXME */
1042 }
1043 g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev;
Harald Welte70767382018-02-21 12:16:40 +01001044
1045 f_est_dchan();
1046
1047 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1048 * RSL measurement reports on Abis side */
1049 timer T := 8.0;
1050 T.start;
1051 alt {
1052 [] as_l1_sacch();
1053 [] as_meas_res();
1054 [] as_l1_dcch();
1055 [] L1CTL.receive { repeat; }
1056 [g_Tmeas_exp.running] T.timeout {
1057 /* as_meas_res() would have done setverdict(fail) / self.stop in case
1058 * of any earlier errors, so if we reach this timeout, we're good */
1059 setverdict(pass);
1060 }
1061 [] T.timeout {
1062 setverdict(fail, "No MEAS RES received at all");
1063 }
1064 }
1065 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001066 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001067}
1068testcase TC_meas_res_sign_tchf() runs on test_CT {
1069 var ConnHdlr vc_conn;
1070 var ConnHdlrPars pars;
1071 f_init(testcasename());
1072 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1073 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1074 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1075 vc_conn.done;
1076 }
Harald Welte294b0a22018-03-10 23:26:48 +01001077 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001078}
1079testcase TC_meas_res_sign_tchh() runs on test_CT {
1080 var ConnHdlr vc_conn;
1081 var ConnHdlrPars pars;
1082 f_init(testcasename());
1083 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1084 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1085 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1086 vc_conn.done;
1087 }
Harald Welte294b0a22018-03-10 23:26:48 +01001088 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001089}
1090testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1091 var ConnHdlr vc_conn;
1092 var ConnHdlrPars pars;
1093 f_init(testcasename());
1094 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1095 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1096 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1097 vc_conn.done;
1098 }
Harald Welte294b0a22018-03-10 23:26:48 +01001099 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001100}
1101testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1102 var ConnHdlr vc_conn;
1103 var ConnHdlrPars pars;
1104 f_init(testcasename());
1105 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1106 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1107 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1108 vc_conn.done;
1109 }
Harald Welte294b0a22018-03-10 23:26:48 +01001110 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001111}
Harald Welte685d5982018-02-27 20:42:05 +01001112testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1113 var ConnHdlr vc_conn;
1114 var ConnHdlrPars pars;
1115 f_init(testcasename());
1116 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1117 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1118 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1119 pars.l1_pars.toa256_enabled := true;
1120 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1121 vc_conn.done;
1122 }
Harald Welte294b0a22018-03-10 23:26:48 +01001123 f_shutdown();
Harald Welte685d5982018-02-27 20:42:05 +01001124}
1125
Harald Welte70767382018-02-21 12:16:40 +01001126
1127/* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND */
1128private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001129 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001130 RSL.clear;
1131
1132 f_est_dchan();
1133 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001134 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001135
1136 timer T := 40.0;
1137 T.start;
1138 alt {
1139 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1140 setverdict(pass)
1141 }
1142 [] RSL.receive { repeat };
1143 [] T.timeout {
1144 setverdict(fail, "No CONN FAIL IND received");
1145 }
1146 }
1147 f_rsl_chan_deact();
1148}
1149testcase TC_conn_fail_crit() runs on test_CT {
1150 var ConnHdlr vc_conn;
1151 var ConnHdlrPars pars;
1152 f_init(testcasename());
1153 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1154 pars.t_guard := 60.0;
1155 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1156 vc_conn.done;
1157}
1158
Harald Welte93640c62018-02-25 16:59:33 +01001159/***********************************************************************
1160 * Paging
1161 ***********************************************************************/
1162
Harald Welte68e495b2018-02-25 00:05:57 +01001163function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1164 if (tmsi == 'FFFFFFFF'O) {
1165 return true;
1166 } else {
1167 return false;
1168 }
1169}
Harald Welte70767382018-02-21 12:16:40 +01001170
Harald Welte68e495b2018-02-25 00:05:57 +01001171altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids)
1172runs on test_CT {
1173 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001174 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001175 repeat;
1176 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001177 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001178 var octetstring without_plen :=
1179 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1180 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
1181 if (match(rr, tr_PAGING_REQ1)) {
1182 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1183 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1184 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1185 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1186 }
1187 } else if (match(rr, tr_PAGING_REQ2)) {
1188 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1189 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1190 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1191 }
1192 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1193 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1194 }
1195 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1196 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1197 }
1198 } else if (match(rr, tr_PAGING_REQ3)) {
1199 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1200 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1201 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1202 }
1203 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1204 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1205 }
1206 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1207 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1208 }
1209 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1210 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1211 }
1212 }
1213 repeat;
1214 }
1215}
1216
1217type record PagingTestCfg {
1218 boolean combined_ccch,
1219 integer bs_ag_blks_res,
1220 float load_factor,
1221 boolean exp_load_ind,
1222 boolean exp_overload,
1223 boolean use_tmsi
1224}
1225
1226type record PagingTestState {
1227 integer num_paging_sent,
1228 integer num_paging_rcv_msgs,
1229 integer num_paging_rcv_ids,
1230 integer num_overload
1231}
1232
1233/* receive + ignore RSL RF RES IND */
1234altstep as_rsl_res_ind() runs on test_CT {
1235 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1236 repeat;
1237 }
1238}
1239
1240/* Helper function for paging related testing */
1241private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1242 f_init(testcasename());
1243 f_init_l1ctl();
1244 f_l1_tune(L1CTL);
1245
1246 var PagingTestState st := {
1247 num_paging_sent := 0,
1248 num_paging_rcv_msgs := 0,
1249 num_paging_rcv_ids := 0,
1250 num_overload := 0
1251 };
1252
1253 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1254 var float max_pch_imsi_per_sec;
1255 if (cfg.use_tmsi) {
1256 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1257 } else {
1258 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1259 }
1260 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1261 var float interval := 1.0 / pch_blocks_per_sec;
1262 log("pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
1263
1264 for (var integer i := 0; i < float2int(20.0/interval); i := i+1) {
1265 /* build mobile Identity */
1266 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1267 if (cfg.use_tmsi) {
1268 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1269 } else {
1270 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
1271 }
1272 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1273 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1274
1275 /* Send RSL PAGING COMMAND */
1276 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
1277 st.num_paging_sent := st.num_paging_sent + 1;
1278
1279 /* Wait for interval to next PAGING COMMAND */
1280 timer T_itv := interval;
1281 T_itv.start;
1282 alt {
1283 /* check for presence of CCCH LOAD IND (paging load) */
1284 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1285 st.num_overload := st.num_overload + 1;
1286 repeat;
1287 }
1288 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1289 setverdict(fail, "Unexpected PCH Overload");
1290 }
1291 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1292 log("Rx LOAD_IND");
1293 /* FIXME: analyze/verify interval + contents */
1294 repeat;
1295 }
1296 /* check if paging requests arrive on Um side */
1297 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids);
1298 [] L1CTL.receive { repeat; }
1299 [] T_itv.timeout { }
1300 [] as_rsl_res_ind();
1301 }
1302 }
1303
1304 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1305 timer T_wait := 18.0;
1306 T_wait.start;
1307 alt {
1308 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids);
1309 [] L1CTL.receive { repeat; }
1310 /* 65535 == empty paging queue, we can terminate*/
1311 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1312 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1313 [] T_wait.timeout {
1314 setverdict(fail, "Waiting for empty paging queue");
1315 }
1316 [] as_rsl_res_ind();
1317 }
1318
Harald Welte294b0a22018-03-10 23:26:48 +01001319 f_shutdown();
1320
Harald Welte68e495b2018-02-25 00:05:57 +01001321 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1322 " rcvd_ids=", st.num_paging_rcv_ids);
1323 return st;
1324}
1325
1326/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1327 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1328 * - that CCCH LOAD IND (PCH) are being generated
1329 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1330testcase TC_paging_imsi_80percent() runs on test_CT {
1331 var PagingTestCfg cfg := {
1332 combined_ccch := true,
1333 bs_ag_blks_res := 1,
1334 load_factor := 0.8,
1335 exp_load_ind := true,
1336 exp_overload := false,
1337 use_tmsi := false
1338 };
1339 var PagingTestState st := f_TC_paging(cfg);
1340 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1341 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1342 st.num_paging_rcv_ids);
1343 } else {
1344 setverdict(pass);
1345 }
1346}
1347
1348/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1349 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1350 * - that CCCH LOAD IND (PCH) are being generated
1351 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1352testcase TC_paging_tmsi_80percent() runs on test_CT {
1353 var PagingTestCfg cfg := {
1354 combined_ccch := true,
1355 bs_ag_blks_res := 1,
1356 load_factor := 0.8,
1357 exp_load_ind := true,
1358 exp_overload := false,
1359 use_tmsi := true
1360 };
1361 var PagingTestState st := f_TC_paging(cfg);
1362 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1363 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1364 st.num_paging_rcv_ids);
1365 } else {
1366 setverdict(pass);
1367 }
1368}
1369
1370/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1371 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1372 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1373 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1374testcase TC_paging_imsi_200percent() runs on test_CT {
1375 var PagingTestCfg cfg := {
1376 combined_ccch := true,
1377 bs_ag_blks_res := 1,
1378 load_factor := 2.0,
1379 exp_load_ind := true,
1380 exp_overload := true,
1381 use_tmsi := false
1382 };
1383 var PagingTestState st := f_TC_paging(cfg);
1384 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1385 * slots and will fully drain that buffer before returning */
1386 var template integer tpl := (st.num_paging_sent*80/100 .. st.num_paging_sent *85/100);
1387 if (not match(st.num_paging_rcv_ids, tpl)) {
1388 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1389 } else {
1390 setverdict(pass);
1391 }
1392}
1393
1394/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1395 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1396 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1397 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1398testcase TC_paging_tmsi_200percent() runs on test_CT {
1399 var PagingTestCfg cfg := {
1400 combined_ccch := true,
1401 bs_ag_blks_res := 1,
1402 load_factor := 2.0,
1403 exp_load_ind := true,
1404 exp_overload := true,
1405 use_tmsi := true
1406 };
1407 var PagingTestState st := f_TC_paging(cfg);
1408 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1409 * slots and will fully drain that buffer before returning */
1410 var template integer tpl := (st.num_paging_sent*68/100 .. st.num_paging_sent *72/100);
1411 if (not match(st.num_paging_rcv_ids, tpl)) {
1412 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1413 } else {
1414 setverdict(pass);
1415 }
1416}
1417
1418
Harald Welte93640c62018-02-25 16:59:33 +01001419/***********************************************************************
1420 * Immediate Assignment / AGCH
1421 ***********************************************************************/
1422
Harald Welte68e495b2018-02-25 00:05:57 +01001423testcase TC_imm_ass() runs on test_CT {
1424 f_init(testcasename());
1425 for (var integer i := 0; i < 1000; i := i+1) {
1426 var octetstring ia_enc := f_rnd_octstring(8);
1427 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
1428 f_sleep(0.02);
1429 }
1430 /* FIXME: check if imm.ass arrive on Um side */
1431 /* FIXME: check for DELETE INDICATION */
1432 f_sleep(100.0);
Harald Welte294b0a22018-03-10 23:26:48 +01001433 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001434}
1435
Harald Welte48494ca2018-02-25 16:59:50 +01001436/***********************************************************************
1437 * BCCH
1438 ***********************************************************************/
1439
1440/* tuple of Frame Number + decoded SI */
1441type record SystemInformationFn {
1442 GsmFrameNumber frame_number,
1443 SystemInformation si
1444}
1445
1446/* an arbitrary-length vector of decoded SI + gsmtap header */
1447type record of SystemInformationFn SystemInformationVector;
1448
1449/* an array of SI-vectors indexed by TC value */
1450type SystemInformationVector SystemInformationVectorPerTc[8];
1451
1452/* determine if a given SI vector contains given SI type at least once */
1453function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
1454 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
1455 var integer fn_mod51 := arr[i].frame_number mod 51;
1456 if (not bcch_ext and fn_mod51 == 2 or
1457 bcch_ext and fn_mod51 == 6) {
1458 if (arr[i].si.header.message_type == key) {
1459 return true;
1460 }
1461 }
1462 }
1463 return false;
1464}
1465
1466/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
1467function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
1468 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
1469 setverdict(fail, "No ", key, " in TC=", tc, "!");
1470 }
1471}
1472
1473/* check if a given SI vector contains given SI type at least once on any TC */
1474function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
1475 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
1476 if (f_si_vecslot_contains(arr[tc], key) or
1477 f_si_vecslot_contains(arr[tc], key, true)) {
1478 return true;
1479 }
1480 }
1481 return false;
1482}
1483
1484/* determine if a given SI vector contains given SI type at least N of M times */
1485function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
1486 var integer count := 0;
1487 if (sizeof(arr) < m) {
1488 setverdict(fail, "Error: Insufficient SI in array");
1489 self.stop;
1490 }
1491 for (var integer i:= 0; i < m; i := i + 1) {
1492 var integer fn_mod51 := arr[i].frame_number mod 51;
1493 if (not bcch_ext and fn_mod51 == 2 or
1494 bcch_ext and fn_mod51 == 6) {
1495 if (arr[i].si.header.message_type == key) {
1496 count := count + 1;
1497 }
1498 }
1499 }
1500 if (count >= n) {
1501 return true;
1502 } else {
1503 return false;
1504 }
1505}
1506
1507/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
1508function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
1509 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
1510 setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!");
1511 }
1512}
1513
1514/* determine if a given SI vector contains given SI type at least once */
1515function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
1516 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
1517 var integer fn_mod51 := arr[i].frame_number mod 51;
1518 if (not bcch_ext and fn_mod51 == 2 or
1519 bcch_ext and fn_mod51 == 6) {
1520 if (arr[i].si.header.message_type != key) {
1521 return false;
1522 }
1523 }
1524 }
1525 return true;
1526}
1527
1528/* ensure a given TC slot of the SI vector contains only given SI type */
1529function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
1530 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
1531 setverdict(fail, "Not all ", key, " in TC=", tc, "!");
1532 }
1533}
1534
1535/* SI configuration of cell, against which we validate actual SI messages */
1536type set SystemInformationConfig {
1537 boolean bcch_extended,
1538 boolean si1_present,
1539 boolean si2bis_present,
1540 boolean si2ter_present,
1541 boolean si2quater_present,
1542 boolean si7_present,
1543 boolean si8_present,
1544 boolean si9_present,
1545 boolean si13_present,
1546 boolean si13alt_present,
1547 boolean si15_present,
1548 boolean si16_present,
1549 boolean si17_present,
1550 boolean si2n_present,
1551 boolean si21_present,
1552 boolean si22_present
1553}
1554
1555/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
1556function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
1557 var integer i;
1558 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
1559 if (sizeof(si_per_tc[i]) == 0) {
Harald Welte544565a2018-03-02 10:34:08 +01001560 setverdict(fail, "No SI messages for TC=", i);
Harald Welte48494ca2018-02-25 16:59:50 +01001561 }
1562 }
1563 if (cfg.si1_present) {
1564 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
1565 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
1566 * when TC = 0, it can assume that System Information Type 1 is not in use. */
1567 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
1568 /* make sure *ALL* contain SI1 */
1569 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
1570 }
1571 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
1572 /* iii) A SI 2 message will be sent at least every time TC = 1 */
1573 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
1574 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
1575 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
1576 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
1577
1578 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
1579 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
1580 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
1581 * consecutive occurrences of TC = 4. */
1582 if (cfg.si2bis_present and not cfg.si2ter_present) {
1583 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
1584 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
1585 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
1586 } else if (cfg.si2ter_present and cfg.si2bis_present) {
1587 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
1588 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
1589 }
1590
1591 if (cfg.si7_present or cfg.si8_present) {
1592 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
1593 * if System Information type 4 does not contain all information needed for cell
1594 * selection and reselection. */
1595 if (not cfg.bcch_extended) {
1596 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
1597 }
1598 if (cfg.si7_present) {
1599 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
1600 }
1601 if (cfg.si8_present) {
1602 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
1603 }
1604 }
1605
1606 if (cfg.si2quater_present) {
1607 /* iii) System information type 2 quater is sent if needed, as determined by the system
1608 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
1609 * and 2ter are used, otherwise it shall be sent at least once within any of 4
1610 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
1611 * within any of 4 consecutive occurrences of TC = 5. */
1612 if (not (cfg.bcch_extended)) {
1613 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
1614 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
1615 } else {
1616 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
1617 }
1618 } else {
1619 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
1620 }
1621 }
1622 if (cfg.si9_present) {
1623 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
1624 * in system information type 3 as defined in 3GPP TS 44.018. */
1625 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
1626 }
1627 if (cfg.si13_present) {
1628 /* vii) System Information type 13 is only related to the GPRS service. System Information
1629 * Type 13 need only be sent if GPRS support is indicated in one or more of System
1630 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
1631 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
1632 * In the case that the message is sent on the BCCH Norm, it is sent at least once
1633 * within any of 4 consecutive occurrences of TC=4. */
1634 if (not cfg.bcch_extended) {
1635 log("not-bccch-extended");
1636 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
1637 } else {
1638 log("bccch-extended");
1639 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
1640 }
1641 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
1642 setverdict(fail, "Cannot have SI13alt and SI13");
1643 }
1644 }
1645 if (cfg.si16_present or cfg.si17_present) {
1646 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
1647 * should not be sent in a cell where network sharing is used (see rule xv). */
1648 if (cfg.si22_present) {
1649 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
1650 }
1651 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
1652 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
1653 }
1654 if (not cfg.bcch_extended) {
1655 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
1656 }
1657 if (cfg.si16_present) {
1658 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
1659 }
1660 if (cfg.si17_present) {
1661 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
1662 }
1663 }
1664
1665 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
1666 * broadcast information. The frequency with which they are sent is determined by the
1667 * system operator. System Information type 9 identifies the scheduling of System
1668 * Information type 18 and 20 messages. */
1669
1670 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
1671 * Information Type 19 is present, then its scheduling shall be indicated in System
1672 * Information Type 9. */
1673
1674 if (cfg.si15_present) {
1675 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
1676 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
1677 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
1678 * 4 consecutive occurrences of TC = 1. */
1679 if (not cfg.bcch_extended) {
1680 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
1681 } else {
1682 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
1683 }
1684 }
1685 if (cfg.si13alt_present) {
1686 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
1687 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
1688 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
1689 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
1690 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
1691 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
1692 * of TC = 4. */
1693 if (cfg.si13_present) {
1694 testcase.stop("Error: Cannot have SI13alt and SI13");
1695 }
1696 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
1697 setverdict(fail, "Cannot have SI13alt and SI13");
1698 }
1699 if (not cfg.bcch_extended) {
1700 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
1701 } else {
1702 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
1703 }
1704 }
1705 if (cfg.si2n_present) {
1706 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
1707 * as determined by the system operator. In the case that the message is sent on the
1708 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
1709 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
1710 * consecutive occurrences of TC = 4. */
1711 if (not cfg.bcch_extended) {
1712 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
1713 } else {
1714 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
1715 }
1716 }
1717 if (cfg.si21_present) {
1718 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
1719 * determined by the system operator. If Extended Access Barring is in use in the cell
1720 * then this message is sent at least once within any of 4 consecutive occurrences of
1721 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
1722 * cell then this message shall only be sent on BCCH Ext. */
1723 if (not cfg.bcch_extended) {
1724 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
1725 } else {
1726 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
1727 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
1728 setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
1729 }
1730 }
1731 }
1732 if (cfg.si22_present) {
1733 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
1734 * should not be sent in a cell where SoLSA is used (see rule viii). System
1735 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
1736 * =2 and TC=6. */
1737 if (cfg.si16_present or cfg.si17_present) {
1738 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
1739 }
1740 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
1741 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
1742 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
1743 }
1744 if (not cfg.bcch_extended) {
1745 testcase.stop("Error: SI22 requires BCCH Extd!");
1746 } else {
1747 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
1748 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
1749 }
1750 }
1751}
1752
1753/* sample Systme Information for specified duration via L1CTL */
1754function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
1755 timer T := duration;
1756 var SystemInformationVectorPerTc si_per_tc;
1757 var L1ctlDlMessage l1_dl;
1758
1759 /* initialize all per-TC vectors empty */
1760 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
1761 si_per_tc[i] := {};
1762 }
1763
1764 /* flush all previous L1 queued msgs */
1765 pt.clear;
1766
1767 T.start;
1768 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001769 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01001770 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
1771 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
1772 log("Ignoring non-RR SI ", l1_dl);
1773 repeat;
1774 }
1775 var SystemInformationFn sig := {
1776 frame_number := l1_dl.dl_info.frame_nr,
1777 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
1778 }
1779 var integer tc := f_gsm_compute_tc(sig.frame_number);
1780 log("SI received at TC=", tc, ": ", sig.si);
1781 /* append to the per-TC bucket */
1782 si_per_tc[tc] := si_per_tc[tc] & { sig };
1783 repeat;
1784 }
1785 [] pt.receive { repeat; }
1786 [] T.timeout { }
1787 }
1788
1789 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
1790 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
1791 }
1792 log("si_per_tc=", si_per_tc);
1793 return si_per_tc;
1794}
1795
1796/* helper function: Set given SI via RSL + validate scheduling.
1797 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
1798function f_TC_si_sched() runs on test_CT {
1799 var SystemInformationVectorPerTc si_per_tc;
1800 f_init_l1ctl();
1801 f_l1_tune(L1CTL);
1802
1803 /* Sample + Validate Scheduling */
1804 si_per_tc := f_l1_sample_si(L1CTL);
1805 f_validate_si_scheduling(si_cfg, si_per_tc);
1806
1807 setverdict(pass);
1808}
1809
1810testcase TC_si_sched_default() runs on test_CT {
1811 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01001812 /* 2+3+4 are mandatory and set in f_init() */
1813 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001814 f_shutdown();
Harald Welte0cae4552018-03-09 22:20:26 +01001815}
1816
1817testcase TC_si_sched_1() runs on test_CT {
1818 f_init();
1819 si_cfg.si1_present := true;
1820 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01001821 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001822 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001823}
1824
1825testcase TC_si_sched_2bis() runs on test_CT {
1826 f_init();
1827 si_cfg.si2bis_present := true;
1828 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
1829 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001830 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001831}
1832
1833testcase TC_si_sched_2ter() runs on test_CT {
1834 f_init();
1835 si_cfg.si2ter_present := true;
1836 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
1837 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001838 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001839}
1840
1841testcase TC_si_sched_2ter_2bis() runs on test_CT {
1842 f_init();
1843 si_cfg.si2bis_present := true;
1844 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
1845 si_cfg.si2ter_present := true;
1846 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
1847 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001848 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001849}
1850
1851testcase TC_si_sched_2quater() runs on test_CT {
1852 f_init();
1853 si_cfg.si2quater_present := true;
1854 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
1855 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001856 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001857}
1858
1859testcase TC_si_sched_13() runs on test_CT {
1860 f_init();
1861 si_cfg.si13_present := true;
1862 //f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, fixme);
1863 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001864 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001865}
1866
1867testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
1868 f_init();
1869 si_cfg.si2bis_present := true;
1870 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
1871 si_cfg.si2ter_present := true;
1872 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
1873 si_cfg.si2quater_present := true;
1874 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
1875 si_cfg.si13_present := true;
1876 //f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, fixme);
1877 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01001878 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01001879}
1880
1881
Harald Welte68e495b2018-02-25 00:05:57 +01001882testcase TC_bcch_info() runs on test_CT {
1883 f_init(testcasename());
1884 /* FIXME: enable / disable individual BCCH info */
1885 //ts_RSL_BCCH_INFO(si_type, info);
1886 /* expect no ERROR REPORT after either of them *
1887 /* negative test: ensure ERROR REPORT on unsupported types */
Harald Welte294b0a22018-03-10 23:26:48 +01001888 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001889}
1890
Harald Welte93640c62018-02-25 16:59:33 +01001891/***********************************************************************
1892 * Low-Level Protocol Errors / ERROR REPORT
1893 ***********************************************************************/
1894
Harald Welte01d982c2018-02-25 01:31:40 +01001895private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
1896 timer T := 5.0;
1897 T.start;
1898 alt {
1899 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
1900 setverdict(pass);
1901 }
1902 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
1903 setverdict(fail, "Wrong cause in RSL ERR REP");
1904 }
1905 [] RSL_CCHAN.receive {
1906 repeat;
1907 }
1908 [] T.timeout {
1909 setverdict(fail, "Timeout waiting for RSL ERR REP");
1910 }
1911 }
1912}
1913
1914/* Provoke a protocol error (message too short) and match on ERROR REPORT */
1915testcase TC_rsl_protocol_error() runs on test_CT {
1916 f_init(testcasename());
1917 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
1918 rsl.ies := omit;
1919 RSL_CCHAN.send(ts_RSL_UD(rsl));
1920
1921 f_exp_err_rep(RSL_ERR_PROTO);
1922}
1923
1924/* Provoke a mandatory IE error and match on ERROR REPORT */
1925testcase TC_rsl_mand_ie_error() runs on test_CT {
1926 f_init(testcasename());
1927
1928 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
1929 rsl.ies := { rsl.ies[0] };
1930 RSL_CCHAN.send(ts_RSL_UD(rsl));
1931
1932 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
1933}
1934
1935/* Provoke an IE content error and match on ERROR REPORT */
1936testcase TC_rsl_ie_content_error() runs on test_CT {
1937 f_init(testcasename());
1938 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
1939 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
1940 RSL_CCHAN.send(ts_RSL_UD(rsl));
1941
1942 f_exp_err_rep(RSL_ERR_IE_CONTENT);
1943}
1944
Harald Welte93640c62018-02-25 16:59:33 +01001945/***********************************************************************
1946 * IPA CRCX/MDCX/DLCS media stream handling
1947 ***********************************************************************/
1948
Harald Weltea871a382018-02-25 02:03:14 +01001949/* Send IPA DLCX to inactive lchan */
1950function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01001951 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
1952 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01001953}
1954testcase TC_ipa_dlcx_not_active() runs on test_CT {
1955 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1956 f_init(testcasename());
1957 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
1958 vc_conn.done;
1959}
Harald Welte68e495b2018-02-25 00:05:57 +01001960
Harald Weltea3f1df92018-02-25 12:49:55 +01001961/* Send IPA CRCX twice to inactive lchan */
1962function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
1963 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1964 "IPA CRCX ACK");
1965 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
1966 "IPA CRCX NACK");
1967}
1968testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
1969 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1970 f_init(testcasename());
1971 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
1972 vc_conn.done;
1973}
1974
1975/* Regular sequence of CRCX/MDCX/DLCX */
1976function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
1977 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1978 "IPA CRCX ACK");
1979 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
1980 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
1981 var uint7_t rtp_pt2 := f_rnd_int(127);
1982 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
1983 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
1984 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
1985 "IPA MDCX ACK");
1986 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
1987 "IPA DLCX ACK");
1988}
1989testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
1990 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1991 f_init(testcasename());
1992 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
1993 vc_conn.done;
1994}
1995
Harald Welte3ae11da2018-02-25 13:36:06 +01001996/* Sequence of CRCX, 2x MDCX, DLCX */
1997function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
1998 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1999 "IPA CRCX ACK");
2000 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2001 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2002 var uint7_t rtp_pt2 := f_rnd_int(127);
2003 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2004 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2005 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2006 "IPA MDCX ACK");
2007 /* Second MDCX */
2008 remote_ip := f_rnd_int(c_UINT32_MAX);
2009 remote_port := f_rnd_int(c_UINT16_MAX);
2010 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2011 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2012 "IPA MDCX ACK");
2013 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2014 "IPA DLCX ACK");
2015}
2016testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2017 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2018 f_init(testcasename());
2019 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2020 vc_conn.done;
2021}
2022
Harald Welte9912eb52018-02-25 13:30:15 +01002023/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2024function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2025 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2026 "IPA CRCX NACK");
2027}
2028testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2029 var ConnHdlrPars pars;
2030 var ConnHdlr vc_conn;
2031 f_init(testcasename());
2032
2033 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2034 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2035 vc_conn.done;
2036
2037 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2038 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2039 vc_conn.done;
2040}
2041
Harald Weltea3f1df92018-02-25 12:49:55 +01002042
Harald Welte883340c2018-02-28 18:59:29 +01002043/***********************************************************************
2044 * PCU Socket related tests
2045 ***********************************************************************/
2046
2047private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2048runs on test_CT {
2049 timer T := 3.0;
2050
2051 /* we don't expect any RTS.req before PDCH are active */
2052 T.start;
2053 alt {
2054 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
2055 setverdict(fail, "PCU RTS.req before PDCH active?");
2056 self.stop;
2057 }
2058 [] PCU.receive { repeat; }
2059 [] T.timeout { }
2060 }
2061
2062 /* Send PDCH activate request for known PDCH timeslot */
2063 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2064
2065 /* we now expect RTS.req for this timeslot (only) */
2066 T.start;
2067 alt {
2068 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2069 setverdict(pass);
2070 }
2071 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2072 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2073 setverdict(fail, "Unexpected RTS.req for supposedly failing activation");
2074 self.stop;
2075 }
2076 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
2077 setverdict(fail, "RTS.req for wrong TRX/TS");
2078 self.stop;
2079 }
2080 [] PCU.receive { repeat; }
2081 [exp_success] T.timeout {
2082 setverdict(fail, "Timeout waiting for PCU RTS.req");
2083 }
2084 [not exp_success] T.timeout {
2085 setverdict(pass);
2086 }
2087 }
2088}
2089
2090private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2091runs on test_CT {
2092 timer T := 3.0;
2093
2094 /* Send PDCH activate request for known PDCH timeslot */
2095 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2096
2097 PCU.clear;
2098 /* we now expect no RTS.req for this timeslot */
2099 T.start;
2100 alt {
2101 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2102 setverdict(fail, "Received unexpected PCU RTS.req");
2103 self.stop;
2104 }
2105 [] PCU.receive { repeat; }
2106 [] T.timeout {
2107 setverdict(pass);
2108 }
2109 }
2110}
2111
2112/* PDCH activation via PCU socket; check for presence of RTS.req */
2113testcase TC_pcu_act_req() runs on test_CT {
2114 f_init();
2115 f_TC_pcu_act_req(0, 0, 7, true);
2116}
2117
2118/* PDCH activation via PCU socket on non-PDCU timeslot */
2119testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
2120 f_init();
2121 f_TC_pcu_act_req(0, 0, 1, false);
2122}
2123
2124/* PDCH activation via PCU socket on wrong BTS */
2125testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
2126 f_init();
2127 f_TC_pcu_act_req(23, 0, 7, false);
2128}
2129
2130/* PDCH activation via PCU socket on wrong TRX */
2131testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
2132 f_init();
2133 f_TC_pcu_act_req(0, 23, 7, false);
2134}
2135
2136/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2137testcase TC_pcu_deact_req() runs on test_CT {
2138 f_init();
2139 /* Activate PDCH */
2140 f_TC_pcu_act_req(0, 0, 7, true);
2141 f_sleep(1.0);
2142 /* and De-Activate again */
2143 f_TC_pcu_deact_req(0, 0, 7);
2144}
2145
2146/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2147testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
2148 f_init();
2149 f_TC_pcu_deact_req(0, 0, 1);
2150}
2151
2152/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2153testcase TC_pcu_ver_si13() runs on test_CT {
2154 const octetstring si13 := '00010203040506070909'O;
2155 var PCUIF_send_data sd;
2156 timer T:= 3.0;
2157 f_init();
2158
2159 /* Set SI13 via RSL */
2160 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
2161 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, "BTS_Test v23")));
2162 T.start;
2163 alt {
2164 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2165 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2166 setverdict(pass);
2167 } else {
2168 repeat;
2169 }
2170 }
2171 [] PCU.receive { repeat; }
2172 [] T.timeout {
2173 setverdict(fail, "Timeout waiting for SI13");
2174 self.stop;
2175 }
2176 }
2177}
2178
2179private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2180
2181/* helper function to send a PCU DATA.req */
2182private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2183 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2184runs on test_CT
2185{
2186 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2187 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2188}
2189
2190/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2191private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2192 PCUIF_Sapi sapi, octetstring data)
2193runs on test_CT
2194{
2195 var PCUIF_send_data sd;
2196
2197 timer T := 3.0;
2198 T.start;
2199 alt {
2200 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2201 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2202 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2203 sd.data.u.rts_req.fn, sapi, data);
2204 }
2205 [] PCU.receive { repeat; }
2206 [] T.timeout {
2207 setverdict(fail, "Timeout waiting for RTS.ind");
2208 }
2209 }
2210}
2211
2212/* Send DATA.req on invalid BTS */
2213testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
2214 f_init();
2215 f_TC_pcu_act_req(0, 0, 7, true);
2216 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2217 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2218 f_sleep(10.0);
2219}
2220
2221/* Send DATA.req on invalid TRX */
2222testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
2223 f_init();
2224 f_TC_pcu_act_req(0, 0, 7, true);
2225 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2226 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2227 f_sleep(10.0);
2228}
2229
2230/* Send DATA.req on invalid timeslot */
2231testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
2232 f_init();
2233 f_TC_pcu_act_req(0, 0, 7, true);
2234 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2235 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2236 f_sleep(10.0);
2237}
2238
2239/* Send DATA.req on timeslot that hasn't been activated */
2240testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
2241 f_init();
2242 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2243 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2244 f_sleep(2.0);
2245}
2246
2247testcase TC_pcu_data_req_pdtch() runs on test_CT {
2248 f_init();
2249 f_TC_pcu_act_req(0, 0, 7, true);
2250 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2251 /* FIXME: how to check this was actually sent */
2252 f_sleep(2.0);
2253}
2254
2255testcase TC_pcu_data_req_ptcch() runs on test_CT {
2256 f_init();
2257 f_TC_pcu_act_req(0, 0, 7, true);
2258 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2259 /* FIXME: how to check this was actually sent */
2260 f_sleep(2.0);
2261}
2262
2263/* Send AGCH from PCU; check it appears on Um side */
2264testcase TC_pcu_data_req_agch() runs on test_CT {
2265 timer T := 3.0;
2266 f_init();
2267 f_init_l1ctl();
2268 f_l1_tune(L1CTL);
2269
2270 f_TC_pcu_act_req(0, 0, 7, true);
2271 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2272
2273 T.start;
2274 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002275 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002276 setverdict(pass);
2277 }
2278 [] L1CTL.receive { repeat; }
2279 [] T.timeout {
2280 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
2281 }
2282 }
2283}
2284
2285/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2286testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2287 var octetstring imm_ass := f_rnd_octstring(23);
2288 f_init();
2289 f_init_l1ctl();
2290 f_l1_tune(L1CTL);
2291
2292 /* append 3 last imsi digits so BTS can compute pagng group */
2293 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2294
2295 timer T := 0.5;
2296 T.start;
2297 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002298 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002299 /* TODO: verify paging group */
2300 setverdict(pass);
2301 }
2302 [] L1CTL.receive { repeat; }
2303 [] T.timeout {
2304 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
2305 }
2306 }
2307}
2308
2309/* Send RACH from Um side, expect it to show up on PCU socket */
2310testcase TC_pcu_rach_content() runs on test_CT {
2311 f_init();
2312 f_init_l1ctl();
2313 f_l1_tune(L1CTL);
2314
2315 var GsmFrameNumber fn_last := 0;
2316 for (var integer i := 0; i < 1000; i := i+1) {
2317 var OCT1 ra := f_rnd_ra_ps();
2318 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2319 if (fn == fn_last) {
2320 setverdict(fail, "Two RACH in same FN?!?");
2321 self.stop;
2322 }
2323 fn_last := fn;
2324
2325 timer T := 2.0;
2326 T.start;
2327 alt {
2328 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2329 T.stop;
2330 }
2331 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
2332 setverdict(fail, "Unexpected RACH IND");
2333 self.stop;
2334 }
2335 [] PCU.receive { repeat; }
2336 [] T.timeout {
2337 setverdict(fail, "Timeout waiting for RACH IND");
2338 self.stop;
2339 }
2340 }
2341 }
2342 setverdict(pass);
2343}
2344
2345private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
2346 var integer strlen := lengthof(str);
2347 for (var integer i := 0; i < len-strlen; i := i+1) {
2348 str := str & pad;
2349 }
2350 return str;
2351}
2352
2353/* Send PAGING via RSL, expect it to shw up on PCU socket */
2354testcase TC_pcu_paging_from_rsl() runs on test_CT {
2355 f_init();
2356
2357 for (var integer i := 0; i < 100; i := i+1) {
2358 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2359 timer T := 3.0;
2360 if (i < 50) {
2361 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2362 } else {
2363 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
2364 }
2365 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2366 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2367 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
2368
2369 /* Send RSL PAGING COMMAND */
2370 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
2371 T.start;
2372 alt {
2373 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
2374 }
2375 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
2376 setverdict(fail, "Unexpected PAGING REQ");
2377 self.stop;
2378 }
2379 [] PCU.receive { repeat; }
2380 [] T.timeout {
2381 setverdict(fail, "Timeout waiting for PAGING REQ");
2382 self.stop;
2383 }
2384 }
2385 }
2386 setverdict(pass);
2387}
2388
2389
Harald Welte68e495b2018-02-25 00:05:57 +01002390/* TODO Areas:
2391
2392* channel activation
2393** with BS_Power / MS_Power, bypassing power control loop
2394** on primary vs. secondary TRX
2395** with encryption from initial activation on
2396** with timing advance from initial activation on
2397* mode modify
2398** encryption
2399** multirate
2400* check DEACTIVATE SACCH
2401* encryption command / intricate logic about tx-only/tx+rx/...
2402** unsupported algorithm
2403* handover detection
2404* MS Power Control
2405* BS Power Control
2406* Physical Context
2407* SACCH info modify
Harald Welte68e495b2018-02-25 00:05:57 +01002408* CCCH Load Indication for PCH and RACH
2409* Delete Indication on AGCH overflow
2410* SMS Broadcast Req / Cmd / CBCH LOad Ind
2411* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01002412* error handling
2413* discriminator error
2414** type error
2415** sequence error
2416** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01002417* PCU interface
2418** TIME_IND from BTS->PCU
2419** DATA_IND from BTS->PCU
2420** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01002421
2422*/
Harald Welte70767382018-02-21 12:16:40 +01002423
2424control {
2425 execute( TC_chan_act_stress() );
2426 execute( TC_chan_act_react() );
2427 execute( TC_chan_deact_not_active() );
2428 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01002429 execute( TC_deact_sacch() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01002430 execute( TC_rach_content() );
2431 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01002432 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01002433 execute( TC_meas_res_sign_tchf() );
2434 execute( TC_meas_res_sign_tchh() );
2435 execute( TC_meas_res_sign_sdcch4() );
2436 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01002437 execute( TC_meas_res_sign_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01002438 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01002439 execute( TC_paging_imsi_80percent() );
2440 execute( TC_paging_tmsi_80percent() );
2441 execute( TC_paging_imsi_200percent() );
2442 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01002443 execute( TC_rsl_protocol_error() );
2444 execute( TC_rsl_mand_ie_error() );
2445 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01002446 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01002447 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01002448 execute( TC_si_sched_2bis() );
2449 execute( TC_si_sched_2ter() );
2450 execute( TC_si_sched_2ter_2bis() );
2451 execute( TC_si_sched_2quater() );
2452 execute( TC_si_sched_13() );
2453 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01002454 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01002455 execute( TC_ipa_crcx_twice_not_active() );
2456 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01002457 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01002458 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01002459
2460 execute( TC_pcu_act_req() );
2461 execute( TC_pcu_act_req_wrong_ts() );
2462 execute( TC_pcu_act_req_wrong_bts() );
2463 execute( TC_pcu_act_req_wrong_trx() );
2464 execute( TC_pcu_deact_req() );
2465 execute( TC_pcu_deact_req_wrong_ts() );
2466 execute( TC_pcu_ver_si13() );
2467 execute( TC_pcu_data_req_wrong_bts() );
2468 execute( TC_pcu_data_req_wrong_trx() );
2469 execute( TC_pcu_data_req_wrong_ts() );
2470 execute( TC_pcu_data_req_ts_inactive() );
2471 execute( TC_pcu_data_req_pdtch() );
2472 execute( TC_pcu_data_req_ptcch() );
2473 execute( TC_pcu_data_req_agch() );
2474 execute( TC_pcu_data_req_imm_ass_pch() );
2475 execute( TC_pcu_rach_content() );
2476 execute( TC_pcu_paging_from_rsl() );
Harald Welte70767382018-02-21 12:16:40 +01002477}
2478
2479
2480}